2
# taken from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=510307
3
# which were in turn taken from somewhere...
4
Index: munin-1.2.6/node/node.d/asterisk_channels.in
5
===================================================================
6
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7
+++ munin-1.2.6/node/node.d/asterisk_channels.in 2006-03-06 12:06:55.000000000 +0100
11
+# Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
13
+# This program is free software; you can redistribute it and/or
14
+# modify it under the terms of the GNU General Public License
15
+# as published by the Free Software Foundation; version 2 dated June,
18
+# This program is distributed in the hope that it will be useful,
19
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+# GNU General Public License for more details.
23
+# You should have received a copy of the GNU General Public License
24
+# along with this program; if not, write to the Free Software
25
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
+# If you improve this script please send your version to my email address
28
+# with the copyright notice upgrade with your name.
32
+# Revision 1.1 2005/10/22 21:04:01 rodo
33
+# Created by Rodolphe Quiedeville
35
+# Parameters mandatory:
41
+#%# capabilities=autoconf
46
+if (! eval "require Net::Telnet;")
48
+ $ret = "Net::Telnet not found";
51
+if ($ARGV[0] and $ARGV[0] eq "config")
53
+ print "graph_title Asterisk active channels\n";
54
+ print "graph_args --base 1000 -l 0\n";
55
+ print "graph_vlabel channels\n";
56
+ print "graph_category asterisk\n";
57
+ print "channels.draw AREA\n";
58
+ print "channels.label channels\n";
62
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
63
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
65
+my $username = $ENV{'username'};
66
+my $secret = $ENV{'secret'};
68
+my $pop = new Net::Telnet (Telnetmode => 0);
69
+$pop->open(Host => $host,
72
+## Read connection message.
73
+my $line = $pop->getline;
74
+die $line unless $line =~ /^Asterisk/;
77
+$pop->print("Action: login");
78
+$pop->print("Username: $username");
79
+$pop->print("Secret: $secret");
80
+$pop->print("Events: off");
84
+#Message: Authentication accepted
86
+## Request status of messages.
87
+$pop->print("Action: command");
88
+$pop->print("Command: show channels");
91
+while (($line = $pop->getline) and ($line !~ /END COMMAND/o))
94
+ $result = $line if $line =~ /active channel/;
97
+my $nb = (split ' ',$result)[0];
98
+$pop->print("Action: logoff");
101
+print "channels.value $nb\n";
104
Index: munin-1.2.6/node/node.d/asterisk_channelstypes.in
105
===================================================================
106
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
107
+++ munin-1.2.6/node/node.d/asterisk_channelstypes.in 2006-03-06 12:06:55.000000000 +0100
111
+# Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
113
+# This program is free software; you can redistribute it and/or
114
+# modify it under the terms of the GNU General Public License
115
+# as published by the Free Software Foundation; version 2 dated June,
118
+# This program is distributed in the hope that it will be useful,
119
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
120
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
121
+# GNU General Public License for more details.
123
+# You should have received a copy of the GNU General Public License
124
+# along with this program; if not, write to the Free Software
125
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
127
+# If you improve this script please send your version to my email address
128
+# with the copyright notice upgrade with your name.
130
+# Plugin to monitor number of active channels by type, use the
131
+# asterisk's manager API to fetch datas.
134
+# Revision 1.1 2006/03/06 12:04:01 rodo
135
+# Created by Rodolphe Quiedeville
137
+# Parameters mandatory:
143
+#%# capabilities=autoconf
148
+if (! eval "require Net::Telnet;")
150
+ $ret = "Net::Telnet not found";
153
+my @CHANNELS = exists $ENV{'channels'} ? split ' ',$ENV{'channels'} : qw(Zap IAX2 SIP);
155
+if ($ARGV[0] and $ARGV[0] eq "config")
157
+ print "graph_title Asterisk channels\n";
158
+ print "graph_args --base 1000 -l 0\n";
159
+ print "graph_vlabel channels\n";
160
+ print "graph_category asterisk\n";
161
+ foreach my $channel (@CHANNELS) {
162
+ if ($channel eq $CHANNELS[0]) {
163
+ print "$channel.draw AREA\n";
166
+ print "$channel.draw STACK\n";
168
+ print "$channel.label $channel\n";
173
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
174
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
176
+my $username = $ENV{'username'};
177
+my $secret = $ENV{'secret'};
179
+my $pop = new Net::Telnet (Telnetmode => 0);
180
+$pop->open(Host => $host,
183
+## Read connection message.
184
+my $line = $pop->getline;
185
+die $line unless $line =~ /^Asterisk/;
188
+$pop->print("Action: login");
189
+$pop->print("Username: $username");
190
+$pop->print("Secret: $secret");
191
+$pop->print("Events: off");
195
+#Message: Authentication accepted
197
+## Request status of messages.
198
+$pop->print("Action: command");
199
+$pop->print("Command: show channels");
203
+#Channel Location State Application(Data)
204
+#Zap/pseudo-198641660 s@frompstn:1 Rsrvd (None)
205
+#Zap/1-1 4@frompstn:1 Up MeetMe(5500)
211
+my ($i, $start)=(0,0);
212
+foreach my $channel (@CHANNELS) {
218
+while (($line = $pop->getline) and ($line !~ /active channels/o))
222
+ @fields = (split '/', $line);
223
+ foreach my $channel (@CHANNELS) {
224
+ $results[$i] = $results[$i] + 1 if ($fields[0] eq $channel);
228
+ $start = 1 if ($line =~ /Channel/o);
233
+$pop->print("Action: logoff");
237
+foreach my $channel (@CHANNELS) {
238
+ print "$channel.value $results[$i]\n";
243
Index: munin-1.2.6/node/node.d/asterisk_codecs.in
244
===================================================================
245
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
246
+++ munin-1.2.6/node/node.d/asterisk_codecs.in 2008-04-15 18:03:07.000000000 +0200
250
+# Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
252
+# This program is free software; you can redistribute it and/or
253
+# modify it under the terms of the GNU General Public License
254
+# as published by the Free Software Foundation; version 2 dated June,
257
+# This program is distributed in the hope that it will be useful,
258
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
259
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
260
+# GNU General Public License for more details.
262
+# You should have received a copy of the GNU General Public License
263
+# along with this program; if not, write to the Free Software
264
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
266
+# If you improve this script please send your version to my email address
267
+# with the copyright notice upgrade with your name.
269
+# Plugin to monitor number of active channels by codec used, use the
270
+# asterisk's manager API to fecth datas.
273
+# Revision 1.1 2005/10/28 21:04:01 rodo
274
+# Created by Rodolphe Quiedeville
276
+# Parameters mandatory:
281
+# Optional parameters:
284
+# note that, if present, both required with codecsX being
285
+# the hex representation asterisk returns for the codec
288
+#%# capabilities=autoconf
293
+if (! eval "require Net::Telnet;")
295
+ $ret = "Net::Telnet not found";
298
+my @CODECS = exists $ENV{'codecs'} ? split ' ',$ENV{'codecs'} : qw(gsm ulaw alaw);
299
+my @CODECSX = exists $ENV{'codecsx'} ? split ' ',$ENV{'codecsx'} : qw(0x2 0x4 0x8);
301
+if ($ARGV[0] and $ARGV[0] eq "config")
303
+ print "graph_title Asterisk channels/codecs\n";
304
+ print "graph_args --base 1000 -l 0\n";
305
+ print "graph_vlabel channels\n";
306
+ print "graph_category asterisk\n";
307
+ foreach my $codec (@CODECS) {
308
+ if ($codec eq $CODECS[0]) {
309
+ print "$codec.draw AREA\n";
312
+ print "$codec.draw STACK\n";
314
+ print "$codec.label $codec\n";
316
+ print "other.draw STACK\n";
317
+ print "other.label other\n";
318
+ print "unknown.draw STACK\n";
319
+ print "unknown.label not set\n";
323
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
324
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
326
+my $username = $ENV{'username'};
327
+my $secret = $ENV{'secret'};
329
+my $pop = new Net::Telnet (Telnetmode => 0);
330
+$pop->open(Host => $host,
333
+## Read connection message.
334
+my $line = $pop->getline;
335
+die $line unless $line =~ /^Asterisk/;
338
+$pop->print("Action: login");
339
+$pop->print("Username: $username");
340
+$pop->print("Secret: $secret");
341
+$pop->print("Events: off");
345
+#Message: Authentication accepted
347
+## Request status of messages.
348
+$pop->print("Action: command");
349
+$pop->print("Command: sip show channels");
353
+#Peer User/ANR Call ID Seq (Tx/Rx) Format
354
+#192.168.1.135 yann 6902112b3e0 00101/00002 g729
355
+#1 active SIP channel(s)
359
+my ($i, $start, $unknown, $other)=(0,0,0,0);
360
+foreach my $codec (@CODECS) {
366
+while (($line = $pop->getline) and ($line !~ /active SIP channel/o))
368
+ #print STDERR "SIP: $line\n";
372
+ @fields = (split ' ', $line);
373
+ if ($fields[4] eq '0x0') {
377
+ foreach my $codec (@CODECSX) {
378
+ if ($fields[4] eq "$codec") {
379
+ $results[$i] = $results[$i] + 1;
387
+ print STDERR "CODEC: SIP other format $fields[4]\n";
390
+ $start = 1 if ($line =~ /Peer/o);
393
+## Request status of messages.
394
+$pop->print("Action: command");
395
+$pop->print("Command: iax2 show channels");
399
+#Channel Peer Username ID (Lo/Rem) Seq (Tx/Rx) Lag Jitter JitBuf Format
400
+#IAX2/rodolphe@rodolp 10.8.53.6 rodolphe 00003/01287 00006/00004 00000ms 0148ms 0000ms gsm
401
+#1 active IAX channel(s)
405
+while (($line = $pop->getline) and ($line !~ /active IAX channel/o))
410
+ @fields = (split ' ', $line);
411
+ if ($fields[8] eq '0x0') {
415
+ foreach my $codec (@CODECSX) {
416
+ if ($fields[8] eq "$codec") {
417
+ $results[$i] = $results[$i] + 1;
425
+ print STDERR "CODEC: IAX2 other format: $fields[8]\n";
428
+ $start = 1 if ($line =~ /Channel/o);
432
+$pop->print("Action: logoff");
436
+foreach my $codec (@CODECS) {
437
+ print "$codec.value $results[$i]\n";
440
+print "other.value $other\n";
441
+print "unknown.value $unknown\n";
444
Index: munin-1.2.6/node/node.d/asterisk_meetme.in
445
===================================================================
446
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
447
+++ munin-1.2.6/node/node.d/asterisk_meetme.in 2006-03-06 12:06:55.000000000 +0100
451
+# Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
453
+# This program is free software; you can redistribute it and/or
454
+# modify it under the terms of the GNU General Public License
455
+# as published by the Free Software Foundation; version 2 dated June,
458
+# This program is distributed in the hope that it will be useful,
459
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
460
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
461
+# GNU General Public License for more details.
463
+# You should have received a copy of the GNU General Public License
464
+# along with this program; if not, write to the Free Software
465
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
467
+# If you improve this script please send your version to my email address
468
+# with the copyright notice upgrade with your name.
470
+# Plugin to monitor number of active conferences, use the asterisk's manager
471
+# API to fecth datas.
474
+# Revision 1.1 2005/10/22 21:04:01 rodo
475
+# Created by Rodolphe Quiedeville
477
+# Parameters mandatory:
483
+#%# capabilities=autoconf
488
+if (! eval "require Net::Telnet;")
490
+ $ret = "Net::Telnet not found";
493
+if ($ARGV[0] and $ARGV[0] eq "config")
495
+ print "graph_title Asterisk actives conferences\n";
496
+ print "graph_args --base 1000 -l 0\n";
497
+ print "graph_vlabel conferences\n";
498
+ print "graph_category asterisk\n";
499
+ print "confs.draw AREA\n";
500
+ print "confs.label conferences\n";
504
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
505
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
507
+my $username = $ENV{'username'};
508
+my $secret = $ENV{'secret'};
510
+my $pop = new Net::Telnet (Telnetmode => 0);
511
+$pop->open(Host => $host,
514
+## Read connection message.
515
+my $line = $pop->getline;
516
+die $line unless $line =~ /^Asterisk/;
519
+$pop->print("Action: login");
520
+$pop->print("Username: $username");
521
+$pop->print("Secret: $secret");
522
+$pop->print("Events: off");
526
+#Message: Authentication accepted
528
+## Request status of messages.
529
+$pop->print("Action: command");
530
+$pop->print("Command: meetme");
535
+#Conf Num Parties Marked Activity Creation
536
+#5500 0001 N/A 00:00:03 Static
537
+#* Total number of MeetMe users: 1
540
+my ($confs, $start)=(0,0);
542
+while (($line = $pop->getline) and ($line !~ /Total number|No active MeetMe/o))
549
+ $start = 1 if ($line =~ /Conf\sNum\s*Parties/o);
552
+$pop->print("Action: logoff");
555
+print "confs.value $confs\n";
558
Index: munin-1.2.6/node/node.d/asterisk_meetmeusers.in
559
===================================================================
560
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
561
+++ munin-1.2.6/node/node.d/asterisk_meetmeusers.in 2008-04-11 20:57:15.000000000 +0200
565
+# Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
567
+# This program is free software; you can redistribute it and/or
568
+# modify it under the terms of the GNU General Public License
569
+# as published by the Free Software Foundation; version 2 dated June,
572
+# This program is distributed in the hope that it will be useful,
573
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
574
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
575
+# GNU General Public License for more details.
577
+# You should have received a copy of the GNU General Public License
578
+# along with this program; if not, write to the Free Software
579
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
581
+# If you improve this script please send your version to my email address
582
+# with the copyright notice upgrade with your name.
584
+# Plugin to monitor number of active users in all the conferences, use the
585
+# asterisk's manager API to fecth datas.
588
+# Revision 1.1 2005/10/22 24:04:01 rodo
589
+# Created by Rodolphe Quiedeville
591
+# Parameters mandatory:
597
+#%# capabilities=autoconf
602
+if (! eval "require Net::Telnet;")
604
+ $ret = "Net::Telnet not found";
607
+if ($ARGV[0] and $ARGV[0] eq "config")
609
+ print "graph_title Asterisk conference's users\n";
610
+ print "graph_args --base 1000 -l 0\n";
611
+ print "graph_category asterisk\n";
612
+ print "graph_vlabel users\n";
613
+ print "users.draw AREA\n";
614
+ print "users.label users\n";
615
+ print "users.info users on active conference\n";
619
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
620
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
622
+my $username = $ENV{'username'};
623
+my $secret = $ENV{'secret'};
625
+my $pop = new Net::Telnet (Telnetmode => 0);
626
+$pop->open(Host => $host,
629
+## Read connection message.
630
+my $line = $pop->getline;
631
+die $line unless $line =~ /^Asterisk/;
634
+$pop->print("Action: login");
635
+$pop->print("Username: $username");
636
+$pop->print("Secret: $secret");
637
+$pop->print("Events: off");
641
+#Message: Authentication accepted
643
+## Request status of messages.
644
+$pop->print("Action: command");
645
+$pop->print("Command: meetme");
652
+#No active MeetMe conferences.
654
+#Total number of MeetMe users: 1
656
+while (($line = $pop->getline) and ($line !~ /END COMMAND/o))
658
+ $nb = $1 if $line =~ /MeetMe users:\s(\d)$/;
661
+$pop->print("Action: logoff");
664
+print "users.value $nb\n";
667
Index: munin-1.2.6/node/node.d/asterisk_sipchannels.in
668
===================================================================
669
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
670
+++ munin-1.2.6/node/node.d/asterisk_sipchannels.in 2008-04-15 18:04:15.000000000 +0200
674
+# Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
676
+# This program is free software; you can redistribute it and/or
677
+# modify it under the terms of the GNU General Public License
678
+# as published by the Free Software Foundation; version 2 dated June,
681
+# This program is distributed in the hope that it will be useful,
682
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
683
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
684
+# GNU General Public License for more details.
686
+# You should have received a copy of the GNU General Public License
687
+# along with this program; if not, write to the Free Software
688
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
690
+# If you improve this script please send your version to my email address
691
+# with the copyright notice upgrade with your name.
693
+# Plugin to monitor number of SIP active channels by codec used, use the
694
+# asterisk's manager API to fecth datas.
697
+# Revision 1.3 2006/02/27 12:04:01 rodo
698
+# Support codec's list definition in config file
700
+# Revision 1.2 2006/02/26 12:04:01 rodo
701
+# Support Asterisk 1.2
703
+# Revision 1.1 2005/10/28 21:04:01 rodo
704
+# Created by Rodolphe Quiedeville
706
+# Parameters mandatory:
711
+# Optional parameters:
714
+# note that, if present, both required with codecsX being
715
+# the hex representation asterisk returns for the codec
718
+#%# capabilities=autoconf
723
+if (! eval "require Net::Telnet;")
725
+ $ret = "Net::Telnet not found";
728
+#Codecs g723, gsm, ulaw, alaw, g726, adpcm, slin, lpc10, g729, speex, ilbc
730
+my @CODECS = exists $ENV{'codecs'} ? split ' ',$ENV{'codecs'} : qw(gsm ulaw alaw);
731
+my @CODECSX = exists $ENV{'codecsx'} ? split ' ',$ENV{'codecsx'} : qw(0x2 0x4 0x8);
733
+if ($ARGV[0] and $ARGV[0] eq "config")
735
+ print "graph_title Asterisk sip channels/codecs\n";
736
+ print "graph_args --base 1000 -l 0\n";
737
+ print "graph_vlabel channels\n";
738
+ print "graph_category asterisk\n";
739
+ foreach my $codec (@CODECS) {
740
+ if ($codec eq $CODECS[0]) {
741
+ print "$codec.draw AREA\n";
744
+ print "$codec.draw STACK\n";
746
+ print "$codec.label $codec\n";
748
+ print "other.draw STACK\n";
749
+ print "other.label other\n";
750
+ print "unknown.draw STACK\n";
751
+ print "unknown.label not set\n";
755
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
756
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
758
+my $username = $ENV{'username'};
759
+my $secret = $ENV{'secret'};
761
+my $pop = new Net::Telnet (Telnetmode => 0);
762
+$pop->open(Host => $host,
765
+## Read connection message.
766
+my $line = $pop->getline;
767
+die $line unless $line =~ /^Asterisk/;
770
+$pop->print("Action: login");
771
+$pop->print("Username: $username");
772
+$pop->print("Secret: $secret");
773
+$pop->print("Events: off");
776
+## Request status of messages.
777
+$pop->print("Action: command");
778
+$pop->print("Command: sip show channels");
783
+#Peer User/ANR Call ID Seq (Tx/Rx) Format Hold Last Message
784
+#0 active SIP channels
786
+#74.218.176.166 (None) c24a5a230c6 00101/278584006 0x0 (nothing) No Rx: REGISTER
787
+#74.218.176.166 (None) 508c037f936 00101/07310 0x0 (nothing) No Rx: REGISTER
788
+#2 active SIP channels
793
+my ($i, $start, $unknown, $other, $fields)=(0,0,0,0,0);
794
+foreach my $codec (@CODECS) {
799
+while (($line = $pop->getline) and ($line !~ /active SIP channel/o))
803
+ my @fields = (split ' ', $line);
804
+ if ($fields[4] eq '0x0') {
809
+ foreach my $codec (@CODECSX) {
810
+ if ($fields[4] eq "$codec") {
811
+ $results[$i] = $results[$i] + 1;
819
+ print STDERR "SIP other format: $fields[4]\n";
822
+ $start = 1 if ($line =~ /Peer/o);
825
+$pop->print("Action: logoff");
829
+foreach my $codec (@CODECS) {
830
+ print "$codec.value $results[$i]\n";
833
+print "other.value $other\n";
834
+print "unknown.value $unknown\n";
835
+#print STDERR "asterisk_codecs other.value $other\n";
836
+#print STDERR "asterisk_codecs unknown.value $unknown\n";
839
Index: munin-1.2.6/node/node.d/asterisk_sippeers.in
840
===================================================================
841
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
842
+++ munin-1.2.6/node/node.d/asterisk_sippeers.in 2008-04-11 18:09:09.000000000 +0200
846
+# Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
848
+# This program is free software; you can redistribute it and/or
849
+# modify it under the terms of the GNU General Public License
850
+# as published by the Free Software Foundation; version 2 dated June,
853
+# This program is distributed in the hope that it will be useful,
854
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
855
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
856
+# GNU General Public License for more details.
858
+# You should have received a copy of the GNU General Public License
859
+# along with this program; if not, write to the Free Software
860
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
862
+# If you improve this script please send your version to my email address
863
+# with the copyright notice upgrade with your name.
865
+# Plugin to monitor number of sip peers registered, use the asterisk's manager
866
+# API to fecth datas.
869
+# Revision 1.1 2005/10/28 16:42:01 rodo
870
+# Created by Rodolphe Quiedeville
872
+# Parameters mandatory:
878
+#%# capabilities=autoconf
880
+# #################################################################################
881
+# Following example from current asterisk 1.4
883
+#Name/username Host Dyn Nat ACL Port Status
884
+#104-RANDALLBUILT/104-RAND 74.218.176.166 D 5060 Unmonitored
886
+#102-ROCKSOLID/102-ROCKSOL (Unspecified) D 0 Unmonitored
887
+#101-ROCKSOLID/101-ROCKSOL (Unspecified) D N 0 UNKNOWN
888
+#20 sip peers [Monitored: 0 online, 1 offline Unmonitored: 2 online, 17 offline]
889
+# #################################################################################
894
+if (! eval "require Net::Telnet;")
896
+ $ret = "Net::Telnet not found";
899
+if ($ARGV[0] and $ARGV[0] eq "config")
901
+ print "graph_title Asterisk sip peers\n";
902
+ print "graph_args --base 1000 -l 0\n";
903
+ print "graph_order mon moff umon umoff\n";
904
+ print "graph_vlabel peers\n";
905
+ print "graph_category asterisk\n";
906
+ #print "peers.label total\n";
907
+ print "mon.draw AREA\n";
908
+ print "mon.label monitored online\n";
909
+ print "moff.draw STACK\n";
910
+ print "moff.label monitored offline\n";
911
+ print "umon.draw STACK\n";
912
+ print "umon.label unmonitored online\n";
913
+ print "umoff.draw STACK\n";
914
+ print "umoff.label unmonitored offline\n";
918
+ #graph_info The ... describes ....
919
+ #load.info Average load for the five minutes.
923
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
924
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
926
+my $username = $ENV{'username'};
927
+my $secret = $ENV{'secret'};
929
+my $pop = new Net::Telnet (Telnetmode => 0);
930
+$pop->open(Host => $host,
933
+## Read connection message.
934
+my $line = $pop->getline;
935
+die $line unless $line =~ /^Asterisk/;
938
+$pop->print("Action: login");
939
+$pop->print("Username: $username");
940
+$pop->print("Secret: $secret");
941
+$pop->print("Events: off");
945
+#Message: Authentication accepted
947
+## Request status of messages.
948
+$pop->print("Action: command");
949
+$pop->print("Command: sip show peers");
952
+my ($peers,$monitor_online,$monitor_offline,$unmonitor_online,$unmonitor_offline)=(0,0,0,0,0);
954
+while (($line = $pop->getline) and ($line !~ /END COMMAND/o))
956
+ my @fields = split(' ', $line);
957
+ my $count = @fields;
958
+ #20 sip peers [Monitored: 0 online, 1 offline Unmonitored: 2 online, 17 offline]
959
+ if (($count > 10) and ($fields[1] eq 'sip' and $fields[2] eq 'peers')) {
960
+ $peers = $fields[0];
961
+ $monitor_online = $fields[4];
962
+ $monitor_offline = $fields[6];
963
+ $unmonitor_online = $fields[9];
964
+ $unmonitor_offline = $fields[11];
965
+ #print STDERR "$peers $monitor_online $monitor_offline $unmonitor_online $unmonitor_offline\n";
970
+$pop->print("Action: logoff");
973
+#print "peers.value $peers\n";
974
+print "mon.value $monitor_online\n";
975
+print "moff.value $monitor_offline\n";
976
+print "umon.value $unmonitor_online\n";
977
+print "umoff.value $unmonitor_offline\n";
980
Index: munin-1.2.6/node/node.d/asterisk_voicemail.in
981
===================================================================
982
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
983
+++ munin-1.2.6/node/node.d/asterisk_voicemail.in 2006-03-06 12:06:55.000000000 +0100
987
+# Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
989
+# This program is free software; you can redistribute it and/or
990
+# modify it under the terms of the GNU General Public License
991
+# as published by the Free Software Foundation; version 2 dated June,
994
+# This program is distributed in the hope that it will be useful,
995
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
996
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
997
+# GNU General Public License for more details.
999
+# You should have received a copy of the GNU General Public License
1000
+# along with this program; if not, write to the Free Software
1001
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1003
+# If you improve this script please send your version to my email address
1004
+# with the copyright notice upgrade with your name.
1006
+# Plugin to monitor number of messages in all voicemails
1009
+# Revision 1.1 2006/03/05 15:07:01 rodo
1010
+# Created by Rodolphe Quiedeville
1012
+# Parameters mandatory:
1018
+#%# capabilities=autoconf
1023
+if (! eval "require Net::Telnet;")
1025
+ $ret = "Net::Telnet not found";
1028
+if ($ARGV[0] and $ARGV[0] eq "config")
1030
+ print "graph_title Asterisk Voicemail messages\n";
1031
+ print "graph_args --base 1000 -l 0\n";
1032
+ print "graph_vlabel messages\n";
1033
+ print "graph_category asterisk\n";
1034
+ print "messages.draw AREA\n";
1035
+ print "messages.label messages\n";
1039
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
1040
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
1042
+my $username = $ENV{'username'};
1043
+my $secret = $ENV{'secret'};
1045
+my $pop = new Net::Telnet (Telnetmode => 0);
1046
+$pop->open(Host => $host,
1049
+## Read connection message.
1050
+my $line = $pop->getline;
1051
+die $line unless $line =~ /^Asterisk/;
1054
+$pop->print("Action: login");
1055
+$pop->print("Username: $username");
1056
+$pop->print("Secret: $secret");
1057
+$pop->print("Events: off");
1061
+#Message: Authentication accepted
1063
+## Request status of messages.
1064
+$pop->print("Action: command");
1065
+$pop->print("Command: show voicemail users");
1068
+#Context Mbox User Zone NewMsg
1069
+#default 1234 Example Mailbox 1
1070
+#other 1234 Company2 User 0
1072
+my ($results,$start)=(0,0);
1075
+while (($line = $pop->getline) and ($line !~ /--END/o))
1078
+ @fields = (split ' ', $line);
1079
+ $results = $results + pop(@fields);
1082
+ $start = 1 if ($line =~ /Context/o);
1086
+$pop->print("Action: logoff");
1089
+print "messages.value $results\n";