#!/usr/bin/perl # # $Log$ # Revision 1.1 2004/01/02 18:50:00 jimmyo # Renamed occurrances of lrrd -> munin # # Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo # Import of LRRD CVS tree after renaming to Munin # # Revision 1.3 2003/12/18 19:02:36 jimmyo # Typo # # Revision 1.2 2003/12/18 17:14:24 jimmyo # Added autoconf-support # # Revision 1.1 2003/11/10 18:51:50 jimmyo # Initial entries # #%# family=manual #%# capabilities=autoconf my $ret = undef; if (! eval "require Net::IRC;") { $ret = "Net::IRC not found"; } if ($ARGV[0] and $ARGV[0] eq "autoconf") { if ($ret) { print "no ($ret)\n"; exit 1; } my $irc = new Net::IRC; my $conn; $irc = new Net::IRC; $conn = $irc->newconn(Nick => 'munin', Server => '192.168.1.1'); if (!$conn) { print "no (Couldn't connect to IRC server)\n"; exit 1; } print "yes\n"; exit 0; } if($ARGV[0] and $ARGV[0] eq "config") { print "host_name $ENV{FQDN}\n"; print "graph_title ircd status\n"; print "graph_order clients channels\n"; print "graph_args -l 0\n"; print "clients.label clients\n"; print "clients.draw LINE2\n"; print "channels.label channels\n"; print "channels.draw LINE2\n"; exit 0; } my $irc = new Net::IRC; my $conn = $irc->newconn(Nick => 'munin', Server => '192.168.1.1'); my %result; #$conn->debug(1); sub luserclient { my($self, $event) = @_; if(($event->args)[1] =~ /There are (\d+) users and (\d+) invisible/) { $result{'clients'} = $1 + $2 - 1; # don't count this script } } sub luserchannels { my($self, $event) = @_; if(($event->args)[1] =~ /^(\d+)/) { $result{'channels'} = $1; } } sub quit { my($self, $event) = @_; open(STDERR, ">/dev/null"); $self->quit(); print "clients.value " . $result{'clients'} . "\n"; print "channels.value " . $result{'channels'} . "\n"; } $conn->add_global_handler('endofmotd', \&quit); $conn->add_global_handler('luserclient', \&luserclient); $conn->add_global_handler('luserchannels', \&luserchannels); while(1) { $irc->do_one_loop(); } # vim:syntax=perl