Skip to content

Instantly share code, notes, and snippets.

@bdha
Created April 8, 2009 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdha/92082 to your computer and use it in GitHub Desktop.
Save bdha/92082 to your computer and use it in GitHub Desktop.
[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