# once an issue has been acknowledged/fixed, change the --startindex option
-# Copyright (C) 2009 Peter Palfrader <peter@palfrader.org>
+# Copyright (C) 2009,2012 Peter Palfrader <peter@palfrader.org>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
use Getopt::Long;
-my $usage = "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--timeout=<timeout>] [--startindex=<idx>] <host> <community>\n";
+my $usage = "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--timeout=<timeout>] [--startindex=<idx>] [--verbose] <host> <community>\n";
my $params;
+$params->{'verbosity'} = 0;
Getopt::Long::config('bundling');
if (!GetOptions (
'--help' => \$params->{'help'},
'--timeout=i' => \$params->{'timeout'},
'--startindex=i' => \$params->{'startindex'},
+ '-verbose' => \$params->{'verbosity'},
)) {
die ($usage);
};
my $exit = 0;
my $res = '';
-my %num = ('warn' => 0, 'error' => 0);
+my %num = ('warn' => 0, 'error' => 0, 'info' => 0, 'error-ignored' => 0, 'warn-ignored' => 0);
for my $idx (sort {$a <=> $b} keys %{$data{'severity'}}) {
my $sev = $snmp_severity{$data{'severity'}->{$idx}};
die("Unexpected severity $data{'severity'}->{$idx}\n") unless $sev;
my $sevint = $severity_int{$sev};
- if ($sevint > 0) {
+ if ($sevint > -$params->{'verbosity'}) {
my $msg = $data{'message'}->{$idx};
- next if grep {$_ eq $msg} @ignores;
+ if (grep {$_ eq $msg} @ignores) {
+ $num{$sev.'-ignored'}++;
+ next;
+ };
$exit = $sevint > $exit ? $sevint : $exit;
$data{'timestamp'}->{$idx},
$msg;
+ $num{$sev}++;
+ } else {
$num{$sev}++;
};
};
-printf "Event Log: %d warnings, %d errors\n", $num{'warn'}, $num{'error'};
+printf "Event Log: %d info, %d warnings%s, %d errors%s\n",
+ $num{'info'},
+ $num{'warn'},
+ ($num{'warn-ignored'} ? " (+$num{'warn-ignored'} ignored)" : ""),
+ $num{'error'},
+ ($num{'error-ignored'} ? " (+$num{'error-ignored'} ignored)" : "");
print $res;
exit $exit;