Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / other / ircu @ 55d100de

Historique | Voir | Annoter | Télécharger (2,06 ko)

1
#!/usr/bin/perl
2
#
3
# $Log$
4
# Revision 1.1  2004/01/02 18:50:00  jimmyo
5
# Renamed occurrances of lrrd -> munin
6
#
7
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
8
# Import of LRRD CVS tree after renaming to Munin
9
#
10
# Revision 1.3  2003/12/18 19:02:36  jimmyo
11
# Typo
12
#
13
# Revision 1.2  2003/12/18 17:14:24  jimmyo
14
# Added autoconf-support
15
#
16
# Revision 1.1  2003/11/10 18:51:50  jimmyo
17
# Initial entries
18
#
19
#%# family=manual
20
#%# capabilities=autoconf
21

    
22
my $ret = undef;
23

    
24
if (! eval "require Net::IRC;")
25
{
26
    $ret = "Net::IRC not found";
27
}
28

    
29
if ($ARGV[0] and $ARGV[0] eq "autoconf")
30
{
31
    if ($ret)
32
    {
33
	print "no ($ret)\n";
34
	exit 1;
35
    }
36
    my $irc = new Net::IRC;
37
    my $conn;
38

    
39
    $irc = new Net::IRC; $conn = $irc->newconn(Nick => 'munin', Server => '192.168.1.1');
40
    if (!$conn)
41
    {
42
	print "no (Couldn't connect to IRC server)\n";
43
	exit 1;
44
    }
45
    print "yes\n";
46
    exit 0;
47
}
48

    
49
if($ARGV[0] and $ARGV[0] eq "config") {
50
    print "host_name $ENV{FQDN}\n";
51
    print "graph_title ircd status\n";
52
    print "graph_order clients channels\n";
53
    print "graph_args -l 0\n";
54
    print "clients.label clients\n";
55
    print "clients.draw LINE2\n";
56
    print "channels.label channels\n";
57
    print "channels.draw LINE2\n";
58
    exit 0;
59
}
60

    
61
my $irc = new Net::IRC;
62
my $conn = $irc->newconn(Nick => 'munin',
63
			 Server => '192.168.1.1');
64

    
65
my %result;
66
#$conn->debug(1);
67

    
68
sub luserclient {
69
    my($self, $event) = @_;
70
    if(($event->args)[1] =~  /There are (\d+) users and (\d+) invisible/) {
71
	$result{'clients'} = $1 + $2 - 1; # don't count this script
72
    }
73
}
74

    
75
sub luserchannels {
76
    my($self, $event) = @_;
77
    if(($event->args)[1] =~  /^(\d+)/) {
78
	$result{'channels'} = $1;
79
    }
80
}
81

    
82
sub quit {
83
    my($self, $event) = @_;
84
    open(STDERR, ">/dev/null");
85
    $self->quit();
86
    print "clients.value " . $result{'clients'} . "\n";
87
    print "channels.value " . $result{'channels'} . "\n";
88
}
89

    
90
$conn->add_global_handler('endofmotd', \&quit);
91
$conn->add_global_handler('luserclient', \&luserclient);
92
$conn->add_global_handler('luserchannels', \&luserchannels);
93

    
94

    
95
while(1) {
96
    $irc->do_one_loop();
97
}		 
98

    
99
# vim:syntax=perl