Nagios check_mysql and storing password

The ‘services’ manual page is a little light on advanced service configuration. I have been poking around in the PHP code and have been unable to find an answer to my question.

I am wanting to setup a check_mysql plugin for each of my hosts that run MySQL. I added a check_mysql service through the LibreNMS UI, but I don’t want to put the password in the command line args to prevent it from being exposed in the process list. My question is simply: How do I configure the check_mysql my.cnf file and/or how do I configure services in a services.conf-type file?

We just utilise nagios service checks so this question is more for them rather than us. All our code does is pass args to the script, if it has the ability to use .cnf files then that’s outside of the scope for us.

I’ve tried submitting a bug / issue to the nagios mailing list, never got a response. I’ve tried submitting an issue to the librenms-client repository about mysql check issues. Also no response. Don’t have the time to recode it myself. It really needs to both add support for MariaDB (when used without a login), as well as needs an option to authenticate locally via unix sockets vs. username and password (as MariaDB does by default, and is more secure that storing the password in plain text).

As for the .cnf:
name it “mysql.cnf”

<?php
$mysql_user = '<username>';
$mysql_pass = '<password>';
$mysql_host = '<hostname>';
$mysql_port = '<port>';

No ending php tag

No response because no one has either the time to fix it or the need to fix it.

Yeah, I’m sure. One day I’ll find the time I might just do it myself :stuck_out_tongue: Took a stab at it once, but couldn’t get it working with unix sockets and didn’t have time to get more into it

But where do I put that file?

Edit: Got it. I made a file /etc/nagios/mysql.cnf with the contents:

[client]
user=xxx
password=yyy

And in LibreNMS I put command line args: -H localhost -f /etc/nagios/mysql.cnf

I think that’s great and it holds to the UNIX philosophy of doing one thing and doing it well. Allow Nagios plugins to do their thing. I just didn’t know if there was a wrapper around them so they could be further configured aside from command line args.