Ben,

$_SERVER["PHP_SELF"] should be available from php-cli also.


Create a file called test.php with this inside:
<? echo $_SERVER["PHP_SELF"]."\n"; ?>

then run:

# php test.php

and show us the output.

Which PHP version and OS are you running?

Javier

Ben Lentz wrote:
Hello list-

Due to the length of time it takes for sms_client to page all the required recipients in the event of a trigger in my configuration, my consolidate.php cron process can take more than a minute to run.

My problem is that when an alarm is triggered, I often end up with more than one consolidate.php process running at a time, and all hell breaks loose: Multiple notifications for the same event go out, multiple processes are waiting for the sms_client to free up the modem, etc.

The engine/consolidate.php process uses the function is_process_running() from lib/api.inc.php to prevent multiple runs of consolidate.php from being executed simultaneously by cron. However, this function doesn't work... consolidate.php calls is_process_running() with (NULL,2) and in lib/api.inc.php, if $process_name isn't specified (i.e. NULL), it fails back to the $_SERVER["PHP_SELF"] variable. It looks like this variable is only available when executed from apache, and is not set when consolidate.php is run from cron... I've done some simple tests and each time the $_SERVER["PHP_SELF"] variable is empty when I run things from bash (assuming it's the same with cron).

My workaround is to modify engine/consolidate.php to be more specific about how it specifies the is_process_running() test:
--- engine/consolidate.php.orig 2006-01-05 11:45:31.581210320 -0500
+++ engine/consolidate.php      2006-01-05 11:11:27.630937992 -0500
@@ -16,7 +16,7 @@
    $i = 0;
    $date_start = time();

- if (is_process_running(NULL,2) === false) { //check if a process named as myself is already running (one instance is me) + if (is_process_running("consolidate.php",2) === false) { //check if a process named as myself is already running (one instance is me)

       detach();

Perhaps there's a more robust solution for fixing this problem (i.e. perhaps better self-> detection in lib/api.inc.php) but this works for me and properly prevents consolidate.php from running more than once. Hell is no longer breaking loose...

So long as I don't have another process running on my box with that same name ;-)


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
jffnms-users mailing list
jffnms-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jffnms-users

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Javier Szyszlican, Project Leader, JFFNMS
[EMAIL PROTECTED]

I hope JFFNMS or I were helpful to you, if you
can, please donate at http://jffnms.org/donate



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
jffnms-users mailing list
jffnms-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jffnms-users

Reply via email to