i don't see how process.monitor does anything similar to what i am
suggesting.  as far as i can tell, process.monitor is just checking to see
if processes are still alive.

i'm shooting for something along the lines of getting mon to fail over
routes, restart a dead process, put a "sorry, service is unavailable"
page on a web server, or to take some other action based on the service
you are watching.

a prime example, and what i want to do is disable a router interface when
his serial line is up, but his path to the internet is broken.  i have
monitor checking to see if i can get to 5-6 different locations on the
net.  if this fails, i'll kick off the action.alert which will in turn
will kick off a script that logs into the router, disables the interface,
and fires off an alert that internet access is down but ought to be back
up in a minute.

the action.alert will be generic in that it will pass the alert on to any
of the current alerts the same way mon does, and will handle forking off
xthe action script.

attached is an early example.

the mon.cf should look like the following:
watch internet-connectivity
    service ping
    monitor anyfping.monitor
        period wd {Sun-Sat}
            alert action.alert -a"/usr/lib/mon/action.d/router-fail.sh" -c"mail.alert" 
 [EMAIL PROTECTED]




-Tom Scanlan
OpenReach, Inc.
Network Operations
office: 732-254-0210 x-6022
cell: 732-682-3365


On Thu, 13 Dec 2001, Derek Callaway wrote:

> You may want to look into SNMP and process.monitor.
>
> --
> //Derek Callaway <[EMAIL PROTECTED]> * Programmer: CISC, LLC - S@IRC
>  char *sites[]={"http://www.freezersearch.com/index.cfm?aff=dhc";,
>  "http://www.ciscllc.com","http://www.freezemail.com",0}; /*KDR AB 249*/
>
>
> On Thu, 13 Dec 2001, Tom Scanlan wrote:
>
> > does anyone have a use for an alert that takes an action and does a normal
> > alert?  i'm working on one now, as i haven;t seen one lying around.  my
> > reasoning follows.
> >
> > in some cases, devices that we monitor can be fixed in a programatic
> > manner.  this proposed alert would take the place of mail.alert or
> > qpage.alert.  it would take an arg (-a <file>, for example) that is a
> > script to run if we are alerting on the service, and another arg (-c
> > <mail.alert>)  for the normal alert to call).
> >
> > the script may attempt to fix the failed service while the normal alert is
> > being processed.
> >
> >
> > -Tom Scanlan
> > OpenReach, Inc.
> > Network Operations
> > office: 732-254-0210 x-6022
> > cell: 732-682-3365
> >
> >
>

Attachment: router-fail.sh
Description: Bourne shell script

#!/usr/bin/perl 
use Getopt::Std;
#
# take action and then send normal alert
#
# Tom Scanlan, [EMAIL PROTECTED]
#
# $Id: action.alert,v 1.1 2001/12/13 19:04:29 tscanlan Exp $
#
#       -c      call this alert
#       -a      action this script
my $alertdir = '/usr/lib/mon/alert.d';

getopts ("s:g:h:t:c:a:uTO");

system($opt_a);

# set up alert
my $alert = $opt_c;
$alert =~ s{^.*/([^/]+)$}{$1};
$alert = "$alertdir/$alert";
my $pid = open (ALERT, "|-");
if (!defined $pid) {
    exit 1;
}
 
#
# child, the actual alert
#
if ($pid == 0) {

    my @execargs = ( $alert, 
        "-s", "$opt_s", 
        "-g", "$opt_g",
        "-h", "$opt_h",
        "-t", "$opt_t");
    my $t;
    $t = "-u" if ($opt_u);
    $t = "-T" if ($opt_T);
    $t = "-O" if ($opt_O);

    push (@execargs, $t) if ($t);
    push (@execargs, @ARGV) if (@ARGV);

    if (!exec @execargs) {
        exit 1;
    }
    exit 0;
}

while (<STDIN>) {
    print ALERT $_;
}
close (ALERT);

waitpid $pid, 0;

Reply via email to