apllied Jarda Benkovsky's perl clients patch

This commit is contained in:
reenoo
2001-12-11 21:20:22 +00:00
parent d0c2164625
commit 45bf2e6c41
4 changed files with 143 additions and 46 deletions
+40 -18
View File
@@ -1,20 +1,53 @@
#!/usr/local/bin/perl -w
#!/usr/bin/perl -w
use IO::Socket;
use Fcntl;
#
# This LCDproc client takes a list of machines to ping and and reports
# number of those which ping and number of those which do not and their list
#
############################################################
# Configurable part. Set it according your setup.
############################################################
# Host which runs lcdproc daemon (LCDd)
$HOST = "localhost";
# Port on which LCDd listens to requests
$PORT = "13666";
# Path to `ping' command
$PING = "ping";
# list of hosts to be ping'ed
@MACHINES = ("lcdproc.omnipotent.net",
"www.linux.org",
"www.daemonnews.org",
"127.0.0.1",
"seurat",
"rodin",
"matisse",
);
############################################################
# End of user configurable parts
############################################################
# Connect to the server...
$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "localhost",
PeerPort => "13666",
PeerAddr => $HOST,
PeerPort => $PORT,
)
|| die "Cannot connect to LCDproc port\n";
# Make sure our messages get there right away
$remote->autoflush(1);
`sleep 1`; # Give server plenty of time to notice us...
sleep (1); # Give server plenty of time to notice us...
print $remote "hello\n";
my $lcdconnect = <$remote>;
@@ -43,26 +76,15 @@ while(1)
#print "Main loop...\n";
# Handle input... (just spew it to the console)
while(defined($line = <$remote>)) {
if ( $line =~ /^success$/ ) next;
if ( $line =~ /^success$/ ) { next; }
print $line;
}
undef %down;
undef %up;
foreach $machine ("ZakaZak",
"webfoot",
"degas",
"cassat",
"miro",
"monet",
"dali",
"escher",
"seurat",
"rodin",
"matisse",
)
foreach $machine (@MACHINES)
{
`ping -c 1 $machine`;
`$PING -c 1 $machine`;
if($?) { $down{$machine} = 1; }
else { $up{$machine} = 1; }
}