Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple MySQL-MMM setup with a dedicated monitoring host as described in their installation guide. I also have a separate monitoring system that is able to check status URLs so I'd like to set up some simple monitors to check for the status based on the output of this command:

[root@host ~]# mmm_control show
db1( master/ONLINE. Roles: writer(
db2( master/ONLINE. Roles: reader(
db3( slave/ONLINE. Roles: reader(

Unfortunately because this is a command in /usr/sbin and seems to need to run in root's environment I can't simply execute it from a CGI.

Can anyone suggest a simple method for remotely monitoring the status of the MMM?

share|improve this question
up vote 1 down vote accepted

For my money, sudo with NOPASSWD is exactly the right way to go, I use it often to give monitoring scripts privilege in a very fine-grained manner. Here's a line from my NRPE config file demonstrating that:

command[check_md_raid]=/usr/bin/sudo /usr/lib/nagios/plugins/check_md_raid

and the corresponding line from sudoers

nagios  ALL=(root) NOPASSWD: /usr/lib/nagios/plugins/check_md_raid

If you think it's overkill, I'd be interested to know why, since it's about as fine-grained, well-debugged and easily-setup as anything I can think of!

share|improve this answer

Dave, You should be able to execute it from a CGI or PHP script by running a SSH command as the user that has the permissions to run the command.

The script will login as a user with the permissions, execute the command, gather the results and then you can return a status based on those results.

In PHP you can use ssh2_connect.

share|improve this answer
The problem with this is that mmm_control needs to be run as root and I don't want to SSH as root from PHP. I suppose I could add a non-privileged user to the sudoers list only giving them the ability to run "mmm_control show" with NOPASSWD but this seems like a bit of overkill. I'm still thinking there's got to be a better way. – Dave Forgac Oct 23 '10 at 18:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.