~ubuntu-branches/ubuntu/oneiric/munin/oneiric-updates

« back to all changes in this revision

Viewing changes to debian/patches/560-asterisk-plugins

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-05-29 19:05:02 UTC
  • mfrom: (8.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090529190502-tcfkztuv244ke17s
Tags: 1.2.6-12ubuntu1
* Merge from debian unstable, remaining changes:
  - Suggest libdate-manip-perl (LP: #306274)
  - Recommend "cron". (LP: #225061)
  - Update maintainer according to spec.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# should go upstream
 
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
 
8
@@ -0,0 +1,95 @@
 
9
+#!/usr/bin/perl -w
 
10
+#
 
11
+# Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
 
12
+#
 
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,
 
16
+# 1991.
 
17
+#
 
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.
 
22
+#
 
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.
 
26
+#
 
27
+# If you improve this script please send your version to my email address
 
28
+# with the copyright notice upgrade with your name.
 
29
+#
 
30
+#
 
31
+# $Log$
 
32
+# Revision 1.1  2005/10/22 21:04:01  rodo
 
33
+# Created by Rodolphe Quiedeville
 
34
+#
 
35
+# Parameters mandatory:
 
36
+#
 
37
+#      username
 
38
+#      secret
 
39
+#
 
40
+#%# family=contrib
 
41
+#%# capabilities=autoconf
 
42
+
 
43
+use strict;
 
44
+
 
45
+my $ret = undef;
 
46
+if (! eval "require Net::Telnet;")
 
47
+{
 
48
+    $ret = "Net::Telnet not found";
 
49
+}
 
50
+
 
51
+if ($ARGV[0] and $ARGV[0] eq "config")
 
52
+{
 
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";
 
59
+    exit 0;
 
60
+}
 
61
+
 
62
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
 
63
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
 
64
+
 
65
+my $username = $ENV{'username'};
 
66
+my $secret   = $ENV{'secret'};
 
67
+
 
68
+my $pop = new Net::Telnet (Telnetmode => 0);
 
69
+$pop->open(Host => $host,
 
70
+          Port => $port);
 
71
+
 
72
+## Read connection message.
 
73
+my $line = $pop->getline;
 
74
+die $line unless $line =~ /^Asterisk/;
 
75
+
 
76
+## Send user name.
 
77
+$pop->print("Action: login");
 
78
+$pop->print("Username: $username");
 
79
+$pop->print("Secret: $secret");
 
80
+$pop->print("Events: off");
 
81
+$pop->print("");
 
82
+
 
83
+#Response: Success
 
84
+#Message: Authentication accepted
 
85
+
 
86
+## Request status of messages.
 
87
+$pop->print("Action: command");
 
88
+$pop->print("Command: show channels");
 
89
+$pop->print("");
 
90
+my $result;
 
91
+while (($line = $pop->getline) and ($line !~ /END COMMAND/o))
 
92
+{
 
93
+    #print $line;
 
94
+    $result = $line if $line =~ /active channel/;
 
95
+}
 
96
+
 
97
+my $nb = (split ' ',$result)[0];
 
98
+$pop->print("Action: logoff");
 
99
+$pop->print("");
 
100
+
 
101
+print "channels.value $nb\n";
 
102
+
 
103
+# vim:syntax=perl
 
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
 
108
@@ -0,0 +1,134 @@
 
109
+#!/usr/bin/perl -w
 
110
+#
 
111
+# Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
 
112
+#
 
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,
 
116
+# 1991.
 
117
+#
 
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.
 
122
+#
 
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.
 
126
+#
 
127
+# If you improve this script please send your version to my email address
 
128
+# with the copyright notice upgrade with your name.
 
129
+#
 
130
+# Plugin to monitor number of active channels by type, use the 
 
131
+# asterisk's manager API to fetch datas.
 
132
+#
 
133
+# $Log$
 
134
+# Revision 1.1  2006/03/06 12:04:01  rodo
 
135
+# Created by Rodolphe Quiedeville
 
136
+#
 
137
+# Parameters mandatory:
 
138
+#
 
139
+#      username
 
140
+#      secret
 
141
+#
 
142
+#%# family=contrib
 
143
+#%# capabilities=autoconf
 
144
+
 
145
+use strict;
 
146
+
 
147
+my $ret = undef;
 
148
+if (! eval "require Net::Telnet;")
 
149
+{
 
150
+    $ret = "Net::Telnet not found";
 
151
+}
 
152
+
 
153
+my @CHANNELS = exists $ENV{'channels'} ? split ' ',$ENV{'channels'} : qw(Zap IAX2 SIP);
 
154
+
 
155
+if ($ARGV[0] and $ARGV[0] eq "config")
 
156
+{
 
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";
 
164
+       }
 
165
+       else{
 
166
+           print "$channel.draw STACK\n";
 
167
+       }
 
168
+       print "$channel.label $channel\n";
 
169
+    }
 
170
+    exit 0;
 
171
+}
 
172
+
 
173
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
 
174
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
 
175
+
 
176
+my $username = $ENV{'username'};
 
177
+my $secret   = $ENV{'secret'};
 
178
+
 
179
+my $pop = new Net::Telnet (Telnetmode => 0);
 
180
+$pop->open(Host => $host,
 
181
+          Port => $port);
 
182
+
 
183
+## Read connection message.
 
184
+my $line = $pop->getline;
 
185
+die $line unless $line =~ /^Asterisk/;
 
186
+
 
187
+## Send user name.
 
188
+$pop->print("Action: login");
 
189
+$pop->print("Username: $username");
 
190
+$pop->print("Secret: $secret");
 
191
+$pop->print("Events: off");
 
192
+$pop->print("");
 
193
+
 
194
+#Response: Success
 
195
+#Message: Authentication accepted
 
196
+
 
197
+## Request status of messages.
 
198
+$pop->print("Action: command");
 
199
+$pop->print("Command: show channels");
 
200
+$pop->print("");
 
201
+
 
202
+#Response: Follows
 
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)
 
