Graphing a developed plugin
Posted: Tue Sep 25, 2018 4:12 pm
Hi everybody.
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?
Ill appreciate your help
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?
Ill appreciate your help
Code: Select all
#!/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