Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Im traying to develope a nagios plugin using shell that gets Temperature and status information from a Fan Coil using SNMP oid, c. It works good. But when I click on the graph button next to the service (pnp4nagios addon for nagios) it doesnt graph anything, when I try to graph using another plugin, such as check_snmp (Comes with the official nagios plugins pack) pnp4nagios graphs it.
Is there anything bad with my code? I think the information that my plugin sets to nagios isnt enough. Maybe an integer that im missing?
#!/bin/sh
fc_return_temperature=`snmpwalk -v2c -c public $1 1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4291 /| awk '{print $4}' | bc -l | sed 's/[.].*//'` #Almacena valor obtenido de consulta SNMP, convierte en integer y sin decimales
fc_status=`snmpwalk -v2c -c public $1 1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4706 /| awk '{print $4}'` #Almacena valor obtenido de consulta SNMP y obtiene unicamente si esta encendido o apagado
fc_status_string=$(echo "${fc_status//'"'}")
if [ $fc_status_string = "on" ]; then
if ((19<=$fc_return_temperature && $fc_return_temperature<=26)); then
echo "OK - $fc_return_temperature"
exit 0
elif ((18<=$fc_return_temperature && $fc_return_temperature<=27)); then
echo "WARNING HIGH TEMP- $fc_return_temperature"
exit 1
elif ((17<=$fc_return_temperature && $fc_return_temperature<=40)); then
echo "CRITICAL HIGH TEMP - $fc_return_temperature"
exit 2
else
echo "UNKNOWN - $fc_return_temperature"
exit 3
fi
else
echo "STANDBY - $fc_return_temperature"
exit 0
fi
You do not have the required permissions to view the files attached to this post.
[quote] Nagios 3 and newer will concatenate the parts following a "|" in a) the first line output by the plugin, and b) in the second to last line, into a string it passes to whatever performance data processing it has configured. (Note that it currently does not insert additional whitespace between both, so the plugin needs to provide some to prevent the last pair of a) and the first of b) getting run together.) Please refer to the Nagios documentation for information on how to configure such processing. However, it is the responsibility of the plugin writer to ensure the performance data is in a "Nagios Plugins" format.
#!/bin/sh
fc_return_temperature=`snmpwalk -v2c -c public $1 1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4291 /| awk '{print $4}' | bc -l | sed 's/[.].*//'` #Almacena valor obtenido de consulta SNMP, convierte en integer y sin decimales
fc_status=`snmpwalk -v2c -c public $1 1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4706 /| awk '{print $4}'` #Almacena valor obtenido de consulta SNMP y obtiene unicamente si esta encendido o apagado
fc_status_string=$(echo "${fc_status//'"'}")
if [ $fc_status_string = "on" ]; then
if ((19<=$fc_return_temperature && $fc_return_temperature<=26)); then
echo "OK - $fc_return_temperature|temp=$fc_return_temperature"
exit 0
elif ((18<=$fc_return_temperature && $fc_return_temperature<=27)); then
echo "WARNING HIGH TEMP- $fc_return_temperature|temp=$fc_return_temperature"
exit 1
elif ((17<=$fc_return_temperature && $fc_return_temperature<=40)); then
echo "CRITICAL HIGH TEMP - $fc_return_temperature|temp=$fc_return_temperature"
exit 2
else
echo "UNKNOWN - $fc_return_temperature"
exit 3
fi
else
echo "STANDBY - $fc_return_temperature"
exit 0
fi
#!/bin/sh
fc_return_temperature=`snmpwalk -v2c -c public $1 1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4291 /| awk '{print $4}' | bc -l | sed 's/[.].*//'` #Almacena valor obtenido de consulta SNMP, convierte en integer y sin decimales
fc_status=`snmpwalk -v2c -c public $1 1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4706 /| awk '{print $4}'` #Almacena valor obtenido de consulta SNMP y obtiene unicamente si esta encendido o apagado
fc_status_string=$(echo "${fc_status//'"'}")
if [ $fc_status_string = "on" ]; then
if ((19<=$fc_return_temperature && $fc_return_temperature<=26)); then
echo "OK - $fc_return_temperature|temp=$fc_return_temperature"
exit 0
elif ((18<=$fc_return_temperature && $fc_return_temperature<=27)); then
echo "WARNING HIGH TEMP- $fc_return_temperature|temp=$fc_return_temperature"
exit 1
elif ((17<=$fc_return_temperature && $fc_return_temperature<=40)); then
echo "CRITICAL HIGH TEMP - $fc_return_temperature|temp=$fc_return_temperature"
exit 2
else
echo "UNKNOWN - $fc_return_temperature"
exit 3
fi
else
echo "STANDBY - $fc_return_temperature"
exit 0
fi
I followed your instructions and now pnp4nagios addon is graphing all my hosts and services.
I noticed that if I run scripts, for example check_snmp plugin, it echoes you the parameter of your OID and the extra numbers you gave me in the development guidelines: 'label'=value[UOM];[warn];[crit];[min];[max]
made the same for my plugin.
Thanks scottwilkerson for your support
You do not have the required permissions to view the files attached to this post.