206
+#2 active channels
 
207
+#1 active call
 
208
+#--END COMMAND--
 
209
+
 
210
+my @results;
 
211
+my ($i, $start)=(0,0);
 
212
+foreach my $channel (@CHANNELS) {
 
213
+    $results[$i] = 0;
 
214
+    $i++;
 
215
+}
 
216
+
 
217
+my @fields;
 
218
+while (($line = $pop->getline) and ($line !~ /active channels/o))
 
219
+{
 
220
+    $i = 0;
 
221
+    if ($start) {
 
222
+       @fields = (split '/', $line);
 
223
+       foreach my $channel (@CHANNELS) {
 
224
+           $results[$i] = $results[$i] + 1 if ($fields[0] eq $channel);
 
225
+           $i++;
 
226
+       }
 
227
+    }
 
228
+    $start = 1 if ($line =~ /Channel/o);
 
229
+}
 
230
+
 
231
+
 
232
+# Logoff
 
233
+$pop->print("Action: logoff");
 
234
+$pop->print("");
 
235
+
 
236
+$i = 0;
 
237
+foreach my $channel (@CHANNELS) {
 
238
+    print "$channel.value $results[$i]\n";
 
239
+    $i++;
 
240
+}
 
241
+
 
242
+# vim:syntax=perl
 
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
 
247
@@ -0,0 +1,196 @@
 
248
+#!/usr/bin/perl -w
 
249
+#
 
250
+# Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
 
251
+#
 
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,
 
255
+# 1991.
 
256
+#
 
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.
 
261
+#
 
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.
 
265
+#
 
266
+# If you improve this script please send your version to my email address
 
267
+# with the copyright notice upgrade with your name.
 
268
+#
 
269
+# Plugin to monitor number of active channels by codec used, use the 
 
270
+# asterisk's manager API to fecth datas.
 
271
+#
 
272
+# $Log$
 
