[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Program for watching running programs
> > I am running Red Hat Linux 7.2.
> > Do anybody know where can i find a script or a program that can keep
> > watching all or some running programs and send a warning email to the root
> > everytime a program stop running ?
Where I work we have little scripts to do this. They are shell scripts, but
perl is more flexible. Here's a 3-minute example:
--------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my at processes = (
'/usr/local/sbin/radiusd',
'/usr/sbin/sendmail',
);
my $res;
open F, "ps auxwww |" or die "ps: $? $!";
while (<F>) { $res .= $_ };
close F;
my $err;
foreach my $p ( at processes) {
unless ($res =~ $p) {
$err .= "Monitored process '$p' is not running\n";
}
}
if ($err) {
my $host = `hostname`;
chomp $host;
open S, "| /usr/sbin/sendmail -t";
print S <<END;
To: alerts\ at example.com
Subject: $host alert
$host: error detected
$err
END
close S;
}
Untested, use at your own risk! But in this way you can develop a script
which also, for example, looks at the output of 'df -i' and reports when
partitions get more than 90% full or use more than 90% of available inodes.
Regards,
Brian.
-----
This is the afnog mailing list, managed by Majordomo 1.94.5
To send a message to this list, e-mail afnog at afnog.org
To send a request to majordomo, e-mail majordomo at afnog.org and put
your request in the body of the message (i.e use "help" for help)
This list is maintained by owner-afnog at afnog.org