1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-31 05:13:45 +00:00

Initial version

This commit is contained in:
Paul McCormack 2009-10-27 00:15:42 +01:00 committed by Steve Schnepp
parent 06e10a5359
commit a49aeae41c

71
plugins/other/asterisk_sippeers Executable file
View file

@ -0,0 +1,71 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2009 Paul McCormack <paul@paulmccormack.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# If you improve this script please send your version to my email address
# with the copyright notice upgrade with your name.
#
# Plugin to monitor number of sip peers registered
#
#
#%# family=asterisk
use strict;
if ($ARGV[0] and $ARGV[0] eq "autoconf")
{
print "yes\n";
exit 0;
}
if ($ARGV[0] and $ARGV[0] eq "config")
{
print "graph_title Asterisk connected sip peers\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel peers\n";
print "graph_category asterisk\n";
print "peers_online.label peers online\n";
print "peers_offline.label peers offline\n";
print "unmon_online.label unmonitored online\n";
print "unmon_offline.label unmonitored offline\n";
print "peers_offline.warning 1\n";
print "peers_offline.critical 2\n";
exit 0;
}
open(LINE, 'asterisk -rx "sip show peers"|');
my ($online)=(0,0);
my ($offline)=(0,0);
my ($unmon_online)=(0,0);
my ($unmon_offline)=(0,0);
while (<LINE>)
{
$online = $1 if ($_ =~ /Monitored: (\d+) online/);
$offline = $1 if ($_ =~ /Monitored: \d+ online, (\d+) offline/);
$unmon_online = $1 if ($_ =~ /Unmonitored: (\d+) online/);
$unmon_offline = $1 if ($_ =~ /Unmonitored: \d+ online, (\d+) offline/);
}
close(LINE);
print "peers_online.value $online\n";
print "peers_offline.value $offline\n";
print "unmon_online.value $unmon_online\n";
print "unmon_offline.value $unmon_offline\n";