273
+# Revision 1.1  2005/10/28 21:04:01  rodo
 
274
+# Created by Rodolphe Quiedeville
 
275
+#
 
276
+# Parameters mandatory:
 
277
+#
 
278
+#      username
 
279
+#      secret
 
280
+#
 
281
+# Optional parameters:
 
282
+#       codecs
 
283
+#       codecsx
 
284
+# note that, if present, both required with codecsX being
 
285
+# the hex representation asterisk returns for the codec
 
286
+#
 
287
+#%# family=contrib
 
288
+#%# capabilities=autoconf
 
289
+
 
290
+use strict;
 
291
+
 
292
+my $ret = undef;
 
293
+if (! eval "require Net::Telnet;")
 
294
+{
 
295
+    $ret = "Net::Telnet not found";
 
296
+}
 
297
+
 
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);
 
300
+
 
301
+if ($ARGV[0] and $ARGV[0] eq "config")
 
302
+{
 
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";
 
310
+       }
 
311
+       else{
 
312
+           print "$codec.draw STACK\n";
 
313
+       }
 
314
+       print "$codec.label $codec\n";
 
315
+    }
 
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";
 
320
+    exit 0;
 
321
+}
 
322
+
 
323
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
 
324
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
 
325
+
 
326
+my $username = $ENV{'username'};
 
327
+my $secret   = $ENV{'secret'};
 
328
+
 
329
+my $pop = new Net::Telnet (Telnetmode => 0);
 
330
+$pop->open(Host => $host,
 
331
+          Port => $port);
 
332
+
 
333
+## Read connection message.
 
334
+my $line = $pop->getline;
 
335
+die $line unless $line =~ /^Asterisk/;
 
336
+
 
337
+## Send user name.
 
338
+$pop->print("Action: login");
 
339
+$pop->print("Username: $username");
 
340
+$pop->print("Secret: $secret");
 
341
+$pop->print("Events: off");
 
342
+$pop->print("");
 
343
+
 
344
+#Response: Success
 
345
+#Message: Authentication accepted
 
346
+
 
347
+## Request status of messages.
 
348
+$pop->print("Action: command");
 
349
+$pop->print("Command: sip show channels");
 
350
+$pop->print("");
 
351
+
 
352
+#Response: Follows
 
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)
 
356
+#--END COMMAND--
 
357
+
 
358
+my @results;
 
359
+my ($i, $start, $unknown, $other)=(0,0,0,0);
 
360
+foreach my $codec (@CODECS) {
 
361
+    $results[$i] = 0;
 
362
+    $i++;
 
363
+}
 
364
+
 
365
+my @fields;
 
366
+while (($line = $pop->getline) and ($line !~ /active SIP channel/o))
 
367
+{
 
368
+    #print STDERR "SIP: $line\n";
 
369
+    $i = 0;
 
370
+    my $found = 0;
 
371
+    if ($start) {
 
372
+       @fields = (split ' ', $line);
 
373
+        if ($fields[4] eq '0x0') {
 
374
+            $unknown += 1;
 
375
+            next;
 
376
+        }
 
377
+       foreach my $codec (@CODECSX) {
 
378
+           if ($fields[4] eq "$codec") {
 
379
+               $results[$i] = $results[$i] + 1;
 
380
+               $found = 1;
 
381
+               last;
 
382
+           }
 
383
+           $i++;
 
384
+       }
 
385
+       if (! $found) {
 
386
+            $other += 1;
 
387
+           print STDERR "CODEC: SIP other format $fields[4]\n";
 
388
+       }
 
389
+    }
 
390
+    $start = 1 if ($line =~ /Peer/o);
 
391
+}
 
392
+
 
393
+## Request status of messages.
 
394
+$pop->print("Action: command");
 
395
+$pop->print("Command: iax2 show channels");
 
396
+$pop->print("");
 
397
+
 
398
+#Response: Follows
 
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)
 
402
+#--END COMMAND--
 
403
+
 
