3 # Perl Script to Check the SystemDaemon to see if things are
10 my ($problem, $host, $port, $pagemsg);
12 $host = 'monitor.sourceforge.net';
16 my @pass1 = &check_monitor;
17 my @pass2 = &check_monitor;
19 # now run through the two and see if there are any
20 # matching results. If so we need to send a page.
22 # it was in both.. push it into $pagemsg
23 if (grep("/$_/", @pass2)) {
29 system("echo \"$pagemsg\" | mail admin-pager\@sourceforge.net -s SF-ALERT");
33 my ($sock, $bigbuf, $buf, $time, $hostname, $garbage, $service, @errormsg, @response);
35 $sock = IO::Socket::INET->new(PeerAddr => $host,
39 Type => SOCK_STREAM() );
41 # Ooops.. we weren't able to open a socket to the monitor server.
42 # something bad happened.. lets send a page and exit.
44 system('echo "Monitor Fragged!" | mail admin-pager\@sourceforge.net -s SF-ALERT');
48 # set the socket to be nonblocking.
49 fcntl($sock, F_SETFL(), fcntl($sock, F_GETFL(), 0) | O_NONBLOCK()) || die "Unable to make socket non-blocking: $!";
53 # read from the socket for 10 seconds.
54 while ($time+10 > time()) {
55 $sock->recv($buf, 2048, 0);
61 @response = split("\n", $bigbuf);
63 # lets see what we got back...
65 # uh-oh.. something failed.. let see what it was..
67 ($garbage, $service, $garbage, $hostname) = split(' ', $_);
69 # $errormsg .= "$hostname $service\n";
70 push @errormsg, "$hostname $service";