From a49aeae41cbe18317e41a67d27016675e9a014e0 Mon Sep 17 00:00:00 2001 From: Paul McCormack Date: Tue, 27 Oct 2009 00:15:42 +0100 Subject: [PATCH] Initial version --- plugins/other/asterisk_sippeers | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 plugins/other/asterisk_sippeers diff --git a/plugins/other/asterisk_sippeers b/plugins/other/asterisk_sippeers new file mode 100755 index 00000000..02ebd237 --- /dev/null +++ b/plugins/other/asterisk_sippeers @@ -0,0 +1,71 @@ +#!/usr/bin/perl -w +# +# Copyright (C) 2009 Paul McCormack +# +# 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 () +{ + $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"; +