Icon image based on the service status / value

nagvis
nagios
#1

Hi,

How can I set the icon of a service object based on its status or value?

For example, I want to monitor a cluster node and I am looking to have a Nagios NCPA script that returns 0 for standby and 1 for active. I want a specific icon to be displayed whether it is standby or active.

#2

Looking at the documentation there is a way to adjust the icons on the maps.

#3

I’m aware of, and I am using, the iconset feature.

I thought the icon used is based on the status of the service check?

For example, the cluster nodes will will return a status of OK for the NCPA check, along with the value of either 0 (standby) or 1 (active) to indicate the node cluster status.

Since the both nodes returns a status of OK - since the script has executed correctly - the object will use the same image from the iconset.

However, I want the image to be based on the returned value - either 0 or 1.

I suppose the workaround is to get the script to return some other status value, but I think this is wrong as I still want to know if the script has executed OK or not.

#4

Looking at the documentation you’ll see that there is an option “iconset” for services, too.

The state is based on the return code of the script, not on the output.

Taking at look at the plugins development guidelines you have to adjust your assumptions. If you execute a check on the diskspace of a volume its return code will change according to your thresholds, although it is executed correctly.

#5

Hi,

Apologies. I’m being lazy and not explaining myself clearly and I’m using the wrong terminology. Thank you for your patience.

I want the service icon to be based on the ‘Peformance Data’ that is returned by the script. The script I’m using returns the following as ‘Perfromance Data’:

State=value

where value is either 0 (if the node is in standby) or 1 (if the node is active).

I’m not wanting to use this script to alert on anything, I just want to use it to provide visual information on my NagVis map - i.e. which host/node is the active one and which is the standby one.

Is this possible to do - use an icon based on the performance data value?

Note: I was able to do such a thing when I used Cacti with phpweathermap. So, I would like to replicate the same/similar.

#6

You might be able to create a gadget showing different icons based on the performance data. I’m not sure if this will help to alter the state of the host object when the performance data of a service changes.

#7

Thanks for the tip about gadgets. It does look like I might be able to use that - since it state:

“Gadgets are small programs which generate images or HTML code from information which is provided by NagVis. The main idea is to provide the performance data of Nagios to these programs for visualizing it as nice graphs or fancy speedometers, thermometers etc.”

So, I interpret this as being able to return an image based on the performance data that is given to it.

I’m not looking to use this to alter the host object, I just want an additional service object icon that indicates the cluster status of it.

Note, I have tried and successfully used the returned status code of the script to change the icon of a service - for example if I get the script to return an exit code of 3 (for unknown) if the cluster state of that node is 0 (standby). But I don’t think this is the right approach. Or rather, I’ll only use this if nothing else works.

#8

Hi,

Just wanted to report back that I was able to create a very simple gadget that returned an png image based on the performance data value sent to it.

Thank you for your help - very much appreciated!