TECHZEN Zenoss User Community ARCHIVE  

ZenPack devel, how is the logic to generate events

Subject: ZenPack devel, how is the logic to generate events
Author: Daniel Vogel
Posted: 2019-02-20 08:58

Hello,

I'm trying to develop a ZenPack with the samples from https://zenpack-sdk.zenoss.com/en/latest/index.html and ZenPack_DevGuide_V1.0.1_publish1_20161013.pdf.

The ZenPack monitors ZFS file system and disk status over SNMP.

So far, I understand the modeler development.
The result is:

What I do not understand:
- How can I add some triggers to generate events if a file system or disk becomes DEGRADED?
- If I have SNMP values with counters, for example error counters. I think the right variant is a "monitoring template" with a threshold?
- Only "model device" will update the values, for example "Wert3"?

For information on how the components work together, I thank you in advance.

------------------------------
Daniel Vogel
ABC Systems AG
------------------------------


Subject: RE: ZenPack devel, how is the logic to generate events
Author: Pheripheral Pheripheral
Posted: 2019-02-21 04:39

Hi,

I've done something similar to this I think.

For the degraded 'trigger' it depends on what snmp value you are collecting to indicate the disk status.
If it is a number (hopefully it is) then you can create a monitoring template for the device type and add that snmp value as one of the datasources on the template. 
Then you can add a threshold on this value and set it so that it raises an event when the value goes above / below / out of a certain value / range.
The event it raises can then have a transform on it that updates the modelled component.

I do something similar to update status of disks with a transform that looks bit like (this is approx psuedocode - not the actual code!):

if component if not None:

    # get value from event
    snmpValue = int(float(getattr(evt,'current', '0')))
    if snmpValue != expectedValue:
        # set event details 
        evt.summary = 'Status Degraded on ' + component.id
        # set to warning event
        evt.severity = 4 
        # update the component
        @transact
       def update():
            component.modelledStatusproperty = snmpValue
       updateDb()

​​​​​
If you actually managinig to collect disk status as a numeric but still want it to show as the string on screen you can use a renderer to translate the value to the string, something like:

/*
* Customizations to device Page
* This file name must match the name of the Device object in the yaml
*/
Ext.apply(Zenoss.render, {
StatusRenderer: function(n) {
var status = parseInt(n)
switch (status) {
case 1:
result = 'Up';
break;
case 0:
result = 'Degraded';
break;
default:
result = 'Unknown';
}
return result;
},
});
​​​

There is also a way to have the modelled component property hooked up to a template value, but i find that for status type values this tends to set the value as an average so you end up with 0.5s /  0.6s etc... rather than a definitive 0 or 1 for a status type value, hence the threshold and event transform update method as above. This is mentioned in Jane's zenpack document somewhere (section 10.3.6 i think about using the datapoint keyword )


If the wert 2 value if actually a string coming back from the device in the snmp, then its harder to do this in performance templates as they are not happy collecting strings. i ran into this previously - see the thread about it
https://community.zenoss.com/forum/community-home/digestviewer/viewthread?MessageKey=9fbf07e4-cd78-4beb-ad9b-90ed2a574b94&CommunityKey=bf8b1900-b44f-44c3-8287-3b60f8023cf4&tab=digestviewer#bm9fbf07e4-cd78-4beb-ad9b-90ed2a574b94

Ultimately solved by triggering a remodel to collect the string once a numeric status indicator changed. I would only advise using this if you suspect it will only trigger rarely as it could have performance impacts.

Hope this helps / hope i'm doing it right!

------------------------------
Pheripheral Pheripheral
------------------------------


Subject: RE: ZenPack devel, how is the logic to generate events
Author: Daniel Vogel
Posted: 2019-02-22 02:29

Hi,

Thank you very much, exactly the information that I need.
I use a ZFS SNMP extension "pass_persist .1.3.6.1.4.1.53044 /install/snmp/snmpExtend.py" and it's easy to code the text, for example Wert2 "DEGRADED", to a number.

In addition, I found flowing information "ZenPack SDK 4.4.5", to map the events to the correct entry.

...
How do we know what to name a monitoring template that should be used to monitor ourNetBotzTemperatureSensorcomponents?
By default the monitoring template should be named the same as the component class'labelpropertywith all spaces removed. In theComponent Modelingsection we set the label for theNetBotzTemperatureSensorclassto beTemperature Sensor. This means out monitoring template should be namedTemperatureSensor.

Thanks

------------------------------
Daniel Vogel
------------------------------


Subject: RE: ZenPack devel, how is the logic to generate events
Author: Ryan Matte
Posted: 2019-02-21 10:46

Hi Daniel,

You said that status value is currently only being picked up during modelling, which is not going to be very useful from a monitoring standpoint as the modelling generally only occurs every 6 hours or so by default.  You are correct that you would need a monitoring template that has a datapoint configured to collect the status value for each of those components and then you'd need a threshold to trigger against that if the status is an abnormal value.  You could then use an event transform to modify the look of those threshold events if needed.

Pheripheral's post about collecting the value via a template and then using a renderer in the ZenPack code to display that value in the columns for those components is spot on.  Hopefully this helps to get you oriented in the right direction to get what you're wanting.



------------------------------
Ryan Matte
------------------------------


Subject: RE: ZenPack devel, how is the logic to generate events
Author: Daniel Vogel
Posted: 2019-02-22 02:37

Hi Ryan,

You're right. I can do it exactly the same way and now I have the necessary information.

Thanks

------------------------------
Daniel Vogel
IT Infrastructure Architect
ABC Systems AG
Schlieren
------------------------------


< Previous
Zenoss 4.2.5 - install extra libraries for use in a zenpack
  Next
Cannot open zenoss
>