Your message dated Fri, 03 Dec 2010 15:17:06 +0000
with message-id <[email protected]>
and subject line Bug#524016: fixed in hobbit-plugins 20101203
has caused the Debian Bug report #524016,
regarding ircbot: please add feature to highlight nicks on alerts
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
524016: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524016
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: hobbit-plugins
Version: 20080705
Severity: wishlist

Hello "Christian Herzog <[email protected]>" added the following lines to
/etc/hobbit/hobbitserver.d/ircbot.cfg:

#IRC nicks that should be alerted when certain machines have a problem
ALERT_NICKS="johndoe, luckyluke"
ALERT_HOSTS="jollyjoker foobar"
ALERT_IGNORE="apt"

and the feature in /usr/lib/hobbit/server/ext/ircbot, the bot is attached
to the bugreport.

Would you mind adding/revising the changes to the next release?

Thanks,
Guerkan

--
while(!asleep()) sheep++;

#!/usr/bin/perl

# Copyright (C) 2008 Christoph Berg <[email protected]>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

use warnings;
use strict;
use Net::IRC;
use Data::Dumper;

$| = 1;

my $hosttestre = '[a-z0-9.^*()\[\]|_+-]+'; # list of chars for host/test 
patterns
my $channel = $ENV{IRC_CHANNEL} || die ("IRC_CHANNEL is not set");
my $access = $ENV{IRC_ACCESS} || ".*";

print scalar(localtime) . " Connecting to $ENV{IRC_SERVER}\n";

my $irc = new Net::IRC;
my $conn = $irc->newconn (
        Nick    => $ENV{IRC_NICK} || die ("IRC_NICK is not set"),
        Server  => $ENV{IRC_SERVER} || die ("IRC_SERVER is not set"),
        Port    => $ENV{IRC_PORT} || 6667,
        Username => $ENV{IRC_USER} || 'hobbit',
        Ircname => $ENV{IRC_IRCNAME} || 'Hobbit monitor bot',
        SSL     => $ENV{IRC_SSL} ? 1 : 0,
);

sub reply
{
        my $event = shift;
        if ($event->{to}->[0] =~ /^#/) {
                return $event->{to}->[0];
        } else {
                return $event->{nick};
        }
}

sub color
{
        my %color = (
                green => 3,
                yellow => 7,
                red => 4,
                purple => 6,
                blue => 2,
        );
        my $color = shift;
        my $text = shift;
        return "$color{$color}$text" if (exists ($color{$color}));
        return $text;
}

sub age
{
        my $age = time - shift;
        if ($age <= 60) {
                return sprintf ('%ds', $age);
        } elsif ($age <= 3600) {
                return sprintf ('%.1fm', $age / 60.0);
        } elsif ($age <= 86400) {
                return sprintf ('%.1fh', $age / 3600.0);
        } elsif ($age <= 90 * 86400) {
                return sprintf ('%.1fd', $age / 86400.0);
        } else {
                return sprintf ('%.1fmon', $age / (30 * 86400.0));
        }
}

sub on_connect
{
        my $self = shift;
        print scalar (localtime) . " Joining $channel\n";
        $self->join ($channel);
}

