This file is indexed.

/usr/share/munin/plugins/ircu is in munin-node 1.4.6-3ubuntu3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/perl
# -*- perl -*-

=head1 NAME

ircu - Plugin to graph the number of clients, channels and servers on
an IRC network.

=head1 CONFIGURATION

No configuration.

=head1 USAGE

This plugin connects to an IRC server running on the local host.

=head1 AUTHOR

Unknown author

=head1 LICENSE

Unknown license

=head1 MAGIC MARKERS

  #%# family=manual
  #%# capabilities=autoconf

=cut

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 0;
    }
    my $irc = new Net::IRC;
    my $conn;

    $irc = new Net::IRC; $conn = $irc->newconn(Nick => 'munin-ircd', Server => 'localhost');
    if (!$conn)
    {
	print "no (Couldn't connect to IRC server)\n";
	exit 0;
    }
    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 servers\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";
    print "servers.label servers\n";
    print "servers.draw LINE2\n";
    exit 0;
}

my $irc = new Net::IRC;
my $conn = $irc->newconn(Nick => 'munin-ircd',
			 Server => 'localhost');

my %result;
#$conn->debug(0);

sub luserclient {
    my($self, $event) = @_;
    # Do we have something like an UnrealIRCD?
    if(($event->args)[1] =~  /There are (\d+) users and (\d+) invisible on (\d+) servers/) {
	$result{'clients'} = $1 + $2 - 1; # don't count this script
	$result{'servers'} = $3;
    }
    # Or maybe some freendode hyperion stuff?
    elsif(($event->args)[1] =~  /There are (\d+) listed and (\d+) unlisted users on (\d+) servers/) {
	$result{'clients'} = $1 + $2 - 1; # don't count this script
	$result{'servers'} = $3;
    }
    # Or some recent ircnet ircd?
    elsif(($event->args)[1] =~  /There are (\d+) users and \d+ services on (\d+) servers/) {
	$result{'clients'} = $1 - 1; # don't count this script
	$result{'servers'} = $2;
    }
    # Anything else goes here
    elsif(($event->args)[1] =~  /There are (\d+) users and (\d+) invisible/) {
	$result{'clients'} = $1 + $2 - 1; # don't count this script
    }
    # And here (if there are no invisible count)
    elsif(($event->args)[1] =~  /There are (\d+) users/) {
	$result{'clients'} = $1 - 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";
    print "servers.value " . $result{'servers'} . "\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