[ic] email notify of process stopped

Marty Tennison interchange-users@icdevgroup.org
Tue Jun 24 16:11:01 2003


On Tue, 2003-06-24 at 11:30, Lynlinks Technologies wrote:
> Does anybody have a simple way to verify an IC process is running and if
> not, automatically be notified via email so it can be restarted?  It can be
> annoying not to know when a store is down.
> 
> Colt
> 

Here is what I do.

1) Add a new variable to variable.txt like this, and "apply changes"

IS_IC_UP	YES_IC_IS_UP	General

2) Create a page called is_ic_up.html and put this code in it.  

[either]__IS_IC_UP__[or]NO[/either]

3) Create a script to query that page.

# Note: Remember to set $homedir and $geturl or 
# hard code them in the script.
$result = `GET http://$geturl/query/is_ic_up.html`; 
chomp($result);
  if ( $result !~ /YES_IC_IS_UP/) {
    system("$homedir/interchange/bin/interchange -r -u");
  }else{
    print "Successfully retrieved is_sediva_up.html via http\n";
  }

4) Add a cron entry that calls the script every 15 minutes.
0,15,30,45 * * * * /somepath/is_ic_up.pl > /somepath/is_ic_up.log 2>&1 &

5) Sleep at night.   :)

You can periodically monitor the is_ic_up.log to check on things.  I've
been running a script similar to this (I also check the connection
between Mysql and interchange) and it seems to do the trick.  If the
server ever has to be rebooted in the middle of the night, I only suffer
a few minutes of downtime. 

You can add an email or pager routine to email and/or page you pretty
easily. 
 

-- 
Marty Tennison <marty@sediva.com>