On May 5, 2008, at 5:54 PM, jpertschuk wrote:
I understand how to create an event command based on the "echo" example in the documentation. I get how to filter for an event to trigger the command. Can someone explain how I'd create a command to restart apache on a Remote server? All of the commands I'd want to trigger will need to run on remote servers and restart services like mysql, apache, smtp and some of our own custom apps. These are all Linux servers, so I'd just like to be able run (for example) /etc/ rc.d/init.d/httpd restart graceful on the remote linux box when my port check on port 80 goes down. Or I could write a script that contains the command, store it on the linux box and have zenoss execute it as myscript.sh. An example would be helpful.

The command you want to execute require root privileges. There are obviously security implications whenever you allow remote root execution, but you can secure it to a certain extent by using public key authentication.

I'd recommend running "ssh-keygen" as the zenoss user and hitting enter three times to accept the default file location and empty passphrase. You'll then be able to find your zenoss user's public key file in /home/zenoss/.ssh/id_dsa.pub or maybe id_rsa.pub depending on what type of key was created.

You can then copy the contents of this file into the /root/.ssh/ authorized_keys file on any server that you want Zenoss to execute commands on. Be sure that the permissions for the /root/.ssh directory are 700 and the permissions on the authorized_keys file are 600. Test that this works by running "ssh [EMAIL PROTECTED]" as the zenoss user on your Zenoss server. You should do this for all servers that you setup the authorized_keys file on or you won't have their host key cached when your event commands run later on.

You can now remotely execute commands as root from Zenoss to your server by putting something like the following in your event command definition.

ssh [EMAIL PROTECTED]/manageIp} '/etc/init.d/httpd graceful'
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to