Gadgets are small programs which generate images 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.
The gadgets can be written in any language which can be interpreted by your webserver. Some options can be PHP, Perl,...
Gadgets are only supported for service objects. An object can be turned into a gadget by setting view_type="gadget" and a valid gadget_url.
NagVis supports gadgets since version 1.4.
NagVis 1.4 std_speedometer gadget on test map with enabled label.
The gadgets get their information via a HTTP-Get call from NagVis.
The following parameters are being passed to the gadgets:
Parameter | Example value | Description |
---|---|---|
name1 | localhost | The name of the host. |
name2 | Current Load | The service description of the object. |
scale | 100 | The scale of the gadget. |
state | OK | The string which represents the current state. |
stateType | HARD | The type of the current state. Can be HARD or SOFT |
perfdata | load1=0.960;5.000;10.000;0; load5=0.570;4.000;6.000;0; load15=0.540;3.000;4.000;0; | The current performance data information provided by Nagios. It's important to have valid performance data here. |
A valid http get on the std_speedometer.php looks like this:
std_speedometer.php?name1=localhost&name2=Current%20Load&state=OK&stateType=HARD&perfdata=load1=0.450;5.000;10.000;0;%20load5=0.260;4.000;6.000;0;%20load15=0.750;3.000;4.000;0;
Please check the parameters view_type
and gadget_url
on service object in the map configuration format description
Using the code shown included in gadgets_core.php two arrays are filled. $aPerfdata contains the performance data. $aOpts contains the options set in gadget_opts.
The best thing is to take a look at the std_speedometer and adapt the core things from there.
You should set a sample perfdata string in the gadget code by writing it to the variable $sDummyPerfdata. This makes it possible to show the gadget with dummy data in the WUI. It's much easier to design the maps in the WUI when the gadgets are shown there. Important: The variable needs to be set before the gadgets_core.php is included.
A second example can be found in std_speedometer2.php. In contrast to std_speedometer.php it supports output produced by check_multi. Several options influence the behaviour of the gadget:
Parameter | Example value | Description |
---|---|---|
label | 1 | 1 = Show host name / service description in the upper left corner of the graph; 0 = don't show the information (default) |
current | 1 | 1 = Show the current performance data value (default); 0 = don't show the information |
columns | 5 | Graphs can be arranged in columns. The number of rows is calculated based on the maximum number of performance data items. Default is 3 |
string | pct | The performance data label has to contain the string to be displayed. In case of check_multi output only the last part is examined. Default is an empty string |