Projet

Général

Profil

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

root / plugins / services / ircd @ 430d68ff

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

1 12fe0fce Martin Weinelt
#!/usr/bin/php
2
<?php
3
#
4
# IRCd Monitoring for Munin
5
# 
6
# by Martin Weinelt
7
#
8
# $Log$
9
#  Revision 1.0	2009/09/16 05:03:31 UTC	hexa-
10
#  Initial Release featuring 
11
# 	autoconf-support,
12
#	reading user/channels/operators count
13
#
14
#
15
#%# capabilities=autoconf
16
17
$_nick = "munin-ircd";
18
$_host = "tcp://localhost"; // change to ssl:// or tls:// for ssl-tunneled-connection, tcp:// for tcp-socket
19
$_port = 6667;
20
21
if (isset($argv['1']) && $argv['1'] == "config") {
22
23
	print "host_name ".php_uname('n')."\n";
24
25
	print "graph_title IRCd Status\n";
26
	print "graph_category Services\n";
27
	print "graph_order clients channels operators\n";
28
	print "graph_args --base 1000 -l 0\n";
29
30
	print "clients.label Clients\n";
31
	print "clients.draw LINE2\n";
32
33
	print "channels.label Channels\n";
34
	print "channels.draw LINE2\n";
35
36
	print "operators.label Operators\n";
37
	print "operators.draw LINE2\n";
38
39
	exit;
40
41
} elseif (isset($argv['1']) && $argv['1'] == "autoconf") {
42
43
	$sock = fsockopen($_host, $_port);
44
45
	if (!$sock) echo "no\n";
46
	else echo "yes\n";
47
48
	fclose($sock);
49
50
	exit;
51
52
}
53
54
55
$sock = fsockopen($_host, $_port);
56
57
if ($sock) {
58
59
	fputs($sock, "NICK ".$_nick."\n");
60
	fputs($sock, "USER munin munin localhost :munin-ircd\n");
61
62
	while ($buffer = @fgets($sock, 1024)) {
63
64
		$bits = explode(" ", trim($buffer));
65
66
		if ($bits['0'] == "PING") { fputs($sock, "PONG ".$bits['1']."\n"); }
67
68
		if (isset($argv['1']) && $argv['1'] == "debug") echo $buffer."\n";
69
70
		// RAW
71
		//  End of MOTD / MOTD missing
72
		if ($bits['1'] == "422" || $bits['1'] == "376")  {
73
74
			fputs($sock, "LUSERS\n");
75
76
		} elseif ($bits['1'] == "252") {
77
78
			// :irc.linuxlounge.net 252 munin-ircd 1 :operator(s) online
79
			print "operators.value ".$bits['3']."\n";
80
81
		} elseif ($bits['1'] == "254") {
82
83
			// :irc.linuxlounge.net 252 munin-ircd 2 :channels formed
84
			print "channels.value ".$bits['3']."\n";
85
86
		} elseif ($bits['1'] == "266") {
87
88
			// :irc.linuxlounge.net 252 munin-ircd :Current Global Users: 4  Max: 8
89
			print "clients.value ".$bits['6']."\n";
90
91
			// and disconnect
92
			fputs($sock, "QUIT :munin-ircd-monitoring\n");
93
94
		}
95
96
97
	}
98
99
}
100
101
fclose($sock);
102
103
?>