apllied Jarda Benkovsky's perl clients patch
This commit is contained in:
+40
-18
@@ -1,20 +1,53 @@
|
|||||||
#!/usr/local/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
use Fcntl;
|
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...
|
# Connect to the server...
|
||||||
$remote = IO::Socket::INET->new(
|
$remote = IO::Socket::INET->new(
|
||||||
Proto => "tcp",
|
Proto => "tcp",
|
||||||
PeerAddr => "localhost",
|
PeerAddr => $HOST,
|
||||||
PeerPort => "13666",
|
PeerPort => $PORT,
|
||||||
)
|
)
|
||||||
|| die "Cannot connect to LCDproc port\n";
|
|| die "Cannot connect to LCDproc port\n";
|
||||||
|
|
||||||
# Make sure our messages get there right away
|
# Make sure our messages get there right away
|
||||||
$remote->autoflush(1);
|
$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";
|
print $remote "hello\n";
|
||||||
my $lcdconnect = <$remote>;
|
my $lcdconnect = <$remote>;
|
||||||
@@ -43,26 +76,15 @@ while(1)
|
|||||||
#print "Main loop...\n";
|
#print "Main loop...\n";
|
||||||
# Handle input... (just spew it to the console)
|
# Handle input... (just spew it to the console)
|
||||||
while(defined($line = <$remote>)) {
|
while(defined($line = <$remote>)) {
|
||||||
if ( $line =~ /^success$/ ) next;
|
if ( $line =~ /^success$/ ) { next; }
|
||||||
print $line;
|
print $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
undef %down;
|
undef %down;
|
||||||
undef %up;
|
undef %up;
|
||||||
foreach $machine ("ZakaZak",
|
foreach $machine (@MACHINES)
|
||||||
"webfoot",
|
|
||||||
"degas",
|
|
||||||
"cassat",
|
|
||||||
"miro",
|
|
||||||
"monet",
|
|
||||||
"dali",
|
|
||||||
"escher",
|
|
||||||
"seurat",
|
|
||||||
"rodin",
|
|
||||||
"matisse",
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
`ping -c 1 $machine`;
|
`$PING -c 1 $machine`;
|
||||||
if($?) { $down{$machine} = 1; }
|
if($?) { $down{$machine} = 1; }
|
||||||
else { $up{$machine} = 1; }
|
else { $up{$machine} = 1; }
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-15
@@ -1,8 +1,36 @@
|
|||||||
#!/usr/local/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
#
|
||||||
|
# This client for LCDproc displays the tail of a specified file.
|
||||||
|
# It's possible to change the visible part of the file with LCDproc
|
||||||
|
# controlled keys
|
||||||
|
#
|
||||||
|
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
use Fcntl;
|
use Fcntl;
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Configurable part. Set it according your setup.
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# Host which runs lcdproc daemon (LCDd)
|
||||||
|
$HOST = "localhost";
|
||||||
|
|
||||||
|
# Port on which LCDd listens to requests
|
||||||
|
$PORT = "13666";
|
||||||
|
|
||||||
|
# These define the visible part of the file...
|
||||||
|
$top = 3; # How far from the end of the file should we start?
|
||||||
|
$lines = 3; # How many lines to display?
|
||||||
|
$left = 1; # Left/right scrolling position,
|
||||||
|
$width = 20; # and number of characters per line to show
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# End of user configurable parts
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
$slow = 1; # Should we pause after the current frame?
|
||||||
|
|
||||||
if($#ARGV < 0)
|
if($#ARGV < 0)
|
||||||
{
|
{
|
||||||
print "Usage: tail.pl file\n";
|
print "Usage: tail.pl file\n";
|
||||||
@@ -14,8 +42,8 @@ $filename = shift @ARGV;
|
|||||||
# Connect to the server...
|
# Connect to the server...
|
||||||
$remote = IO::Socket::INET->new(
|
$remote = IO::Socket::INET->new(
|
||||||
Proto => "tcp",
|
Proto => "tcp",
|
||||||
PeerAddr => "localhost",
|
PeerAddr => $HOST,
|
||||||
PeerPort => "13666",
|
PeerPort => $PORT,
|
||||||
)
|
)
|
||||||
|| die "Cannot connect to LCDproc port\n";
|
|| die "Cannot connect to LCDproc port\n";
|
||||||
|
|
||||||
@@ -34,7 +62,7 @@ fcntl($remote, F_SETFL, O_NONBLOCK);
|
|||||||
|
|
||||||
|
|
||||||
# Set up some screen widgets...
|
# Set up some screen widgets...
|
||||||
print $remote "client_set name {Tail ($filename)}\n";
|
print $remote "client_set name {Tail}\n";
|
||||||
print $remote "screen_add tail\n";
|
print $remote "screen_add tail\n";
|
||||||
print $remote "screen_set tail name {Tail $filename}\n";
|
print $remote "screen_set tail name {Tail $filename}\n";
|
||||||
print $remote "widget_add tail title title\n";
|
print $remote "widget_add tail title title\n";
|
||||||
@@ -44,13 +72,6 @@ print $remote "widget_add tail 2 string\n";
|
|||||||
print $remote "widget_add tail 3 string\n";
|
print $remote "widget_add tail 3 string\n";
|
||||||
|
|
||||||
|
|
||||||
# These define the visible part of the file...
|
|
||||||
$top = 3; # How far from the end of the file should we start?
|
|
||||||
$lines = 3; # How many lines to display?
|
|
||||||
$left = 1; # Left/right scrolling position,
|
|
||||||
$width = 20; # and number of characters per line to show
|
|
||||||
|
|
||||||
$slow = 1; # Should we pause after the current frame?
|
|
||||||
|
|
||||||
# Forever, we should do stuff...
|
# Forever, we should do stuff...
|
||||||
while(1)
|
while(1)
|
||||||
@@ -58,7 +79,7 @@ while(1)
|
|||||||
# Handle input... (spew it to the console)
|
# Handle input... (spew it to the console)
|
||||||
# Also, certain keys scroll the display
|
# Also, certain keys scroll the display
|
||||||
while(defined($input = <$remote>)) {
|
while(defined($input = <$remote>)) {
|
||||||
if ( $input =~ /^success$/ ) next;
|
if ( $input =~ /^success$/ ) { next; }
|
||||||
print $input;
|
print $input;
|
||||||
|
|
||||||
$slow = -10;
|
$slow = -10;
|
||||||
@@ -103,9 +124,9 @@ while(1)
|
|||||||
}
|
}
|
||||||
else # If the file is unreadable, show an error
|
else # If the file is unreadable, show an error
|
||||||
{
|
{
|
||||||
print $remote "widget_set tail one 1 2 {$filename}\n";
|
print $remote "widget_set tail 1 1 2 {$filename}\n";
|
||||||
print $remote "widget_set tail two 1 3 {doesn't exist.}\n";
|
print $remote "widget_set tail 2 1 3 {doesn't exist.}\n";
|
||||||
print $remote "widget_set tail three 1 4 { }\n";
|
print $remote "widget_set tail 3 1 4 { }\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# And wait a little while before we show stuff again.
|
# And wait a little while before we show stuff again.
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
#!/usr/local/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
#
|
||||||
|
# Simple client for LCDproc which controls XMMS/X11AMP MP3 player
|
||||||
|
# from the keyboard controlled by LCDproc. It can only rewind to
|
||||||
|
# previous song and skip forward to previous one.
|
||||||
#
|
#
|
||||||
# This is just a test! It's simple, cheesy, and doesn't do much
|
# This is just a test! It's simple, cheesy, and doesn't do much
|
||||||
# or even look very nice.
|
# or even look very nice.
|
||||||
@@ -11,11 +15,32 @@
|
|||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
use Fcntl;
|
use Fcntl;
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# 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 command which controls XMMS/X11AMP
|
||||||
|
$XMMS = "xmms";
|
||||||
|
|
||||||
|
# Commands to set to previous / next song
|
||||||
|
$XMMS_FORWARD = "$XMMS --fwd";
|
||||||
|
$XMMS_REWIND = "$XMMS --rew"
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# End of user configurable parts
|
||||||
|
############################################################
|
||||||
|
|
||||||
# Connect to the server...
|
# Connect to the server...
|
||||||
$remote = IO::Socket::INET->new(
|
$remote = IO::Socket::INET->new(
|
||||||
Proto => "tcp",
|
Proto => "tcp",
|
||||||
PeerAddr => "localhost",
|
PeerAddr => $HOST,
|
||||||
PeerPort => "13666",
|
PeerPort => $PORT,
|
||||||
)
|
)
|
||||||
|| die "Cannot connect to LCDproc port\n";
|
|| die "Cannot connect to LCDproc port\n";
|
||||||
|
|
||||||
@@ -55,11 +80,11 @@ while(1)
|
|||||||
$key = shift @items;
|
$key = shift @items;
|
||||||
if($key eq "E")
|
if($key eq "E")
|
||||||
{
|
{
|
||||||
system("x11amp --rew");
|
system($XMMS_REWIND);
|
||||||
}
|
}
|
||||||
if($key eq "F")
|
if($key eq "F")
|
||||||
{
|
{
|
||||||
system("x11amp --fwd");
|
system($XMMS_FORWARD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# And ignore everything else
|
# And ignore everything else
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
# Chicago: KMDW
|
# Chicago: KMDW
|
||||||
# Graz/Austria (Thalerhof) : LOWG
|
# Graz/Austria (Thalerhof) : LOWG
|
||||||
#
|
#
|
||||||
|
# More can be found at http://weather.noaa.gov
|
||||||
|
#
|
||||||
# no warranty - use at your own risc.
|
# no warranty - use at your own risc.
|
||||||
# DO NOT PLAN FLIGHTS ETC ON THIS INFORMATION!!!!
|
# DO NOT PLAN FLIGHTS ETC ON THIS INFORMATION!!!!
|
||||||
#
|
#
|
||||||
@@ -31,11 +33,39 @@
|
|||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
use Fcntl;
|
use Fcntl;
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Configurable part. Set it according your setup.
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# Host which runs lcdproc daemon (LCDd)
|
||||||
|
$HOST = "localhost";
|
||||||
|
|
||||||
|
# Port on which LCDd listens to requests
|
||||||
|
$PORT = "13666";
|
||||||
|
|
||||||
|
# URL returning weather conditions for specified station code.
|
||||||
|
# Note that $site_code gets replaced by the actual site code,
|
||||||
|
# hence the URL must be in single quotes
|
||||||
|
$URL = 'http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=$site_code';
|
||||||
|
|
||||||
|
# Delay (in seconds) between subsequent checks of metar
|
||||||
|
$DELAY = 900;
|
||||||
|
|
||||||
|
# Minimum valid size of metar response
|
||||||
|
$MIN_METAR_SIZE = 10;
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# End of user configurable parts
|
||||||
|
############################################################
|
||||||
|
|
||||||
# Get the site code.
|
# Get the site code.
|
||||||
|
|
||||||
my $site_code = shift @ARGV;
|
my $site_code = shift @ARGV;
|
||||||
|
|
||||||
die "Usage: $0 <site_code>\n" unless $site_code;
|
die "Usage: $0 <site_code>\n Learn about site codes at http://weather.noaa.gov\n" unless $site_code;
|
||||||
|
|
||||||
|
# replace the string '$site_code' in URL with actual site code
|
||||||
|
$URL =~ s/\$site_code/$site_code/;
|
||||||
|
|
||||||
# Get the modules we need.
|
# Get the modules we need.
|
||||||
|
|
||||||
@@ -46,8 +76,8 @@ use LWP::UserAgent;
|
|||||||
# Connect to the server...
|
# Connect to the server...
|
||||||
$remote = IO::Socket::INET->new(
|
$remote = IO::Socket::INET->new(
|
||||||
Proto => "tcp",
|
Proto => "tcp",
|
||||||
PeerAddr => "localhost",
|
PeerAddr => $HOST,
|
||||||
PeerPort => "13666",
|
PeerPort => $PORT,
|
||||||
)
|
)
|
||||||
|| die "Cannot connect to LCDproc port\n";
|
|| die "Cannot connect to LCDproc port\n";
|
||||||
|
|
||||||
@@ -77,8 +107,7 @@ print $remote "widget_add metar wind string\n";
|
|||||||
# set metar source
|
# set metar source
|
||||||
my $ua = new LWP::UserAgent;
|
my $ua = new LWP::UserAgent;
|
||||||
|
|
||||||
my $req = new HTTP::Request GET =>
|
my $req = new HTTP::Request GET => $URL;
|
||||||
"http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=$site_code";
|
|
||||||
|
|
||||||
# fetch weather information
|
# fetch weather information
|
||||||
while (1==1) {
|
while (1==1) {
|
||||||
@@ -105,7 +134,7 @@ while (1==1) {
|
|||||||
|
|
||||||
# Sanity check
|
# Sanity check
|
||||||
|
|
||||||
if (length($metar)<10) {
|
if (length($metar)<$MIN_METAR_SIZE) {
|
||||||
die "METAR is too short! Something went wrong.";
|
die "METAR is too short! Something went wrong.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,8 +164,8 @@ while (1==1) {
|
|||||||
next if ( $input =~ /^success$/ );
|
next if ( $input =~ /^success$/ );
|
||||||
#print $input;
|
#print $input;
|
||||||
}
|
}
|
||||||
print "Sleeping 15 minutes.\n";
|
print "Sleeping " . int ($DELAY / 60) . " minutes.\n";
|
||||||
sleep 900;
|
sleep $DELAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
close($remote);
|
close($remote);
|
||||||
|
|||||||
Reference in New Issue
Block a user