404
+$start = 0;
 
405
+while (($line = $pop->getline) and ($line !~ /active IAX channel/o))
 
406
+{
 
407
+    $i = 0;
 
408
+    my $found = 0;
 
409
+    if ($start) {
 
410
+       @fields = (split ' ', $line);
 
411
+        if ($fields[8] eq '0x0') {
 
412
+            $unknown += 1;
 
413
+            next;
 
414
+        }
 
415
+       foreach my $codec (@CODECSX) {
 
416
+           if ($fields[8] eq "$codec") {
 
417
+               $results[$i] = $results[$i] + 1;
 
418
+               $found = 1;
 
419
+               last;
 
420
+           }
 
421
+           $i++;
 
422
+       }
 
423
+        if (! $found) {
 
424
+            $other += 1;
 
425
+            print STDERR "CODEC: IAX2 other format: $fields[8]\n";
 
426
+        }
 
427
+    }
 
428
+    $start = 1 if ($line =~ /Channel/o);
 
429
+}
 
430
+
 
431
+# Logoff
 
432
+$pop->print("Action: logoff");
 
433
+$pop->print("");
 
434
+
 
435
+$i = 0;
 
436
+foreach my $codec (@CODECS) {
 
437
+    print "$codec.value $results[$i]\n";
 
438
+    $i++;
 
439
+}
 
440
+print "other.value $other\n";
 
441
+print "unknown.value $unknown\n";
 
442
+
 
443
+# vim:syntax=perl
 
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
 
448
@@ -0,0 +1,109 @@
 
449
+#!/usr/bin/perl -w
 
450
+#
 
451
+# Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
 
452
+#
 
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,
 
456
+# 1991.
 
457
+#
 
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.
 
462
+#
 
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.
 
466
+#
 
467
+# If you improve this script please send your version to my email address
 
468
+# with the copyright notice upgrade with your name.
 
469
+#
 
470
+# Plugin to monitor number of active conferences, use the asterisk's manager
 
471
+# API to fecth datas.
 
472
+#
 
473
+# $Log$
 
474
+# Revision 1.1  2005/10/22 21:04:01  rodo
 
475
+# Created by Rodolphe Quiedeville
 
476
+#
 
477
+# Parameters mandatory:
 
478
+#
 
479
+#      username
 
480
+#      secret
 
481
+#
 
482
+#%# family=contrib
 
483
+#%# capabilities=autoconf
 
484
+
 
485
+use strict;
 
486
+
 
487
+my $ret = undef;
 
488
+if (! eval "require Net::Telnet;")
 
489
+{
 
490
+    $ret = "Net::Telnet not found";
 
491
+}
 
492
+
 
493
+if ($ARGV[0] and $ARGV[0] eq "config")
 
494
+{
 
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";
 
501
+    exit 0;
 
502
+}
 
503
+
 
504
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
 
505
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
 
506
+
 
507
+my $username = $ENV{'username'};
 
508
+my $secret   = $ENV{'secret'};
 
509
+
 
510
+my $pop = new Net::Telnet (Telnetmode => 0);
 
511
+$pop->open(Host => $host,
 
512
+          Port => $port);
 
513
+
 
514
+## Read connection message.
 
515
+my $line = $pop->getline;
 
516
+die $line unless $line =~ /^Asterisk/;
 
517
+
 
518
+## Send user name.
 
519
+$pop->print("Action: login");
 
520
+$pop->print("Username: $username");
 
521
+$pop->print("Secret: $secret");
 
522
+$pop->print("Events: off");
 
523
+$pop->print("");
 
524
+
 
525
+#Response: Success
 
526
+#Message: Authentication accepted
 
527
+
 
528
+## Request status of messages.
 
529
+$pop->print("Action: command");
 
530
+$pop->print("Command: meetme");
 
531
+$pop->print("");
 
532
+
 
533
+
 
534
+#Response: Follows
 
535
+#Conf Num       Parties        Marked     Activity  Creation
 
