Update output

This commit is contained in:
root 2016-09-20 16:52:08 +02:00
parent 33b81de014
commit 535832cb8e

View File

@ -69,6 +69,8 @@ $conn->debug(1);
my $laststat = time; my $laststat = time;
my $identified_to_nickserv = 0; my $identified_to_nickserv = 0;
$::tagueule = 0;
# #
# Handler subs # Handler subs
# #
@ -78,7 +80,7 @@ sub on_connect {
my $self = shift; my $self = shift;
$identified_to_nickserv = 1; $identified_to_nickserv = 1;
print "Joining #april-monitoring...\n"; print "Joining #april-admin...\n";
# FIXME: this is broken right now. when this is re-added, it has to happen # FIXME: this is broken right now. when this is re-added, it has to happen
# before we try to join channels. # before we try to join channels.
@ -86,7 +88,7 @@ sub on_connect {
#$self->privmsg('nickserv',"identify xxx"); #$self->privmsg('nickserv',"identify xxx");
# CONFIG: channels you want us to announce to ... # CONFIG: channels you want us to announce to ...
$self->join("#april-monitoring"); $self->join("#april-admin");
#$self->join("#status"); #$self->join("#status");
} }
@ -225,6 +227,16 @@ sub on_public {
$self->privmsg([ @to ], "$nick: supported commands: ignore, unignore, ack, unack, help"); $self->privmsg([ @to ], "$nick: supported commands: ignore, unignore, ack, unack, help");
} elsif ($arg =~ /(?:hey|hi|hello|yo)(?:\.|,|\!|\s_)/i) { } elsif ($arg =~ /(?:hey|hi|hello|yo)(?:\.|,|\!|\s_)/i) {
$self->privmsg([ @to ], "Yo, $nick!"); $self->privmsg([ @to ], "Yo, $nick!");
} elsif ($arg =~ /(?:$mynick[,: ]|!)\s*ta\s*g(:?ueu|o)le/i) {
if ( $::tagueule == 0 )
{
$self->privmsg([ @to ], "$nick: ok, I'll shut up!");
$::tagueule = 1;
}
else {
$self->privmsg([ @to ], "$nick: ok, I'm back!");
$::tagueule = 0;
}
} else { } else {
# $self->privmsg([ @to ], "Yo!"); # $self->privmsg([ @to ], "Yo!");
} }
@ -331,7 +343,7 @@ sub on_notice {
print "Joining channels...\n"; print "Joining channels...\n";
# CONFIG: channels that should be joined go here. # CONFIG: channels that should be joined go here.
$self->join("#april-monitoring"); $self->join("#april-admin");
} }
} }
@ -394,10 +406,11 @@ while (1) {
if ($identified_to_nickserv) { if ($identified_to_nickserv) {
# CONFIG: change where we announce stuff here # CONFIG: change where we announce stuff here
my @channels = ('#april-monitoring'); my @channels = ('#april-admin');
while (defined (my $line = <NAGIOS>)) { while (defined (my $line = <NAGIOS>)) {
print $line; print $line;
chomp($line); chomp($line);
next if $::tagueule;
if ($line =~ /^\[\d+\] (HOST|SERVICE) NOTIFICATION: (.+)$/) { if ($line =~ /^\[\d+\] (HOST|SERVICE) NOTIFICATION: (.+)$/) {
my ($type, $msg) = ($1, $2); my ($type, $msg) = ($1, $2);
my ($who, $host, $service, $state, $how, $output); my ($who, $host, $service, $state, $how, $output);
@ -407,9 +420,6 @@ while (1) {
$renot{$host} = time(); $renot{$host} = time();
my $id = ackable($host,undef,$state,$output); my $id = ackable($host,undef,$state,$output);
$output =~ s/^\s*CRITICAL\s*//g;
$output =~ s/^\s*WARNING\s*//g;
$output =~ s/^\s*OK\s*//g;
$msg = $state_to_color->{$state} . "$id$host is $state: $output"; $msg = $state_to_color->{$state} . "$id$host is $state: $output";
} }
else { else {
@ -418,6 +428,9 @@ while (1) {
$renot{"$host:$service"} = time(); $renot{"$host:$service"} = time();
my $id = ackable($host,$service,$state,$output); my $id = ackable($host,$service,$state,$output);
$output =~ s/^\s*CRITICAL\s*:\s//gi;
$output =~ s/^\s*WARNING\s*:\s//gi;
$output =~ s/^\s*OK\s*:\s//gi;
$msg = $state_to_color->{$state} . "$id$host:$service is $state: $output"; $msg = $state_to_color->{$state} . "$id$host:$service is $state: $output";
} }
$service ||= ""; $service ||= "";