Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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(10.10.1.15) master/ONLINE. Roles: writer(10.10.1.20)
db2(10.10.1.16) master/ONLINE. Roles: reader(10.10.1.30)
db3(10.10.1.17) slave/ONLINE. Roles: reader(10.10.1.31)

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
add comment

2 Answers

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
add comment

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. http://php.net/manual/en/function.ssh2-connect.php

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
add comment

Your Answer

 
discard

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.