536
+#5500           0001           N/A        00:00:03  Static
 
537
+#* Total number of MeetMe users: 1
 
538
+#--END COMMAND--
 
539
+
 
540
+my ($confs, $start)=(0,0);
 
541
+
 
542
+while (($line = $pop->getline) and ($line !~ /Total number|No active MeetMe/o))
 
543
+{
 
544
+    if ($start) {
 
545
+        #print $line;
 
546
+       $confs++;
 
547
+    }
 
548
+
 
549
+    $start = 1 if ($line =~ /Conf\sNum\s*Parties/o);
 
550
+}
 
551
+
 
552
+$pop->print("Action: logoff");
 
553
+$pop->print("");
 
554
+
 
555
+print "confs.value $confs\n";
 
556
+
 
557
+# vim:syntax=perl
 
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
 
562
@@ -0,0 +1,104 @@
 
563
+#!/usr/bin/perl -w
 
564
+#
 
565
+# Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
 
566
+#
 
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,
 
570
+# 1991.
 
571
+#
 
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.
 
576
+#
 
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.
 
580
+#
 
581
+# If you improve this script please send your version to my email address
 
582
+# with the copyright notice upgrade with your name.
 
583
+#
 
584
+# Plugin to monitor number of active users in all the conferences, use the 
 
585
+# asterisk's manager API to fecth datas.
 
586
+#
 
587
+# $Log$
 
588
+# Revision 1.1  2005/10/22 24:04:01  rodo
 
589
+# Created by Rodolphe Quiedeville
 
590
+#
 
591
+# Parameters mandatory:
 
592
+#
 
593
+#      username
 
594
+#      secret
 
595
+#
 
596
+#%# family=contrib
 
597
+#%# capabilities=autoconf
 
598
+
 
599
+use strict;
 
600
+
 
601
+my $ret = undef;
 
602
+if (! eval "require Net::Telnet;")
 
603
+{
 
604
+    $ret = "Net::Telnet not found";
 
605
+}
 
606
+
 
607
+if ($ARGV[0] and $ARGV[0] eq "config")
 
608
+{
 
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";
 
616
+    exit 0;
 
617
+}
 
618
+
 
619
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
 
620
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
 
621
+
 
622
+my $username = $ENV{'username'};
 
623
+my $secret   = $ENV{'secret'};
 
624
+
 
625
+my $pop = new Net::Telnet (Telnetmode => 0);
 
626
+$pop->open(Host => $host,
 
627
+          Port => $port);
 
628
+
 
629
+## Read connection message.
 
630
+my $line = $pop->getline;
 
631
+die $line unless $line =~ /^Asterisk/;
 
632
+
 
633
+## Send user name.
 
634
+$pop->print("Action: login");
 
635
+$pop->print("Username: $username");
 
636
+$pop->print("Secret: $secret");
 
637
+$pop->print("Events: off");
 
638
+$pop->print("");
 
639
+
 
640
+#Response: Success
 
641
+#Message: Authentication accepted
 
642
+
 
643
+## Request status of messages.
 
644
+$pop->print("Action: command");
 
645
+$pop->print("Command: meetme");
 
646
+$pop->print("");
 
647
+
 
648
+my $nb = 0;
 
649
+
 
650
+#Response: Follows
 
651
+#Privilege: Command
 
652
+#No active MeetMe conferences.
 
653
+# OR
 
654
+#Total number of MeetMe users: 1
 
655
+
 
656
+while (($line = $pop->getline) and ($line !~ /END COMMAND/o))
 
657
+{
 
658
+    $nb = $1 if $line =~ /MeetMe users:\s(\d)$/;
 
659
+}
 
660
+
 
661
+$pop->print("Action: logoff");
 
662
+$pop->print("");
 
663
+
 
664
+print "users.value $nb\n";
 
665
+
 
666
+# vim:syntax=perl
 
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
 
671
@@ -0,0 +1,167 @@
 
672
+#!/usr/bin/perl -w
 
