0

is there any plugin or possibility to check with nagios MySQL query, which is running longer than for example 1hour? So I get alerted and can manage it?

I use this code, but I am not sure how to transfer it into nagios plugin

#!/bin/bash
trigger=20
hostname=server.name
activeQcount=`mysql -e "show full processlist;" | egrep -v "leechprotect|root|Time" | awk -v T=$trigger '{ if ( $6 > T ) print $0}' | wc -l`
if [ $activeQcount -gt 0 ]
then
echo "=====================================================================================" > /tmp/MySQLcheckquery
echo "= MySQL Query Check recognized running script longer than 60mins" >> /tmp/MySQLcheckquery
echo "=====================================================================================" >> /tmp/MySQLcheckquery
date >> /tmp/MySQLcheckquery
echo "" >> /tmp/MySQLcheckquery
mysql -e "show full processlist;" >> /tmp/MySQLcheckquery
echo "=====================================================================================">> /tmp/MySQLcheckquery
cat /tmp/MySQLMon | awk -v T=$trigger '{ if ( $6 > T ) print $0}' | \
mail -s"MySQL Query Check recognized running script longer than $trigger seconds on $hostname"  $trigger seconds on "foo@email.com" -- -r "rob$
fi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.