Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata
sudo nano /usr/lib/xymon/client/ext/mysql_select_check.sh
#!/bin/sh

COLUMN=mysql				# THIS IS WHERE XYMON GETS COLUMN NAME
COLOR=green				# By default, everything is OK
MSG="SELECT * FROM [TABLENAME] LIMIT 1;" # The comamnd from var

#In this test, if var = empty = RED
var="$(mysql --defaults-extra-file=/etc/xymon/.sqlpwd -e "SELECT * FROM [TABLENAME] LIMIT 1;")"
cmd="$(service mysql status)"

if [ -z "$var" ]

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/lib/xymon/client/ext/mysql_select_check.sh
sudo chmod 777 /usr/lib/xymon/client/ext/mysql_select_check.sh
sudo nano /etc/xymon/clientlaunch.d/mysql_select_check.cfg
[mysql_select_check]
	ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
	CMD $XYMONCLIENTHOME/ext/mysql_select_check.sh
	LOGFILE $XYMONCLIENTHOME/logs/mysql_select_check.log
	INTERVAL 15m

Create .sqlpwd File :

sudo nano /etc/xymon/.sqlpwd
[mysql]                     
user=[username]
password=[passwd]
/usr/lib/xymon/client/bin/xymoncmd /usr/lib/xymon/client/ext/mysql_select_check.sh
sudo chmod 600 /etc/xymon/.sqlpwd
sudo chown xymon:xymon /etc/xymon/.sqlpwd

Restart Service :

sudo service xymon-client restart

XYMon Server :

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