673
+#
 
674
+# Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
 
675
+#
 
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,
 
679
+# 1991.
 
680
+#
 
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.
 
685
+#
 
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.
 
689
+#
 
690
+# If you improve this script please send your version to my email address
 
691
+# with the copyright notice upgrade with your name.
 
692
+#
 
693
+# Plugin to monitor number of SIP active channels by codec used, use the 
 
694
+# asterisk's manager API to fecth datas.
 
695
+#
 
696
+# $Log$
 
697
+# Revision 1.3  2006/02/27 12:04:01  rodo
 
698
+# Support codec's list definition in config file
 
699
+#
 
700
+# Revision 1.2  2006/02/26 12:04:01  rodo
 
701
+# Support Asterisk 1.2
 
702
+#
 
703
+# Revision 1.1  2005/10/28 21:04:01  rodo
 
704
+# Created by Rodolphe Quiedeville
 
705
+#
 
706
+# Parameters mandatory:
 
707
+#
 
708
+#      username
 
709
+#      secret
 
710
+#
 
711
+# Optional parameters:
 
712
+#       codecs
 
713
+#      codecsx
 
714
+# note that, if present, both required with codecsX being
 
715
+# the hex representation asterisk returns for the codec
 
716
+#
 
717
+#%# family=contrib
 
718
+#%# capabilities=autoconf
 
719
+
 
720
+use strict;
 
721
+
 
722
+my $ret = undef;
 
723
+if (! eval "require Net::Telnet;")
 
724
+{
 
725
+    $ret = "Net::Telnet not found";
 
726
+}
 
727
+
 
728
+#Codecs g723, gsm, ulaw, alaw, g726, adpcm, slin, lpc10, g729, speex, ilbc
 
729
+
 
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);
 
732
+
 
733
+if ($ARGV[0] and $ARGV[0] eq "config")
 
734
+{
 
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";
 
742
+       }
 
743
+       else{
 
744
+           print "$codec.draw STACK\n";
 
745
+       }
 
746
+       print "$codec.label $codec\n";
 
747
+    }
 
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";
 
752
+    exit 0;
 
753
+}
 
754
+
 
755
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
 
756
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
 
757
+
 
758
+my $username = $ENV{'username'};
 
759
+my $secret   = $ENV{'secret'};
 
760
+
 
761
+my $pop = new Net::Telnet (Telnetmode => 0);
 
762
+$pop->open(Host => $host,
 
763
+          Port => $port);
 
764
+
 
765
+## Read connection message.
 
766
+my $line = $pop->getline;
 
767
+die $line unless $line =~ /^Asterisk/;
 
768
+
 
769
+## Send user name.
 
770
+$pop->print("Action: login");
 
771
+$pop->print("Username: $username");
 
772
+$pop->print("Secret: $secret");
 
773
+$pop->print("Events: off");
 
774
+$pop->print("");
 
775
+
 
776
+## Request status of messages.
 
777
+$pop->print("Action: command");
 
778
+$pop->print("Command: sip show channels");
 
779
+$pop->print("");
 
780
+
 
781
+#Response: Follows
 
782
+#Privilege: Command
 
783
+#Peer           User/ANR    Call ID      Seq (Tx/Rx)  Format         Hold   Last Message   
 
784
+#0 active SIP channels
 
785
+# -- OR --
 
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
 
789
+#--END COMMAND--
 
790
+
 
791
+
 
792
+my @results;
 
793
+my ($i, $start, $unknown, $other, $fields)=(0,0,0,0,0);
 
794
+foreach my $codec (@CODECS) {
 
795
+    $results[$i] = 0;
 
796
+    $i++;
 
797
+}
 
798
+
 
799
+while (($line = $pop->getline) and ($line !~ /active SIP channel/o))
 
