#!/bin/bash
#PATH=/bin:/usr/bin:/sbin:/usr/local/bin
# cronjob need clear where is the path
# mysql under path /usr/local/bin
#"mysql;SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST where time>=1000 and COMMAND='locked'";
#var=$(mysql -e "SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST where time>=1000";)
var=$(mysql -e "SELECT count(*) FROM INFORMATION_SCHEMA.PROCESSLIST where time>=100";)
#mysql --execute="SELECT count(*) FROM INFORMATION_SCHEMA.PROCESSLIST where time>=1000"
#echo " Length of string = $var" 
if [[ $var -gt 0 ]]; then echo "";
echo "Subject: Mysql query is locked or out of time!" | /usr/sbin/sendmail "srinivas@glovision.co";
else
echo "Subject: Mysql query is fine!" | /usr/sbin/sendmail "srinivas@glovision.co";
fi
#curl "http://mysms.glovision.co/api/transsms.php?to=9502288833&message=ALERT:%20Glotrax%20Mysql%20is%20out of time&username=staging"
#curl "http://mysms.glovision.co/api/transsms.php?to=9912345856&message=ALERT:%20Glotrax%20Mysql%20is%20out of time&username=staging"
