nagios mysql check using unexpected user after upgrading from ubuntu 12.04 to 14.04

I had Icinga monitoring my network. Everything was working fine.

After upgrading from ubuntu 12.04 to 14.04, MySQL monitoring started reporting problems.

I discovered that nagios check_mysql always uses 'root' user, where it previously used the nagios user (I assume because Icinga is running as that user).

user@server0:~$ /usr/lib/nagios/plugins/check_mysql -H server1
/usr/lib/nagios/plugins/check_mysql: /usr/lib/libmysqlclient.so.18: no version information available (required by /usr/lib/nagios/plugins/check_mysql)
Access denied for user 'root'@'server0' (using password: NO)

Is that some behaviour change I missed?

Also, I assume that the missing library does not cause problems, as passing -u/-p parameters to check_mysql makes it succesfully connect.


In recent version of Debian/Ubuntu, the nagios process (and likely other daemons) runs without $HOME set. That is why check_mysql resorts to reading /proc/self/loginuid, which is wrong, it should just find out the real user id with getuid() and take that user's home directory.

Anyway, a solution is to supply -f optfile to check_mysql, eg.:

check_mysql -H 127.0.0.1 -f /var/lib/nagios/.my.cnf