Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

CentOS 6:

$XYMONHOME=/usr/lib/xymon/
yum install -y smartmontools --no-install-recommends
sudo visudo
xymon   ALL=(ALL)     NOPASSWD:ALL
cat << 'EOL' >/usr/lib/xymon/client/ext/smart.sh
#!/bin/sh

COLUMN=smart                             
COLOR=green                             
MSG="smartctl -H /dev/sd# | grep OK" # The comamnd from var

#In this test, if var = empty = RED
var="$(sudo smartctl -H /dev/sda | grep OK)"
var1="$(sudo smartctl -H /dev/sdb | grep OK)"
cmd="$(sudo smartctl -H /dev/sda ; sudo smartctl -H /dev/sdb)"

if [ -z "$var" ] || [ -z "$var1" ] 

then

COLOR=red
MSG="${MSG}
FAILED
""
"${cmd}"
"
else

MSG="${MSG}
SUCCESS
""
"${cmd}"
"
fi

# Leave the rest of script alone
# Tell Xymon about it
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0
EOL


chown xymon:xymon /usr/lib/xymon/client/ext/smart.sh
chmod 777 /usr/lib/xymon/client/ext/smart.sh
 

nano /usr/lib/xymon/client/etc/clientlaunch*cfg
[smart]
 ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
 CMD $XYMONCLIENTHOME/ext/smart.sh
 LOGFILE $XYMONCLIENTHOME/logs/smart.log
 INTERVAL 15m
/usr/lib/xymon/client/bin/xymoncmd /usr/lib/xymon/client/ext/smart.sh

/etc/init.d/xymon-client restart

 

CentOS 5:

Default $XYHOME home in CentOS 5 :

$XYMONHOME=/usr/share/xymon-client/ext
yum install -y smartmontools --no-install-recommends
sudo visudo
xymon   ALL=(ALL)     NOPASSWD:ALL
sudo nano /usr/share/xymon-client/ext/smart_disk_check.sh
#!/bin/sh

COLUMN=smart				# THIS IS WHERE XYMON GETS COLUMN NAME
COLOR=green				# By default, everything is OK
MSG="smartctl -H /dev/sd# | grep PASSED" # The comamnd from var

#In this test, if var = empty = RED
var="$(sudo smartctl -H /dev/sda | grep PASSED)"
var1="$(sudo smartctl -H /dev/sdb | grep PASSED)"
var2="$(sudo smartctl -H /dev/sdc | grep PASSED)"
var3="$(sudo smartctl -H /dev/sdd | grep PASSED)"
cmd="$(sudo smartctl -a /dev/sda ; sudo smartctl -a /dev/sdb ; sudo smartctl -a /dev/sdc ; sudo smartctl -a /dev/sdd)"

if [ -z "$var" ] || [ -z "$var1" ] || [ -z "$var2" ] || [ -z "$var3" ]

then

COLOR=red
MSG="${MSG}
FAILED
"${cmd}"
"
else

MSG="${MSG}
SUCCESS
"${cmd}"
"
fi

# Leave the rest of script alone
# Tell Xymon about it
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0
sudo chown xymon:xymon /usr/share/xymon-client/ext/smart_disk_check.sh
sudo chmod 777 /usr/share/xymon-client/ext/smart_disk_check.sh
sudo nano /usr/share/xymon-client/etc/client.d/smart_disk_check.cfg
[smart_disk_check]
	ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
	CMD $XYMONCLIENTHOME/ext/smart_disk_check.sh
	LOGFILE $XYMONCLIENTHOME/logs/smart_disk_check.log
	INTERVAL 15m
/usr/share/xymon-client/bin/xymoncmd /usr/share/xymon-client/ext/smart_disk_check.sh

Restart Service :

sudo service xymon-client restart

XYMon Server :

 sudo service xymon restart && sudo service apache2 restart
  • No labels