800
+{
 
801
+    $i = 0;
 
802
+    if ($start) {
 
803
+       my @fields = (split ' ', $line);
 
804
+       if ($fields[4] eq '0x0') {
 
805
+           $unknown += 1;
 
806
+           next;
 
807
+       }
 
808
+       my $found = 0;
 
809
+       foreach my $codec (@CODECSX) {
 
810
+           if ($fields[4] eq "$codec") {
 
811
+               $results[$i] = $results[$i] + 1;
 
812
+               $found = 1;
 
813
+               last;
 
814
+           }
 
815
+           $i++;
 
816
+       }
 
817
+       if (! $found) {
 
818
+           $other += 1;
 
819
+           print STDERR "SIP other format: $fields[4]\n";
 
820
+       }
 
821
+    }
 
822
+    $start = 1 if ($line =~ /Peer/o);
 
823
+}
 
824
+
 
825
+$pop->print("Action: logoff");
 
826
+$pop->print("");
 
827
+
 
828
+$i = 0;
 
829
+foreach my $codec (@CODECS) {
 
830
+    print "$codec.value $results[$i]\n";
 
831
+    $i++;
 
832
+}
 
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";
 
837
+
 
838
+# vim:syntax=perl
 
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
 
843
@@ -0,0 +1,136 @@
 
844
+#!/usr/bin/perl -w
 
845
+#
 
846
+# Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
 
847
+#
 
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,
 
851
+# 1991.
 
852
+#
 
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.
 
857
+#
 
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.
 
861
+#
 
862
+# If you improve this script please send your version to my email address
 
863
+# with the copyright notice upgrade with your name.
 
864
+#
 
865
+# Plugin to monitor number of sip peers registered, use the asterisk's manager
 
866
+# API to fecth datas.
 
867
+#
 
868
+# $Log$
 
869
+# Revision 1.1  2005/10/28 16:42:01  rodo
 
870
+# Created by Rodolphe Quiedeville
 
871
+#
 
872
+# Parameters mandatory:
 
873
+#
 
874
+#      username
 
875
+#      secret
 
876
+#
 
877
+#%# family=contrib
 
878
+#%# capabilities=autoconf
 
879
+
 
880
+# #################################################################################
 
881
+# Following example from current asterisk 1.4
 
882
+#> sip show peers
 
883
+#Name/username              Host            Dyn Nat ACL Port     Status               
 
884
+#104-RANDALLBUILT/104-RAND  74.218.176.166   D          5060     Unmonitored           
 
885
+#...           
 
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
+# #################################################################################
 
890
+
 
891
+use strict;
 
892
+
 
893
+my $ret = undef;
 
894
+if (! eval "require Net::Telnet;")
 
895
+{
 
896
+    $ret = "Net::Telnet not found";
 
897
+}
 
898
+
 
899
+if ($ARGV[0] and $ARGV[0] eq "config")
 
900
+{
 
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";
 
915
+    #graph_scale no
 
916
+    #load.warning 10
 
917
+    #load.critical 120
 
918
+    #graph_info The ... describes ....
 
919
+    #load.info Average load for the five minutes.
 
920
+    exit 0;
 
921
+}
 
922
+
 
923
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
 
924
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
 
925
+
 
926
+my $username = $ENV{'username'};
 
927
+my $secret   = $ENV{'secret'};
 
928
+
 
929
+my $pop = new Net::Telnet (Telnetmode => 0);
 
930
+$pop->open(Host => $host,
 
931
+          Port => $port);
 
932
+
 
933
+## Read connection message.
 
934
+my $line = $pop->getline;
 
935
+die $line unless $line =~ /^Asterisk/;
 
936
+
 
937
+## Send user name.
 
938
+$pop->print("Action: login");
 
939
+$pop->print("Username: $username");
 
940
+$pop->print("Secret: $secret");
 
941
+$pop->print("Events: off");
 
942
+$pop->print("");
 
943
+
 
944
+#Response: Success
 
945
+#Message: Authentication accepted
 
946
+
 
947
+## Request status of messages.
 
948
+$pop->print("Action: command");
 
949
+$pop->print("Command: sip show peers");
 
