[Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi

I’ve written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I’ve tried to write a simple php script and link to it from the GUI, but it only seems to cause
the omd apache server to stop, and not restart. Any thoughts on how I can achieve running ‘omd restart apache’ or ‘omd restart sitename apache’ from the web? I’ve got the script executable from the webserver user. Here is what I’ve got now;

html.write(“Activate Changes (Restart Apache)
”)

##restart_omd.php##

<?php #$output = shell_exec('omd restart apache'); #echo "
$output
"; echo shell_exec('omd restart apache'); ?>

Thanks

Jason

Trying to do something like this results in an odd error from omd;

sudo -u www-data omd restart portaldev apache
omd: no such site: www-data

···

From: checkmk-en-bounces@lists.mathias-kettner.de checkmk-en-bounces@lists.mathias-kettner.de on behalf of Jason Humes JHumes@acs.on.ca
Sent: Thursday, March 19, 2015 10:33 AM
To: checkmk-en@lists.mathias-kettner.de
Subject: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi

I’ve written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I’ve tried to write a simple php script and link to it from the GUI, but it only seems to cause
the omd apache server to stop, and not restart. Any thoughts on how I can achieve running ‘omd restart apache’ or ‘omd restart sitename apache’ from the web? I’ve got the script executable from the webserver user. Here is what I’ve got now;

html.write(“Activate Changes (Restart Apache)
”)

##restart_omd.php##

<?php #$output = shell_exec('omd restart apache'); #echo "
$output
"; echo shell_exec('omd restart apache'); ?>

Thanks

Jason

sudo -u portaldev omd restart apache

···

Am 19.03.2015 um 16:22 schrieb Jason Humes <JHumes@acs.on.ca>:

Trying to do something like this results in an odd error from omd;

sudo -u www-data omd restart portaldev apache
omd: no such site: www-data

From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 10:33 AM
To: checkmk-en@lists.mathias-kettner.de
Subject: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi
I've written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I've tried to write a simple php script and link to it from the GUI, but it only seems to cause the omd apache server to stop, and not restart. Any thoughts on how I can achieve running 'omd restart apache' or 'omd restart sitename apache' from the web? I've got the script executable from the webserver user. Here is what I've got now;

    html.write("<a href='./restart_omd.php' target='main' >Activate Changes (Restart Apache)</a><br>")

##restart_omd.php##
<?php
#$output = shell_exec('omd restart apache');
#echo "<pre>$output</pre>";
echo shell_exec('omd restart apache');
?>

Thanks

Jason

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

Hrmmm, no such luck.

···

________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Joerg Linge <pitchfork@ederdrom.de>
Sent: Thursday, March 19, 2015 11:31 AM
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

sudo -u portaldev omd restart apache

Am 19.03.2015 um 16:22 schrieb Jason Humes <JHumes@acs.on.ca>:

Trying to do something like this results in an odd error from omd;

sudo -u www-data omd restart portaldev apache
omd: no such site: www-data

From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 10:33 AM
To: checkmk-en@lists.mathias-kettner.de
Subject: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi
I've written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I've tried to write a simple php script and link to it from the GUI, but it only seems to cause the omd apache server to stop, and not restart. Any thoughts on how I can achieve running 'omd restart apache' or 'omd restart sitename apache' from the web? I've got the script executable from the webserver user. Here is what I've got now;

    html.write("<a href='./restart_omd.php' target='main' >Activate Changes (Restart Apache)</a><br>")

##restart_omd.php##
<?php
#$output = shell_exec('omd restart apache');
#echo "<pre>$output</pre>";
echo shell_exec('omd restart apache');
?>

Thanks

Jason

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

Strange...I can't seem to figure this out...I've tried all sorts of versions of the command 'omd restart portaldev apache' with no luck. Any other thoughts on how I can achieve a reload of the apache web server when clicking on a link in multisite? I've tried adding the command to the /etc/sudoers file and tried nesting the commands in a shell script and still no luck.

Thoughts/ideas?

Thanks

Jason

···

________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:01 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hrmmm, no such luck.
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Joerg Linge <pitchfork@ederdrom.de>
Sent: Thursday, March 19, 2015 11:31 AM
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

sudo -u portaldev omd restart apache

Am 19.03.2015 um 16:22 schrieb Jason Humes <JHumes@acs.on.ca>:

Trying to do something like this results in an odd error from omd;

sudo -u www-data omd restart portaldev apache
omd: no such site: www-data

From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 10:33 AM
To: checkmk-en@lists.mathias-kettner.de
Subject: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi
I've written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I've tried to write a simple php script and link to it from the GUI, but it only seems to cause the omd apache server to stop, and not restart. Any thoughts on how I can achieve running 'omd restart apache' or 'omd restart sitename apache' from the web? I've got the script executable from the webserver user. Here is what I've got now;

    html.write("<a href='./restart_omd.php' target='main' >Activate Changes (Restart Apache)</a><br>")

##restart_omd.php##
<?php
#$output = shell_exec('omd restart apache');
#echo "<pre>$output</pre>";
echo shell_exec('omd restart apache');
?>

Thanks

Jason

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

If I do like this;

shell_exec('sudo -u portaldev /opt/omd/sites/portaldev/bin/omd restart apache');

And have these in sudoers as tests;

www-data ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=(ALL:ALL) /opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart apache
portaldev ALL=(ALL:ALL) /opt/omd/sites/portaldev/bin/omd restart apache

Then I can get the server to stop, but it seems more like a crash as it doesn't restart;

[Thu Mar 19 12:54:42.803662 2015] [mpm_prefork:notice] [pid 26024] AH00169: caught SIGTERM, shutting down

···

________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:47 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Strange...I can't seem to figure this out...I've tried all sorts of versions of the command 'omd restart portaldev apache' with no luck. Any other thoughts on how I can achieve a reload of the apache web server when clicking on a link in multisite? I've tried adding the command to the /etc/sudoers file and tried nesting the commands in a shell script and still no luck.

Thoughts/ideas?

Thanks

Jason
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:01 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hrmmm, no such luck.
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Joerg Linge <pitchfork@ederdrom.de>
Sent: Thursday, March 19, 2015 11:31 AM
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

sudo -u portaldev omd restart apache

Am 19.03.2015 um 16:22 schrieb Jason Humes <JHumes@acs.on.ca>:

Trying to do something like this results in an odd error from omd;

sudo -u www-data omd restart portaldev apache
omd: no such site: www-data

From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 10:33 AM
To: checkmk-en@lists.mathias-kettner.de
Subject: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi
I've written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I've tried to write a simple php script and link to it from the GUI, but it only seems to cause the omd apache server to stop, and not restart. Any thoughts on how I can achieve running 'omd restart apache' or 'omd restart sitename apache' from the web? I've got the script executable from the webserver user. Here is what I've got now;

    html.write("<a href='./restart_omd.php' target='main' >Activate Changes (Restart Apache)</a><br>")

##restart_omd.php##
<?php
#$output = shell_exec('omd restart apache');
#echo "<pre>$output</pre>";
echo shell_exec('omd restart apache');
?>

Thanks

Jason

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

Thinking this issue through further, it looks like when the web server stops, the script is actually working, but it is not able to continue with the 'restart' process as the web server has stopped, and thus the script seems to not continue to run...does this sound about right? If you run omd restart apache from CLI it is not really a 'restart' so much as a 'stop' and then a 'start'. Is there perhaps another command I can run to get the site apache to re-read/reload the web files? Perhaps like an init.d/apache2 restart, would that be the same as restarting the omd site specific apache? I ask because the actual apache2 has a 'restart' and a 'reload' command.

Thanks

Jason

···

________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:57 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

If I do like this;

shell_exec('sudo -u portaldev /opt/omd/sites/portaldev/bin/omd restart apache');

And have these in sudoers as tests;

www-data ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=(ALL:ALL) /opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart apache
portaldev ALL=(ALL:ALL) /opt/omd/sites/portaldev/bin/omd restart apache

Then I can get the server to stop, but it seems more like a crash as it doesn't restart;

[Thu Mar 19 12:54:42.803662 2015] [mpm_prefork:notice] [pid 26024] AH00169: caught SIGTERM, shutting down
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:47 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Strange...I can't seem to figure this out...I've tried all sorts of versions of the command 'omd restart portaldev apache' with no luck. Any other thoughts on how I can achieve a reload of the apache web server when clicking on a link in multisite? I've tried adding the command to the /etc/sudoers file and tried nesting the commands in a shell script and still no luck.

Thoughts/ideas?

Thanks

Jason
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:01 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hrmmm, no such luck.
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Joerg Linge <pitchfork@ederdrom.de>
Sent: Thursday, March 19, 2015 11:31 AM
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

sudo -u portaldev omd restart apache

Am 19.03.2015 um 16:22 schrieb Jason Humes <JHumes@acs.on.ca>:

Trying to do something like this results in an odd error from omd;

sudo -u www-data omd restart portaldev apache
omd: no such site: www-data

From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 10:33 AM
To: checkmk-en@lists.mathias-kettner.de
Subject: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi
I've written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I've tried to write a simple php script and link to it from the GUI, but it only seems to cause the omd apache server to stop, and not restart. Any thoughts on how I can achieve running 'omd restart apache' or 'omd restart sitename apache' from the web? I've got the script executable from the webserver user. Here is what I've got now;

    html.write("<a href='./restart_omd.php' target='main' >Activate Changes (Restart Apache)</a><br>")

##restart_omd.php##
<?php
#$output = shell_exec('omd restart apache');
#echo "<pre>$output</pre>";
echo shell_exec('omd restart apache');
?>

Thanks

Jason

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

Hi Jason,

  1. “apache2 restart” is also just a stop-than-start
  2. try doing a “omd reload apache” instead of “omd restart apache” :wink:

Regards,

Marcel

···

Jason Humes JHumes@acs.on.ca schrieb am Do., 19. März 2015 um 19:41 Uhr:

Thinking this issue through further, it looks like when the web server stops, the script is actually working, but it is not able to continue with the ‘restart’ process as the web server has stopped, and thus the script seems to not continue to run…does this sound about right? If you run omd restart apache from CLI it is not really a ‘restart’ so much as a ‘stop’ and then a ‘start’. Is there perhaps another command I can run to get the site apache to re-read/reload the web files? Perhaps like an init.d/apache2 restart, would that be the same as restarting the omd site specific apache? I ask because the actual apache2 has a ‘restart’ and a ‘reload’ command.

Thanks

Jason


From: checkmk-en-bounces@lists.mathias-kettner.de checkmk-en-bounces@lists.mathias-kettner.de on behalf of Jason Humes JHumes@acs.on.ca

Sent: Thursday, March 19, 2015 12:57 PM

To: Joerg Linge

Cc: checkmk-en@lists.mathias-kettner.de

Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

If I do like this;

shell_exec(‘sudo -u portaldev /opt/omd/sites/portaldev/bin/omd restart apache’);

And have these in sudoers as tests;

www-data ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart portaldev apache

portaldev ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart portaldev apache

portaldev ALL=(ALL:ALL) /opt/omd/sites/portaldev/bin/omd restart portaldev apache

portaldev ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart apache

portaldev ALL=(ALL:ALL) /opt/omd/sites/portaldev/bin/omd restart apache

Then I can get the server to stop, but it seems more like a crash as it doesn’t restart;

[Thu Mar 19 12:54:42.803662 2015] [mpm_prefork:notice] [pid 26024] AH00169: caught SIGTERM, shutting down


From: checkmk-en-bounces@lists.mathias-kettner.de checkmk-en-bounces@lists.mathias-kettner.de on behalf of Jason Humes JHumes@acs.on.ca

Sent: Thursday, March 19, 2015 12:47 PM

To: Joerg Linge

Cc: checkmk-en@lists.mathias-kettner.de

Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Strange…I can’t seem to figure this out…I’ve tried all sorts of versions of the command ‘omd restart portaldev apache’ with no luck. Any other thoughts on how I can achieve a reload of the apache web server when clicking on a link in multisite? I’ve tried adding the command to the /etc/sudoers file and tried nesting the commands in a shell script and still no luck.

Thoughts/ideas?

Thanks

Jason


From: checkmk-en-bounces@lists.mathias-kettner.de checkmk-en-bounces@lists.mathias-kettner.de on behalf of Jason Humes JHumes@acs.on.ca

Sent: Thursday, March 19, 2015 12:01 PM

To: Joerg Linge

Cc: checkmk-en@lists.mathias-kettner.de

Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hrmmm, no such luck.


From: checkmk-en-bounces@lists.mathias-kettner.de checkmk-en-bounces@lists.mathias-kettner.de on behalf of Joerg Linge pitchfork@ederdrom.de

Sent: Thursday, March 19, 2015 11:31 AM

Cc: checkmk-en@lists.mathias-kettner.de

Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

sudo -u portaldev omd restart apache

Am 19.03.2015 um 16:22 schrieb Jason Humes JHumes@acs.on.ca:

Trying to do something like this results in an odd error from omd;

sudo -u www-data omd restart portaldev apache

omd: no such site: www-data

From: checkmk-en-bounces@lists.mathias-kettner.de checkmk-en-bounces@lists.mathias-kettner.de on behalf of Jason Humes JHumes@acs.on.ca

Sent: Thursday, March 19, 2015 10:33 AM

To: checkmk-en@lists.mathias-kettner.de

Subject: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi

I’ve written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I’ve tried to write a simple php script and link to it from the GUI, but it only seems to cause the omd apache server to stop, and not restart. Any thoughts on how I can achieve running ‘omd restart apache’ or ‘omd restart sitename apache’ from the web? I’ve got the script executable from the webserver user. Here is what I’ve got now;

html.write("<a href='./restart_omd.php' target='main' >Activate Changes (Restart Apache)</a><br>")

##restart_omd.php##

<?php

#$output = shell_exec(‘omd restart apache’);

#echo

$output
”;

echo shell_exec(‘omd restart apache’);

?>

Thanks

Jason


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

That's exactly what is happening. Your restart process is part of the httpd process tree and effectively kills itself during stop().

My workaround uses a temp directory as a place to hold trigger files. The files don't have any data or code in them, the names act as hash indexes in a server program. A small script on the webserver just needs to touch the file. The "server" in this case is a root cron job that runs every minute and performs predefined actions based on the filenames. Then it deletes the files and waits for more files to appear. Or it could be a daemon that watches the directory and acts faster than "within a minute". Add a fair amount of logging and use mk_logwatch so you know when it happened or when an undefined filename was found in the temp dir.

It's a little extra work than a simple sudoers config, but it could help any other bootstrapping issues just by adding another value to the command array/switch statement/if-else in your cron script.

-f

···

On Thu, 19 Mar 2015, Jason Humes wrote:

Thinking this issue through further, it looks like when the web server stops, the script is actually working, but it is not able to continue with the 'restart' process as the web server has stopped, and thus the script seems to not continue to run...does this sound about right? If you run omd restart apache from CLI it is not really a 'restart' so much as a 'stop' and then a 'start'. Is there perhaps another command I can run to get the site apache to re-read/reload the web files? Perhaps like an init.d/apache2 restart, would that be the same as restarting the omd site specific apache? I ask because the actual apache2 has a 'restart' and a 'reload' command.

Thanks

Jason
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:57 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

If I do like this;

shell_exec('sudo -u portaldev /opt/omd/sites/portaldev/bin/omd restart apache');

And have these in sudoers as tests;

www-data ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=(ALL:ALL) /opt/omd/sites/portaldev/bin/omd restart portaldev apache
portaldev ALL=NOPASSWD:/opt/omd/sites/portaldev/bin/omd restart apache
portaldev ALL=(ALL:ALL) /opt/omd/sites/portaldev/bin/omd restart apache

Then I can get the server to stop, but it seems more like a crash as it doesn't restart;

[Thu Mar 19 12:54:42.803662 2015] [mpm_prefork:notice] [pid 26024] AH00169: caught SIGTERM, shutting down
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:47 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Strange...I can't seem to figure this out...I've tried all sorts of versions of the command 'omd restart portaldev apache' with no luck. Any other thoughts on how I can achieve a reload of the apache web server when clicking on a link in multisite? I've tried adding the command to the /etc/sudoers file and tried nesting the commands in a shell script and still no luck.

Thoughts/ideas?

Thanks

Jason
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 12:01 PM
To: Joerg Linge
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hrmmm, no such luck.
________________________________________
From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Joerg Linge <pitchfork@ederdrom.de>
Sent: Thursday, March 19, 2015 11:31 AM
Cc: checkmk-en@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

sudo -u portaldev omd restart apache

Am 19.03.2015 um 16:22 schrieb Jason Humes <JHumes@acs.on.ca>:

Trying to do something like this results in an odd error from omd;

sudo -u www-data omd restart portaldev apache
omd: no such site: www-data

From: checkmk-en-bounces@lists.mathias-kettner.de <checkmk-en-bounces@lists.mathias-kettner.de> on behalf of Jason Humes <JHumes@acs.on.ca>
Sent: Thursday, March 19, 2015 10:33 AM
To: checkmk-en@lists.mathias-kettner.de
Subject: [Check_mk (english)] Any thoughts on how to restart OMD apache from a web link?

Hi
I've written a script/plugin for check_mk and in order for the changes it makes to work I need to restart the apache web server for the omd site in question. I've tried to write a simple php script and link to it from the GUI, but it only seems to cause the omd apache server to stop, and not restart. Any thoughts on how I can achieve running 'omd restart apache' or 'omd restart sitename apache' from the web? I've got the script executable from the webserver user. Here is what I've got now;

    html.write("<a href='./restart_omd.php' target='main' >Activate Changes (Restart Apache)</a><br>")

##restart_omd.php##
<?php
#$output = shell_exec('omd restart apache');
#echo "<pre>$output</pre>";
echo shell_exec('omd restart apache');
?>

Thanks

Jason

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

Could you nohup the restart command?

···

On 3/21/2015 2:07 PM, frank wrote:

That's exactly what is happening. Your restart process is part of the httpd process tree and effectively kills itself during stop().

My workaround uses a temp directory as a place to hold trigger files. The files don't have any data or code in them, the names act as hash indexes in a server program. A small script on the webserver just needs to touch the file. The "server" in this case is a root cron job that runs every minute and performs predefined actions based on the filenames. Then it deletes the files and waits for more files to appear. Or it could be a daemon that watches the directory and acts faster than "within a minute". Add a fair amount of logging and use mk_logwatch so you know when it happened or when an undefined filename was found in the temp dir.

It's a little extra work than a simple sudoers config, but it could help any other bootstrapping issues just by adding another value to the command array/switch statement/if-else in your cron script.

-f

On Thu, 19 Mar 2015, Jason Humes wrote:

Thinking this issue through further, it looks like when the web server stops, the script is actually working, but it is not able to continue with the 'restart' process as the web server has stopped, and thus the script seems to not continue to run...does this sound about right? If you run omd restart apache from CLI it is not really a 'restart' so much as a 'stop' and then a 'start'. Is there perhaps another command I can run to get the site apache to re-read/reload the web files? Perhaps like an init.d/apache2 restart, would that be the same as restarting the omd site specific apache? I ask because the actual apache2 has a 'restart' and a 'reload' command.

Thanks

Jason

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en