Created
April 8, 2009 22:03
-
-
Save bdha/92082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[20090408-18:03:31]:[shoal]:[bda@lab]:[~/Projects/pobox/mon/mon.d]$ cat fmdump.monitor | |
#!/icg/bin/perl | |
use strict; | |
use warnings; | |
use Sys::Hostname; | |
use IPC::Run qw/run new_chunker timeout/; | |
unless ( $^O eq "solaris" ) { exit 0; } | |
my $zonename = `/usr/bin/zonename`; | |
chomp $zonename; | |
unless ( $zonename eq "global" ) { exit 0 ; } | |
my $hostname = hostname; | |
my $time = `/usr/pkg/bin/gdate -d '5 minutes ago' +'%m/%d/%y %H:%M'`; | |
chomp $time; | |
my @cmd = qw/fmdump -t/; | |
push @cmd,$time; | |
my @events; | |
eval { | |
run(\@cmd, | |
'>', new_chunker, sub { | |
my $arg = shift; | |
chomp $arg; | |
unless ( $arg =~ /TIME/ ) { | |
push @events, $arg | |
} | |
}, | |
'2>', new_chunker, sub { push @events, shift }, | |
timeout( 5 ), | |
); | |
}; | |
unless ( @events ) { exit 0; } | |
print "fmd has detected faults on $hostname as of $time\n\n"; | |
foreach my $line ( @events ) { | |
my @event = split / /,$line; | |
print "$event[0] $event[1] $event[2] http://www.sun.com/msg/$event[4]\n"; | |
} | |
exit 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment