Smartmon Disk Check
Posted: Thu Dec 20, 2012 1:29 pm
Hello
I have a smartmon disk check that is working well ,It gives the required result.But the problem I am facing is the exit status.
Here is my script.I have 2 physical drives to which I am performing the test,I need to get notified when a drive fails.
though the script is executing,the exit status seems to be not working.
#!/bin/bash
ok='0'
warning='1'
critical='2'
unknown='3'
#smart='/usr/sbin/smartctl'
string1check=` sudo /usr/sbin/smartctl -H /dev/sda |grep -i PASSED`
string2check=` sudo /usr/sbin/smartctl -H /dev/sdb |grep -i PASSED`
string2catch='SMART overall-health self-assessment test result: PASSED'
if [ "$string2catch" = "$string1check" ]; then
echo 'OK : Drive 1 Good'
$status1=$ok
else
echo 'CRITICAL: Drive 1 Bad'
$status1=$critical
fi
if [ "$string2catch" = "$string2check" ]; then
echo 'OK : Drive 2 Good'
$status2=$ok
else
echo 'CRITICAL: Drive 2 Bad'
$status2=$critical
fi
exit $status1
exit $status2
Current Output :
OK : Drive 1 Good
./check_smart-test: line 15: =0: command not found
OK : Drive 2 Good
./check_smart-test: line 23: =0: command not found
Any help would be greatly appreciated.
I have a smartmon disk check that is working well ,It gives the required result.But the problem I am facing is the exit status.
Here is my script.I have 2 physical drives to which I am performing the test,I need to get notified when a drive fails.
though the script is executing,the exit status seems to be not working.
#!/bin/bash
ok='0'
warning='1'
critical='2'
unknown='3'
#smart='/usr/sbin/smartctl'
string1check=` sudo /usr/sbin/smartctl -H /dev/sda |grep -i PASSED`
string2check=` sudo /usr/sbin/smartctl -H /dev/sdb |grep -i PASSED`
string2catch='SMART overall-health self-assessment test result: PASSED'
if [ "$string2catch" = "$string1check" ]; then
echo 'OK : Drive 1 Good'
$status1=$ok
else
echo 'CRITICAL: Drive 1 Bad'
$status1=$critical
fi
if [ "$string2catch" = "$string2check" ]; then
echo 'OK : Drive 2 Good'
$status2=$ok
else
echo 'CRITICAL: Drive 2 Bad'
$status2=$critical
fi
exit $status1
exit $status2
Current Output :
OK : Drive 1 Good
./check_smart-test: line 15: =0: command not found
OK : Drive 2 Good
./check_smart-test: line 23: =0: command not found
Any help would be greatly appreciated.