OK I am posting my own solution to this problem. After reviewing how bad
this post was, I surprised that I was able to find an answer. I will
restate the problem, so that searches can help find solution:
*Problem: *
I have a Sensatronics network attached temperature monitor that uses a
Nagios plugin (check_temptraxe) to monitor the temperature in our server
rooms. After following the HowToNagiosCreateTemplate wiki page to set up
the check, no RRD database is created, and no graphs are displayed.
Configuration:
Data Source
Name: 5thFlrSrvrRm
Source Type: Command
Enabled: True
Use SSH: False
Component: roomTemp
Event Class: /Status/Temp
Event Key: floor5
Severity: Warning
Cycle Time: 300
Command Template:
check_temptraxe -H $devname -p 2 -w 78 -c 85
DataPoints
Name Type
5thFlrSrvrRm GAUGE
Troubleshooting:
To begin with, I expect that you have already followed the steps in the
HowToNagiosCreateTemplate wiki page to craft your initial command
template. If you have not run your Nagios command successfully from a
command line, go back and review that page first.
To test the configuration, as the zenoss user execute "zencommand run -d
<zenossdevicename> -v 10" from the host that will be performing the
monitoring. NOTE: For zenossdevicename use the device name that is
configured in zenoss. If you have configured zenoss to identify the
device only by the hostname, enter just the hostname, not the fully
qualified hostname. If the device is identified by the fully qualified
hostname in the Zenoss Devices page, adjust accordingly.
The output can help you identify any problems with your configuration:
[EMAIL PROTECTED] zenoss]$ zencommand run -d <zenossdevicename> -v10
DEBUG:zen.zencommand:Fetching config
DEBUG:zen.zencommand:Updated configCycleInterval config to 30
DEBUG:zen.zencommand:Finished config fetch
A DEBUG:zen.zencommand:running '/opt/zenoss/libexec/check_temptraxe -H
therm.mydomain.com -p 2 -w 78 -c 85'
B DEBUG:zen.zencommand:cmd line: '/bin/sh -c exec
/opt/zenoss/libexec/check_temptraxe -H therm.mydomain.com -p 2 -w 78 -c 85'
DEBUG:zen.zencommand:Process check_temptraxe -H therm.mydomain.com -p 2 -w
78 -c 85 started
DEBUG:zen.Events:Found device=monitorhost.mydomain.com
DEBUG:zen.Events:EventClassInst=Start
DEBUG:zen.Events:update status set clearid = '0acac7ef3537b8a7fffffff' where
device='monitorhost.mydomain.com' and component='zencommand' and eventKey='' and
(eventClass='/App/Stop' or eventClass='/App/Start'): --> 0
DEBUG:zen.Events:insert into log (evid, userName, text) select evid, "admin", "auto
cleared" from status where clearid = "0acac7ef3537b8a7fffffff": --> 0
DEBUG:zen.Events:insert into history set
Location='',prodState=1000,firstTime=1177074471.261,severity=0,component='zencommand',DeviceGroups='|',agent='zencommand',summary='started',dedupid='monitorhost.mydomain.com|zencommand|/App/Start||0|started',manager='monitorhost.mydomain.com',DeviceClass='/Server/Linux',device='monitorhost.mydomain.com',eventClass='/App/Start',lastTime=1177074471.261,Systems='|',message='started',eventKey='',deletedTime=null,evid='0acac7ef3537b8a7fffffff':
--> 1
DEBUG:zen.Events:DELETE FROM status WHERE clearid IS NOT NULL: --> 0
C DEBUG:zen.zencommand:Received exit code: 0
DEBUG:zen.zencommand:Command: '/bin/sh -c exec
/opt/zenoss/libexec/check_temptraxe -H therm.mydomain.com -p 2 -w 78 -c 85'
D DEBUG:zen.zencommand:Output: 'Temp Ok: 5th Flr Srvr Rm = 75.4 F\n'
DEBUG:zen.zencommand:Process check_temptraxe -H therm.mydomain.com -p 2 -w
78 -c 85 stopped (0), 0.305997 elapsed
DEBUG:zen.zencommand:The result of "/opt/zenoss/libexec/check_temptraxe -H
therm.mydomain.com -p 2 -w 78 -c 85" was "Temp Ok: 5th Flr Srvr Rm = 75.4 F"
DEBUG:zen.Events:Found device=monitorhost.mydomain.com
DEBUG:zen.Events:EventClassInst=Stop
DEBUG:zen.Events:insert into status set
Location='',prodState=1000,firstTime=1177074471.433,severity=3,component='zencommand',DeviceGroups='|',agent='zencommand',summary='stopped',dedupid='monitorhost.mydomain.com|zencommand|/App/Stop||3|stopped',manager='monitorhost.mydomain.com',DeviceClass='/Server/Linux',device='monitorhost.mydomain.com',eventClass='/App/Stop',lastTime=1177074471.433,Systems='|',message='stopped',eventKey='',evid='0acac7ef3537b8a7ffffffe'
on duplicate key update
prodState=1000,summary='stopped',count=count+1,lastTime=1177074471.433: --> 1
DEBUG:zen.Events:DELETE FROM status WHERE clearid IS NOT NULL: --> 0
There are several key responses to monitor.
*Row A: *
This is the translated check line provided. Notice above that I chose to
include the $devname variable in the command template. This line shows
whether it resolves properly. In this case, the Nagios plugin will
require that the name of the device in Zenoss is resolvable from the
monitoring host. If the monitor host can not resolve the devicename,
change the command template in the perfconf to a resolvable name or an
IP address, or rename the device in zenoss. Also, in this row note the
path to your check. Since I did not explicitly enter the full path to
the check, it is searching for the plugin in the zCommandPath location.
If your zCommandPath does not match your plugin path, you can update the
zCommandPath for device by selecting the Devices pag, and editing the
zCommandPath variable on the zProperties tab. If this is the only
plugin in a different location, edit the zProperties for that individual
device or class that you wish to apply the change to.
*Row B:*
We'll return to this row later.
*Row C:*
This is the exit code provided by the command in Row A. If the exit code
is 0,1 or 2, the command executed properly and provided a return value.
(1 or 2 means that the check failed, but executed properly.)
*Row D:*
This is the response provided by the check. For the purposes of
monitoring execution of the check within Zenoss, this response is
adequate. However, in its current state, we can not generate any graphs.
Notice that there are no lines indicating that it will store the result
in the data point.
Crafting a Solution:
In order to identify a solution, lets look closer at the response
provided by the check.
Temp Ok: 5th Flr Srvr Rm = 75.4 F
Initially when I looked at this repsonse I thought everything was OK.
Upon further investigation, I learned that the response did not follow
the Nagios plugin API for performance data. The plugin currently
provides text only output. According to the Nagios Plugin API
<http://nagios.sourceforge.net/docs/3_0/pluginapi.html>, performance
data should be output after the pipe "|" symbol. If there is no
performance data, you will never store any data to generate graphs.
Step 1 - Crafting a response for a data point.
While it is possible modify the sensor device to output a more friendly
text response, I decided that I would work with the existing output, and
modify the Command Template to adjust the response, to illustrate some
of the flexibility allowed within Zenoss. As text output the existing
response is fine, but it would make crafting a performance data point
difficult. The first change I made to my command template was to remove
the spaces from my intended data point attribute. NOTE: The data point
name configured in your perfconf must match the plugin output. To
accomplish this I used a pipe to a sed statement to clean up the initial
response:
Command Template: check_temptraxe -H $devname -p 2 -w 78 -c 85 | sed 's/5th Flr Srvr Rm/5thFlrSrvrRm/'
This command will modify the initial response to remove the spaces from
the attribute name. The response will now look like:
Temp Ok: 5thFlrSrvrRm = 75.4 F
NOTE: If you do not provide the full path to the executable that you
will use to modify the output, it is important to ensure that the
utility is located within the search path of the zenoss user.
Step 2 - Adding a performance data point
The final step to modifying the plugin output is to manually add the
performance data to output. To accomplish this I used awk to capture the
output and allow me to assign each space separated word as a variable.
(So "Temp" is variable $1, "Ok:" is variable $2, etc.) I want to
manually add the attribute and variable definition as performance data
after a pipe symbol. From the command line, the command I execute is:
check_temptraxe -H <zenossdevicename> -p 2 -w 78 -c 85 | sed 's/5th Flr Srvr Rm/5thFlrSrvrRm/' | awk '{print $1" "$2"
"$3" "$4" "$5" "$6" | "$3$4$5}'
For those not familiar with awk, I am simply reprinting the variables
with a space in between for the text output side, adding the pipe symbol
and the 3rd fourth and fifth variables without spaces for performance
data. I get eliminate the "F" Fahrenheit symbol for the performance
data, because I am only interested in the relative temperature reading.
This will generate the output:
Temp Ok: 5thFlrSrvrRm = 74.8 F | 5thFlrSrvrRm=74.8
This statement works from the command line, but will not carry over if I
place it in the command template. If you notice Row B from the
zencommand output earlier, you will notice that the python process opens
a new shell and runs the command inside that separate shell. The plain
variables ($1, $2, etc.)will not get passed to this shell, but will be
replaced by the python script. In order to properly pass the variables,
you need to double your variable symbol to address the variables.
check_temptraxe -H $devname -p 2 -w 78 -c 85 | sed 's/5th Flr Srvr Rm/5thFlrSrvrRm/' | awk '{print $$1" "$$2"
"$$3" "$$4" "$$5" "$$6" | " $$3$$4$$5}'
Testing the final result:
With the Command Template configured properly. I can now set up a graph
to track the values. When I manually run zencommand, I know get the
following output.
[EMAIL PROTECTED] zenoss]$ zencommand run -d therm.mydomain.com -v10
DEBUG:zen.zencommand:Fetching config
DEBUG:zen.zencommand:Updated configCycleInterval config to 30
DEBUG:zen.zencommand:Finished config fetch
DEBUG:zen.zencommand:running '/opt/zenoss/libexec/check_temptraxe -H
therm.mydomain.com -p 2 -w 78 -c 85 | sed \'s/5th Flr Srvr Rm/5thFlrSrvrRm/\' | awk
\'{print $1 $2 $3 $4 $5 $6 "|" $3$4$5}\''
DEBUG:zen.zencommand:cmd line: '/bin/sh -c exec /opt/zenoss/libexec/check_temptraxe
-H therm.mydomain.com -p 2 -w 78 -c 85 | sed \'s/5th Flr Srvr Rm/5thFlrSrvrRm/\' | awk
\'{print $1 $2 $3 $4 $5 $6 "|" $3$4$5}\''
DEBUG:zen.zencommand:Process check_temptraxe -H therm.mydomain.com -p 2 -w 78 -c 85
| sed 's/5th Flr Srvr Rm/5thFlrSrvrRm/' | awk '{print $1 $2 $3 $4 $5 $6 "|"
$3$4$5}' started
DEBUG:zen.Events:Found device=monitorhost.mydomain.com
DEBUG:zen.Events:EventClassInst=Start
DEBUG:zen.Events:update status set clearid = '0a82d08b3537deb4fffffff' where
device='monitorhost.mydomain.com' and component='zencommand' and eventKey='' and
(eventClass='/App/Stop' or eventClass='/App/Start'): --> 1
DEBUG:zen.Events:insert into log (evid, userName, text) select evid, "admin", "auto
cleared" from status where clearid = "0a82d08b3537deb4fffffff": --> 1
DEBUG:zen.Events:insert into history set
Location='',prodState=1000,firstTime=1177084212.582,severity=0,component='zencommand',DeviceGroups='|',agent='zencommand',summary='started',dedupid='monitorhost.mydomain.com|zencommand|/App/Start||0|started',manager='monitorhost.mydomain.com',DeviceClass='/Server/Linux',device='monitorhost.mydomain.com',eventClass='/App/Start',lastTime=1177084212.582,Systems='|',message='started',eventKey='',deletedTime=null,evid='0a82d08b3537deb4fffffff':
--> 1
DEBUG:zen.Events:DELETE FROM status WHERE clearid IS NOT NULL: --> 1
DEBUG:zen.zencommand:Received exit code: 0
DEBUG:zen.zencommand:Command: '/bin/sh -c exec /opt/zenoss/libexec/check_temptraxe
-H therm.mydomain.com -p 2 -w 78 -c 85 | sed \'s/5th Flr Srvr Rm/5thFlrSrvrRm/\' | awk
\'{print $1 $2 $3 $4 $5 $6 "|" $3$4$5}\''
DEBUG:zen.zencommand:Output:
'TempOk:5thFlrSrvrRm=73.8F|5thFlrSrvrRm=73.8\n'
DEBUG:zen.zencommand:Process check_temptraxe -H therm.mydomain.com -p 2 -w 78 -c 85
| sed 's/5th Flr Srvr Rm/5thFlrSrvrRm/' | awk '{print $1 $2 $3 $4 $5 $6 "|"
$3$4$5}' stopped (0), 0.269248 elapsed
DEBUG:zen.zencommand:The result of "/opt/zenoss/libexec/check_temptraxe -H therm.mydomain.com -p 2
-w 78 -c 85 | sed 's/5th Flr Srvr Rm/5thFlrSrvrRm/' | awk '{print $1 $2 $3 $4 $5 $6 "|"
$3$4$5}'" was "TempOk:5thFlrSrvrRm=73.8F|5thFlrSrvrRm=73.8"
* DEBUG:zen.zencommand:storing 5thFlrSrvrRm = 73.8 in:
/Devices/therm.mydomain.com/5thFlrSrvrRm_5thFlrSrvrRm
* DEBUG:zen.RRDUtil:create new rrd
/opt/zenoss/perf/Devices/therm.mydomain.com/5thFlrSrvrRm_5thFlrSrvrRm.rrd
* DEBUG:zen.zencommand:rrd save result: 73.8
DEBUG:zen.Events:Found device=monitorhost.mydomain.com
DEBUG:zen.Events:EventClassInst=Stop
DEBUG:zen.Events:insert into status set
Location='',prodState=1000,firstTime=1177084212.828,severity=3,component='zencommand',DeviceGroups='|',agent='zencommand',summary='stopped',dedupid='monitorhost.mydomain.com|zencommand|/App/Stop||3|stopped',manager='monitorhost.mydomain.com',DeviceClass='/Server/Linux',device='monitorhost.mydomain.com',eventClass='/App/Stop',lastTime=1177084212.828,Systems='|',message='stopped',eventKey='',evid='0a82d08b3537deb4ffffffe'
on duplicate key update
prodState=1000,summary='stopped',count=count+1,lastTime=1177084212.828: --> 1
DEBUG:zen.Events:DELETE FROM status WHERE clearid IS NOT NULL: --> 0
You will notice that the lines preceded with an asterisk now indicate
that the RRD database file is being created and the value is being stored.
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users