SNMP not sending output correctly
Posted: Tue Aug 13, 2019 1:33 pm
I am running a custom bash script on nagios 5.4.9 that sends an SNMP trap to our NNMi server. The output is not coming across correctly on one server. I use another script that sends the output across just fine. What could the difference be?
Log file and partial script below.
Thanks
Jeff
=========
RUNNING COMMAND: /usr/bin/snmptrap -v 2c -c FDSCOMMON 11.48.30.40:162 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "lp000xsesn0017" nSvcDesc s "storeops_logparser2_IWM_SHIPPABLE_RTF_test_ignore" nSvcStateID i 1 nSvcOutput s "Results=1"
[service] => storeops_logparser2_IWM_SHIPPABLE_RTF_test_ignore
[service] => storeops_logparser2_IWM_SHIPPABLE_RTF_test_ignore
=========
if [ "$LogResult" -ge "1" ];then
RESULT=$STATE_WARNING
msg_text=`sshpass -p$PASS ssh -q -o StrictHostKeyChecking=no -o ConnectTimeout=310 $USER@$HOST "$COMMAND2"`
echo "Results=$RESULT"
echo "$msg_text"
exit $RESULT
fi
=========
2nd script
=========
if [ -z "$LogResult" ];then
echo "File is empty or unreadable."
RESULT=$STATE_UNKNOWN
echo "Results=$RESULT"
exit $RESULT
else
if [ "$LogResult" -eq "0" ];then
RESULT=$STATE_OK
msg_text="DNI Health report is good."
echo "Results=$RESULT"
echo "$msg_text"
exit $RESULT
fi
if [ "$LogResult" -ge "1" ];then
RESULT=$STATE_WARNING
msg_text="DNI Health report is showing BAD."
echo "Results=$RESULT"
echo "$msg_text"
exit $RESULT
fi
fi
======================================
RUNNING COMMAND: /usr/bin/snmptrap -v 2c -c FDSCOMMON 11.48.30.40 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "esu1l278" nSvcDesc s "MFT DNI Log Health_V4" nSvcStateID i 3 nSvcOutput s "File is empty or unreadable. Results=3"
RUNNING COMMAND: /usr/bin/snmptrap -v 2c -c FDSCOMMON 11.48.30.40 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "esu1l278" nSvcDesc s "MFT DNI Log Health_V4" nSvcStateID i 3 nSvcOutput s "File is empty or unreadable. Results=3"
[service] => MFT DNI Daemon Service
[service] => MFT DNI Daemon Service
[service] => MFT DNI Daemon Service
[service] => MFT DNI Daemon Service
[service] => MFT DNI Daemon Service
[serviceoutput] => s95d2z2 DNI Daemon Service is running
[longserviceoutput] => s95d2z2 DNI Daemon Service is running
[service] => MFT DNI Daemon Service
Log file and partial script below.
Thanks
Jeff
=========
RUNNING COMMAND: /usr/bin/snmptrap -v 2c -c FDSCOMMON 11.48.30.40:162 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "lp000xsesn0017" nSvcDesc s "storeops_logparser2_IWM_SHIPPABLE_RTF_test_ignore" nSvcStateID i 1 nSvcOutput s "Results=1"
[service] => storeops_logparser2_IWM_SHIPPABLE_RTF_test_ignore
[service] => storeops_logparser2_IWM_SHIPPABLE_RTF_test_ignore
=========
if [ "$LogResult" -ge "1" ];then
RESULT=$STATE_WARNING
msg_text=`sshpass -p$PASS ssh -q -o StrictHostKeyChecking=no -o ConnectTimeout=310 $USER@$HOST "$COMMAND2"`
echo "Results=$RESULT"
echo "$msg_text"
exit $RESULT
fi
=========
2nd script
=========
if [ -z "$LogResult" ];then
echo "File is empty or unreadable."
RESULT=$STATE_UNKNOWN
echo "Results=$RESULT"
exit $RESULT
else
if [ "$LogResult" -eq "0" ];then
RESULT=$STATE_OK
msg_text="DNI Health report is good."
echo "Results=$RESULT"
echo "$msg_text"
exit $RESULT
fi
if [ "$LogResult" -ge "1" ];then
RESULT=$STATE_WARNING
msg_text="DNI Health report is showing BAD."
echo "Results=$RESULT"
echo "$msg_text"
exit $RESULT
fi
fi
======================================
RUNNING COMMAND: /usr/bin/snmptrap -v 2c -c FDSCOMMON 11.48.30.40 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "esu1l278" nSvcDesc s "MFT DNI Log Health_V4" nSvcStateID i 3 nSvcOutput s "File is empty or unreadable. Results=3"
RUNNING COMMAND: /usr/bin/snmptrap -v 2c -c FDSCOMMON 11.48.30.40 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "esu1l278" nSvcDesc s "MFT DNI Log Health_V4" nSvcStateID i 3 nSvcOutput s "File is empty or unreadable. Results=3"
[service] => MFT DNI Daemon Service
[service] => MFT DNI Daemon Service
[service] => MFT DNI Daemon Service
[service] => MFT DNI Daemon Service
[service] => MFT DNI Daemon Service
[serviceoutput] => s95d2z2 DNI Daemon Service is running
[longserviceoutput] => s95d2z2 DNI Daemon Service is running
[service] => MFT DNI Daemon Service