Restarting Nagios Using PHP

Posted by X-Ware on Server Fault See other posts from Server Fault or by X-Ware
Published on 2012-04-10T09:59:35Z Indexed on 2012/04/10 11:31 UTC
Read the original article Hit count: 147

Filed under:
|

I am making a tool that is interacting with NAGIOS where some config files should be added so a restart will be needed.

What I need to know is how to restart NAGIOS using PHP code since this tool is written in PHP .. when I try to do this using:

  shell_exec("service nagios restart");

changes do not take place but when I do this manually by the console all changes I did using the PHP script are applied ... after 2 minutes research I found that I am asking linux to execut this command while I am logged in as apache user so I changed the command to:

  shell_exec('echo "mypass" | sudo -S service nagios restart');

still having the same problem ... new config files are not read until I restart manually

any suggestions will be appreciated :)

© Server Fault or respective owner

Related posts about php

Related posts about nagios