sub on_msg
{
        # get input
        my $conn = $_[0];
        my $event = $_[1];
        my $msg = substr ($event->{args}->[0], 0, 100);
        chomp $msg;
        $msg =~ s/[^[:print:]]/ /g;
        return unless ($msg =~ 
/^(help|hosts?|status|query|clear|green|yellow|red|purple|blue)\b/);

        # check access
        my $date = scalar localtime;
        my $from = $event->{from};
        if ($from !~ /^($access)$/io) {
                print "$date Denied access for $from ($msg)\n";
                return;
        }

        # parse stuff
        if ($msg =~ /^help\b/i) {
                $conn->notice (reply ($event),
                        "List of commands: " .
                        "hosts [HOST [TEST]], status [HOST [TEST]], COLOR, 
help");

        } elsif ($msg =~ /^hosts?(?:\s+($hosttestre)(?:\s+($hosttestre))?)?/io) 
{
                my $host = $1 || '*';
                my $test = $2 || 'info';
                open F, "bb $ENV{BBDISP} 'hobbitdboard host=$host test=$test 
fields=hostname,color' |";
                my %hosts;
                while (<F>) {
                        chomp;
                        my ($hostname, $color) = split /\|/;
                        $hosts{$hostname} = $test eq 'info' ? 'clear' : $color;
                }
                close F;

                my @hosts = sort keys %hosts;
                my $nhosts = scalar @hosts;
                @hosts = @hosts[0 .. 19] if $nhosts > 20;
                my $txt = join (' ', map { color ($hosts{$_}, $_) } @hosts);
                $txt = "no hosts found" if $nhosts == 0;
                $txt .= " ... " . ($nhosts - 20) . " more" if ($nhosts > 20);
                $conn->notice (reply ($event), $txt);

        } elsif ($msg =~ /^status\s+($hosttestre)\s+($hosttestre)/io) {
                my ($host, $test) = ($1, $2);
                open F, "bb $ENV{BBDISP} 'hobbitdboard host=$host test=$test 
fields=hostname,testname,color,lastchange,logtime,disabletime,dismsg' |";
                my $ntests;
                while (<F>) {
                        next if (++$ntests > 5);
                        chomp;
                        my ($hostname, $testname, $color, $lastchange, $logtime,
                                $disabletime, $dismsg) = split /\|/;
                        $conn->notice (reply ($event),
                                "10$hostname $testname: " . color ($color, 
$color) .
                                " for " . age ($lastchange) .
                                ", reported " . age ($logtime) . " ago");
                        sleep 1;
                        if ($disabletime != 0) {
                                my $until = $disabletime == -1 ? "OK" :
                                        scalar (localtime ($disabletime));
                                my %quote = ( '\\' => '\\', n => ' ',
                                        p => '|', r => ' ', t => ' ' );
                                $dismsg =~ s/\\([\\nprt])/$quote{$1}/g;
                                $conn->notice (reply ($event),
                                        "Test disabled until $until: $dismsg");
                                sleep 1;
                        }
                }
                close F;
                if ($ntests > 5) {
                        $conn->notice (reply ($event), "... " . ($ntests - 5) . 
" more");
                }

        } elsif ($msg =~ /^status\s+($hosttestre)/io) {
                my $host = $1;
                open F, "bb $ENV{BBDISP} 'hobbitdboard host=$host 
fields=hostname,testname,color' |";
                my %test;
                while (<F>) {
                        chomp;
                        my ($hostname, $test, $color) = split /\|/;
                        next if $test =~ /^(info|trends)$/;
                        $test{$hostname}{$test} = $color;
                }
                close F;

                my $nhosts;
                for $host (sort keys %test) {
                        next if (++$nhosts > 5);
                        my $status = join (' ',
                                map { color ($test{$host}{$_}, $_) }
                                sort keys %{$test{$host}});
                        $status = "unknown" if (not scalar keys 
%{$test{$host}});
                        $conn->notice (reply ($event), "10$host: $status");
                        sleep 1;
                }
                if ($nhosts > 5) {
                        $conn->notice (reply ($event), "... " . ($nhosts - 5) . 
" more");
                }

        } elsif ($msg =~ /^status\b/io) {
                open F, "bb $ENV{BBDISP} 'hobbitdboard 
fields=hostname,testname,color' |";
                my (%host, $services, %color);
                while (<F>) {
                        chomp;
                        my ($host, $test, $color) = split /\|/;
                        next if $test =~ /^(info|trends)$/;
                        $host{$host} = 1;
                        $services++;
                        $color{$color}++;
                }
                close F;

                my $hosts = scalar keys %host;
                my $status = join ('', map { color ($_, " $color{$_} $_") } 
sort keys %color );
                $conn->notice (reply ($event),
                        "status: $hosts hosts, $services services,$status");

        } elsif ($msg =~ /^(clear|green|yellow|red|purple|blue)\b/) {
                my $color = $1;
                open F, "bb $ENV{BBDISP} 'hobbitdboard 
fields=hostname,testname,lastchange,logtime color=$color' |";
                my $services = 0;
                while (<F>) {
                        chomp;
                        my ($host, $test, $last, $logtime) = split /\|/;
                        next if $test =~ /^(info|trends)$/;
                        $services++;
                        if ($services <= 5) {
                                $conn->notice (reply ($event),
                                        "10$host $test: " .
                                        color ($color, $color) . " for " .
                                        age ($last) . ", reported " .
                                        age ($logtime) . " ago");
                                sleep 1;
                        }
                }
                close F;
                if ($services == 0) {
                        $conn->notice (reply ($event),
                                "no " . color ($color, $color) . " services");
                }
                if ($services > 5) {
                        $conn->notice (reply ($event),
                                "... " . ($services - 5) . " more");
                }

        # not mentioned in 'help' as it is pretty boring
        } elsif ($msg =~ /^query\s+($hosttestre)/i) {
                my $query = $1;
                my $ret = substr (`bb $ENV{BBDISP} 'query $query'`, 0, 100);
                chomp $ret;
                $ret =~ s/[^[:print:]]/ /g;
                $conn->notice (reply ($event), "$query: " . ($ret || "no 
result"));

        } else {
                return;
        }

        print "$date <$from> $msg\n";
        sleep 2;
}

sub on_stdin
{
        exit if eof (STDIN);
        my $line = <STDIN>;
        chomp $line;
        return unless $line =~ /^@@./;
        print "$line\n";
        my @list = split /\|/, $line;
        # 0        1                 2       3              4       5         6 
         7     8      9        10 11 12    13
        # 
@@page#2|1204300490.218654|hobbitd|tesla.df7cb.de|hobbitd|127.0.0.1|1204302290|green|yellow|1204300490||-1|linux|linux|
        # 
@@page#1|1204302889.833747|127.0.0.1|hubble.df7cb.de|bat|10.81.1.7|1204304689|red|clear|1204302889||404645|||
        if ($list[0] =~ /^...@\@page/) {
                return if ($list[7] eq $list[8]); # no change

                my $alertNicks = $ENV{ALERT_NICKS};
                my @alertHosts = split ' ', $ENV{ALERT_HOSTS};
                my @alertIgnore = split ' ', $ENV{ALERT_HOSTS};

                my $alertMsg = '';
                if (grep(/$list[3]/, @alertHosts) && !grep(/$list[4]/, 
@alertIgnore) && ($list[7] eq 'red')) {
                        $alertMsg = $alertNicks.": ";
                }

                my $msg = "$alertMsg10$list[3] $list[4] is " .
                        color ($list[7], $list[7]) .
                        " (was " . color ($list[8], $list[8]) . ")";
                if ($list[7] eq 'blue') {
                        open F, "bb $ENV{BBDISP} 'hobbitdboard host=$list[3] 
test=$list[4] fields=disabletime,dismsg' |";
                        my $ret = <F>;
                        chomp $ret;;
                        close F;
                        my ($disabletime, $dismsg) = split /\|/, $ret;
                        my $until = $disabletime == -1 ? "OK" :
                                scalar (localtime ($disabletime));
                        my %quote = ( '\\' => '\\', n => ' ',
                                p => '|', r => ' ', t => ' ' );
                        $dismsg =~ s/\\([\\nprt])/$quote{$1}/g;
                        $dismsg =~ s/ / until $until /;
                        $msg .= " $dismsg";
                }
                if ($list[7] =~ /clear|green/) {
                        $conn->privmsg ($channel, $msg);
                        # was notice
                } else {
                        $conn->privmsg ($channel, $msg);
                }
                sleep 2; # be nice
        }
}


$conn->add_global_handler('376', \&on_connect);     # global
$conn->add_handler('msg', \&on_msg);                # local
$conn->add_handler('public', \&on_msg);                # local

$irc->addfh( \*STDIN, \&on_stdin, "r" );

$irc->start;

--- End Message ---
--- Begin Message ---
Source: hobbit-plugins
Source-Version: 20101203

We believe that the bug you reported is fixed in the latest version of
hobbit-plugins, which is due to be installed in the Debian FTP archive:

hobbit-plugins_20101203.dsc
  to main/h/hobbit-plugins/hobbit-plugins_20101203.dsc
hobbit-plugins_20101203.tar.gz
  to main/h/hobbit-plugins/hobbit-plugins_20101203.tar.gz
hobbit-plugins_20101203_all.deb
  to main/h/hobbit-plugins/hobbit-plugins_20101203_all.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Axel Beckert <[email protected]> (supplier of updated hobbit-plugins package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Fri, 03 Dec 2010 15:58:44 +0100
Source: hobbit-plugins
Binary: hobbit-plugins
Architecture: source all
Version: 20101203
Distribution: experimental
Urgency: low
Maintainer: Christoph Berg <[email protected]>
Changed-By: Axel Beckert <[email protected]>
Description: 
 hobbit-plugins - plugins for the Xymon network monitor
Closes: 487331 524016 526894 605687
Changes: 
 hobbit-plugins (20101203) experimental; urgency=low
 .
   * Add myself to Uploaders.
   * apt: Overhaul "last apt update" determining
     + Split up the list of update stamp files into two groups to reduce
       the amount of "Last apt update" false positives:
       - Files where each file indicates a successful update, just not
         necessarily the newest one. Check all of them and use the newest
         of them. (Closes: #605687)
       - Files which are less exact indicators. Check them in order and
         just use the first one found as before.
     + Check mtime of /var/cache/apt/pkgcache.bin, /var/lib/apt/lists/partial
       and /var/lib/apt/lists before checking the mtime of
       /var/lib/apt/lists/lock. (Closes: #526894)
     + Add patch by Emil Larsson for not-in-repo package whitelist
       (/etc/hobbit/apt_alien_accepts) as well as a rejected packages
       blacklist (/etc/hobbit/apt_rejects). (Closes: #487331)
   * ircbot: Forward-port nick-highlighting patch by Christian Herzog from
     ISG D-PHYS, ETH Zurich (Closes: #524016)
   * ircbot: Optionally use privmsg instead of notice for green and clear
     messages (set IRC_GREEN_PRIVMSG to 1)
   * Bump Standards-Version to 3.9.1 (no changes)
   * Switch to source format "3.0 (native)"
Checksums-Sha1: 
 9fbe0468f92de90b2e1e3bf367e4f0a5518caff5 972 hobbit-plugins_20101203.dsc
 c90a00afbe155767d0237499c79cc16b586a5709 22303 hobbit-plugins_20101203.tar.gz
 d8008288638915944ded017a9f783bc1a851d6cc 27380 hobbit-plugins_20101203_all.deb
Checksums-Sha256: 
 8094e454ac77da3bf0d0854e6792062f9698d5e1ee1079fbc01f4c298a9348df 972 
hobbit-plugins_20101203.dsc
 3673a57d291bca0ac829786c9abe7fe100472f5b7454f9ee8ff5c0b9c18fd3d8 22303 
hobbit-plugins_20101203.tar.gz
 4a84a01b51038ea291293d61fa6a8f1bae1051ae5eaedf1c5c3703c2da806b55 27380 
hobbit-plugins_20101203_all.deb
Files: 
 c30f49c2bf7ec40a4dca9981ba45e742 972 net extra hobbit-plugins_20101203.dsc
 6cbf4ee597fcc625214cc8ae33df3272 22303 net extra hobbit-plugins_20101203.tar.gz
 8793645b701cd3b237eaec4f721aa4b1 27380 net extra 
hobbit-plugins_20101203_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkz5Bs4ACgkQwJ4diZWTDt7EFgCeKazC2TZgsFdsyr76NwWSBuZU
/EEAnjkHjE37Aet3lqnLwfE0gB4LZi3C
=svz0
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to