As you are putting the data into a database already, I would simply implement the whole stuff as a rule-checker on the database, that is, a SQL query is run against the database every 5 minutes to see if there has been a syslog update from the NT machine. If there is no such update, then either your script or the NT service is not running, and the support people are to be alerted - you could also send your service an UDP ping packet to wake it up and get it to put a "I'm alive" entry into the database.
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The
$d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider
($c = $d->accept())->get_request(); $c->send_response( new #in the
HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
| [reply] [d/l] |
I've been playing with UDP lately... you might be able to use the alarm function, like this:
# initialize your IO::Socket etc...
$SIG{ALRM} = sub { # code here to do something interesting
# if your program isn't getting
+
# connections
}
my $minutes_to_wait = 5; # wait five minutes
my $alarm_seconds = $minutes_to_wait * 60;
alarm $alarm_seconds; # set the first alarm
while($server->recv($msg,$MAX_LEN) {
# if we're here we got something
# do some interesting stuff with the message
#reset the alarm
alarm $alarm_seconds;
}
I put the server code in place but I don't have my client code in front of me to make sure the server doesn't execute that block even though its getting connections. In theory it should work though :) and if you don't receive something for 5 minutes it will execute the sig alarm block at the top.
Hope that helps.
Chris
| [reply] [d/l] |
This looks like it is exactly what I am looking for but it looks like alarm() is not available under NT 4.0 at least.
| [reply] |