950
+$pop->print("");
 
951
+
 
952
+my ($peers,$monitor_online,$monitor_offline,$unmonitor_online,$unmonitor_offline)=(0,0,0,0,0);
 
953
+
 
954
+while (($line = $pop->getline) and ($line !~ /END COMMAND/o))
 
955
+{
 
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";
 
966
+       last;
 
967
+    }
 
968
+}
 
969
+
 
970
+$pop->print("Action: logoff");
 
971
+$pop->print("");
 
972
+
 
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";
 
978
+
 
979
+# vim:syntax=perl
 
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
 
984
@@ -0,0 +1,106 @@
 
985
+#!/usr/bin/perl -w
 
986
+#
 
987
+# Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
 
988
+#
 
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,
 
992
+# 1991.
 
993
+#
 
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.
 
998
+#
 
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.
 
1002
+#
 
1003
+# If you improve this script please send your version to my email address
 
1004
+# with the copyright notice upgrade with your name.
 
1005
+#
 
1006
+# Plugin to monitor number of messages in all voicemails
 
1007
+#
 
1008
+# $Log$
 
1009
+# Revision 1.1  2006/03/05 15:07:01  rodo
 
1010
+# Created by Rodolphe Quiedeville
 
1011
+#
 
1012
+# Parameters mandatory:
 
1013
+#
 
1014
+#      username
 
1015
+#      secret
 
1016
+#
 
1017
+#%# family=contrib
 
1018
+#%# capabilities=autoconf
 
1019
+
 
1020
+use strict;
 
1021
+
 
1022
+my $ret = undef;
 
1023
+if (! eval "require Net::Telnet;")
 
1024
+{
 
1025
+    $ret = "Net::Telnet not found";
 
1026
+}
 
1027
+
 
1028
+if ($ARGV[0] and $ARGV[0] eq "config")
 
1029
+{
 
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";
 
1036
+    exit 0;
 
1037
+}
 
1038
+
 
1039
+my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
 
1040
+my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
 
1041
+
 
1042
+my $username = $ENV{'username'};
 
1043
+my $secret   = $ENV{'secret'};
 
1044
+
 
1045
+my $pop = new Net::Telnet (Telnetmode => 0);
 
1046
+$pop->open(Host => $host,
 
1047
+          Port => $port);
 
1048
+
 
1049
+## Read connection message.
 
1050
+my $line = $pop->getline;
 
1051
+die $line unless $line =~ /^Asterisk/;
 
1052
+
 
1053
+## Send user name.
 
1054
+$pop->print("Action: login");
 
1055
+$pop->print("Username: $username");
 
1056
+$pop->print("Secret: $secret");
 
1057
+$pop->print("Events: off");
 
1058
+$pop->print("");
 
1059
+
 
1060
+#Response: Success
 
1061
+#Message: Authentication accepted
 
1062
+
 
1063
+## Request status of messages.
 
1064
+$pop->print("Action: command");
 
1065
+$pop->print("Command: show voicemail users");
 
1066
+$pop->print("");
 
1067
+
 
1068
+#Context    Mbox  User                      Zone       NewMsg
 
1069
+#default    1234  Example Mailbox                           1
 
1070
+#other      1234  Company2 User                             0
 
1071
+
 
1072
+my ($results,$start)=(0,0);
 
1073
+
 
1074
+my @fields;
 
1075
+while (($line = $pop->getline)  and ($line !~ /--END/o))
 
1076
+{
 
1077
+    if ($start) {
 
1078
+       @fields = (split ' ', $line);   
 
1079
+       $results = $results + pop(@fields);
 
1080
+    }
 
1081
+
 
1082
+    $start = 1 if ($line =~ /Context/o);
 
1083
+}
 
1084
+
 
1085
+# Logoff
 
1086
+$pop->print("Action: logoff");
 
1087
+$pop->print("");
 
1088
+
 
1089
+print "messages.value $results\n";
 
1090
+# vim:syntax=perl