# This program can be used to send Status update messages to the Spong Server
# from shell scripts or other external programs.
#
-# $Id: spong-status.pl,v 1.10 2003/02/26 15:07:33 sljohnson Exp $
+# $Id: spong-status.pl,v 1.11 2005/09/20 14:59:15 willamowius Exp $
use POSIX;
use Getopt::Long;
&help if defined $opt{'help'};
-#$opt{'cmd'} = 'status' if ! defined $opt{'cmd'};
#if ( $opt{'cmd'} !~ /^(status)$/) { warn "Invalid --cmd\n\n;" &help(); }
#if ( ! defined $opt{'host'} ) { warn "--host is required\n\n"; &help(); }
#if ( ! defined $opt{'service'} ) { warn "--service is required\n\n"; &help(); }
my($cmd, $host, $service, $color, $summary, $ttl) = @ARGV;
+$opt{'cmd'} = 'status' if ! defined $opt{'cmd'};
if (! $cmd && defined $opt{'cmd'}) { $cmd = $opt{'cmd'}; }
-if ( $cmd !~ m/status|event|page/ ) { warn "Invalid cmd\n\n"; &help(); }
+if ( $cmd !~ m/status|event|page/ ) { print "Invalid cmd\n\n"; &help(); }
if ( ! $host && defined $opt{'host'} ) { $host = $opt{'host'}; }
-if ( ! $host ) { warn "Host is required\n\n"; &help(); }
+if ( ! $host ) { print "Host is required\n\n"; &help(); }
if ( ! $service && defined $opt{'service'} ) { $service = $opt{'service'}; }
-if ( ! $service ) { warn "Service name is required\n\n"; &help(); }
+if ( ! $service ) { print "Service name is required\n\n"; &help(); }
if ( ! $color && defined $opt{'color'} ) { $color = $opt{'color'}; }
if ( $color !~ /red|yellow|green/ ) {
- warn "Invalid status color. Must be green, yellow, or red.\n\n";
+ print "Invalid status color. Must be green, yellow, or red.\n\n";
}
if ( ! $summary && defined $opt{'summary'} ) { $summary = $opt{'summary'}; }
-if ( ! $summary ) { warn "Summary text is required\n\n"; &help(); }
+if ( ! $summary ) { print "Summary text is required\n\n"; &help(); }
if ( ! defined $opt{'message'} && ! defined $opt{'file'} ) {
- warn "--message or --file is required\n\n"; &help(); }
+ print "--message or --file is required\n\n"; &help(); }
if ( defined $opt{'message'} && defined $opt{'file'} ) {
- warn "Only one of --message or --file can be specified\n\n"; &help(); }
+ print "Only one of --message or --file can be specified\n\n"; &help(); }
$ttl = defined $opt{'ttl'} ? $opt{'ttl'} : 0;
Where "options" are:
- --help Print this help text.
+ --help Print this help text.
--cmd status Command type being sent to Spong Server.
Defaults to 'status'.
--host name Name of the host being reported.