#!/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 active channels\n"; print "graph_args --base 1000 -l 0\n"; print "graph_vlabel peers\n"; print "graph_category asterisk\n"; print "channels.label peers online\n"; exit 0; } open(LINE, 'asterisk -rx "core show channels"|'); my ($active)=(0,0); while () { $active = $1 if ($_ =~ /(\d+) active channels/); } close(LINE); print "channels.value $active\n";