summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xparse-nagios13
1 files changed, 12 insertions, 1 deletions
diff --git a/parse-nagios b/parse-nagios
index 137d719..4834a39 100755
--- a/parse-nagios
+++ b/parse-nagios
@@ -54,6 +54,7 @@ my $info;
my $running_number;
my $ack_by;
my $comment;
+my $hosttype;
open (MAIL, $ARGV[1]) || die ("Cannot open $ARGV[1]: $!\n");
my @mail = <MAIL>;
@@ -94,6 +95,16 @@ die ("$PROGRAM_NAME - $project: No info found.\n") unless defined $info;
$type =~ tr/A-Z/a-z/;
$service = $host unless defined $service;
+if ($state =~ m/CRITICAL/) {
+ $hosttype = "$type\@4$host";
+} elsif ($state =~ m/WARNING/) {
+ $hosttype = "$type\@8$host";
+} elsif ($state =~ m/OK/) {
+ $hosttype = "$type\@9$host";
+} else {
+ $hosttype = "$type\@$host";
+}
+
my $extra = (defined $running_number) ? " (#$running_number)" : "";
#open(MAIL, "|cat") or
@@ -104,7 +115,7 @@ print MAIL "To: $BOT_ADDRESS\n";
print MAIL "Subject: Announce $project\n";
print MAIL "Precedence: junk\n";
print MAIL "\n";
-print MAIL "[$type\@$host] $service is $state$extra: $info\n";
+print MAIL "[$hosttype] $service is $state$extra: $info\n";
print MAIL "ACK by: $ack_by\n" if ($ack_by);
print MAIL "Comment: $comment\n" if ($comment);
close(MAIL);