Bash Shell Scripting Help Needed - IPMI Monitoring
Posted: Fri May 18, 2012 11:46 pm
I have Nagios 3.3.1 installed on CentOS 5.8. I'm trying to make a shell script to use the ipmimonitoring function of freeipmi to gather Temperatures from Sun ILOM.
My script is written as below:
[root@localhost libexec]# vi ipmimonitoring.sh
#!/bin/bash
TempFile=$(mktemp)
STATUS=$(/usr/local/sbin/ipmimonitoring -u test -p test -l user -h $1 -W endianseq | grep "mb.t_amb")
echo $STATUS > TempFile
Check=$(grep "OK" TempFile)
if [ "$Check" != "" ];
then
ECHOOK="Temperature OK, Result: $STATUS"
echo $ECHOOK
exit 0
else
echo "WARNING: Temperature NOT OK, Result: $STATUS"
exit 1
fi
rm -f $TempFile
When I execute it in the command line, it works fine:
[root@localhost libexec]# ./ipmimonitoring.sh 10.20.60.12
Temperature OK, Result: 4608 | mb.t_amb | Temperature | Nominal | 28.00 | C | 'OK'
But when I execute it in Nagios, it always goes to the else condition even if it is picking up the Temperature:
define command {
command_name ipmimonitoring
command_line $USER1$/ipmimonitoring.sh $HOSTADDRESS$ }
Nagios Webpage Output is:
Current Status: WARNING for 0d 0h 56m 23s)
Status Information: WARNING: Temperature NOT OK, Result: 4608
Performance Data: mb.t_amb | Temperature | Nominal | 28.00 | C | 'OK'
Current Attempt: 3/3 (HARD state)
Last Check Time: 05-19-2012 00:36:08
Check Type: ACTIVE
I have done pre-flight check and service nagios restart but the problem keeps recurring.
Please advise if I'm doing something wrong. Thanks in advance for any help.
My script is written as below:
[root@localhost libexec]# vi ipmimonitoring.sh
#!/bin/bash
TempFile=$(mktemp)
STATUS=$(/usr/local/sbin/ipmimonitoring -u test -p test -l user -h $1 -W endianseq | grep "mb.t_amb")
echo $STATUS > TempFile
Check=$(grep "OK" TempFile)
if [ "$Check" != "" ];
then
ECHOOK="Temperature OK, Result: $STATUS"
echo $ECHOOK
exit 0
else
echo "WARNING: Temperature NOT OK, Result: $STATUS"
exit 1
fi
rm -f $TempFile
When I execute it in the command line, it works fine:
[root@localhost libexec]# ./ipmimonitoring.sh 10.20.60.12
Temperature OK, Result: 4608 | mb.t_amb | Temperature | Nominal | 28.00 | C | 'OK'
But when I execute it in Nagios, it always goes to the else condition even if it is picking up the Temperature:
define command {
command_name ipmimonitoring
command_line $USER1$/ipmimonitoring.sh $HOSTADDRESS$ }
Nagios Webpage Output is:
Current Status: WARNING for 0d 0h 56m 23s)
Status Information: WARNING: Temperature NOT OK, Result: 4608
Performance Data: mb.t_amb | Temperature | Nominal | 28.00 | C | 'OK'
Current Attempt: 3/3 (HARD state)
Last Check Time: 05-19-2012 00:36:08
Check Type: ACTIVE
I have done pre-flight check and service nagios restart but the problem keeps recurring.
Please advise if I'm doing something wrong. Thanks in advance for any help.