After updating mysql on a server that is running cpanel, Nagios kept reporting that mysql is down. I double checked and the database server was running just fine, so I proceeded with a step by step analysis, the issue proved to be the following:
root@cpanel [~]# /usr/local/nagios/libexec/check_mysql /usr/local/nagios/libexec/check_mysql: error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory
I checked to see what’s with the libmysqlclient:
root@cpanel [~]# /usr/local/nagios/libexec/check_mysql /usr/local/nagios/libexec/check_mysql: error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory
This means I had to recompile the nagios-plugins to use the latest mysql libraries which I wasn’t really in the mood to do this, so I built a little bash script to bypass this issue:
#!/bin/bash #DO NOT add a blank space between -p and NRPEPASSWORD mysql_status=`/usr/bin/mysqladmin -u NRPEUSERNAME -pNRPEPASSWORD ping | /bin/cut -d " " -f 3` case $mysql_status in alive) echo "OK - $mysql_status Mysql is alive, running fine." exit 0 ;; *) echo "CRITICAL - $mysql_status Mysql is DOWN." exit 2 ;; esac
Now everything runs fine, this is how you simply check mysql status:
cristian@monitoring> /usr/local/nagios/libexec/check_nrpe -H se.rv.er.ip -c check_mysql OK - alive Mysql is alive, running fine.
Hi guy,
I just wanted to add some lines to your script to make it a little more usable in other environments.
https://gist.github.com/metalmini/629525b7c3396e6d4fd5
Hi Michael, this was not actually a proper script to check mysql status it was just a “hack” at that point in time 🙂 As you may see, it only provides 2 states, OK and whatever else is “critical” which is not always the case.
Glad to hear that you found it useful though.