On Mon, Mar 15, 2004 at 03:37:39PM +0000, Bob Crandell wrote:
> What does your Mon alert look like?
Pretty simple. Here is the alert sans comments:
---
#!/bin/sh
if [ "$1" == "" ]; then
echo Usage: $0 service_name
echo Returns 0 if service found, 1 otherwise
echo Uses \`ps\` command
exit 1
fi
# A good regex will use ^ at least, ie "^/usr/bin/named"
A=`ps -o cmd -e |egrep -q "$1"`
exit $?
---
Here's an alert to restart a service:
----
#!/usr/bin/perl
use Getopt::Std;
getopts ("f:c:s:g:h:t:l:u");
my $file = $opt_f if defined $opt_f;
my $cmd = $opt_c || "restart";
if (-x "/etc/init.d/$file") {
system("/etc/init.d/$file $cmd");
}
----
Then you can use both in a service definition:
watch servers
service sshd
interval 10m
monitor service.monitor "^/usr/sbin/sshd"
period wd {Sun-Sat}
alertevery 1h
alert restart_svc.alert -f sshd -c restart
alert mail.alert -S "sshd is down, attempting restart" [EMAIL PROTECTED]
upalert mail.alert -S "sshd is back up" [EMAIL PROTECTED]
Cory
--
Cory Petkovsek Adapting Information
Adaptable IT Consulting Technology to Your
(858) 705-1655 Business
[EMAIL PROTECTED] www.AdaptableIT.com
_______________________________________________
EuG-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug