mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
- have some dirs
This commit is contained in:
parent
0b089ea777
commit
08346aac58
687 changed files with 0 additions and 0 deletions
52
plugins/asterisk/asterisk_inuse
Executable file
52
plugins/asterisk/asterisk_inuse
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# add this into munin/plugin-conf.d/plugins.conf:
|
||||
#
|
||||
# [asterisk_inuse]
|
||||
# user root
|
||||
#
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -x /usr/local/sbin/asterisk ]; then
|
||||
/usr/local/sbin/asterisk -rx 'sip show inuse' > /dev/null
|
||||
if [ $? = "0" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Line use'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel line use and connected users states'
|
||||
echo 'graph_noscale true'
|
||||
echo 'graph_info will be info'
|
||||
echo 'graph_category asterisk'
|
||||
echo 'inuse.label inuse'
|
||||
echo 'inuse.type GAUGE'
|
||||
echo 'inuse.info sip show inuse'
|
||||
echo 'connected.label connected'
|
||||
echo 'connected.type GAUGE'
|
||||
echo 'connected.info sip show peers'
|
||||
echo 'connected.warning 10:300'
|
||||
echo 'connected.critical 1:500'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
INUSE=`/usr/local/sbin/asterisk -rx 'sip show inuse' | grep -v "0/0" | grep -v " 0 " | grep -v " name" | wc -l`
|
||||
CONN=`/usr/local/sbin/asterisk -rx 'sip show peers' | grep OK | wc -l`
|
||||
|
||||
if [ "$INUSE" -ge "1" ]; then
|
||||
echo "inuse.value"$INUSE
|
||||
else
|
||||
echo "inuse.value 0"
|
||||
fi
|
||||
|
||||
echo "connected.value"$CONN
|
168
plugins/asterisk/asterisk_sippeers
Executable file
168
plugins/asterisk/asterisk_sippeers
Executable file
|
@ -0,0 +1,168 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
asterix_sippeers - Plugin to monitor number of sip peers registered
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
The following configuration parameters are used by this plugin
|
||||
|
||||
[asterisk_sippeers]
|
||||
env.host - hostname to connect to
|
||||
env.port - port number to connect to
|
||||
env.username - username used for authentication
|
||||
env.secret - secret used for authentication
|
||||
|
||||
The "username" and "secret" parameters are mandatory, and have no
|
||||
defaults.
|
||||
|
||||
=head2 DEFAULT CONFIGURATION
|
||||
|
||||
[asterisk_sippeers]
|
||||
env.host 127.0.0.1
|
||||
env.port 5038
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
|
||||
Ported to Asterisk 1.6 by cerien.jean@gmail.com
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Gnu GPLv2
|
||||
|
||||
=begin comment
|
||||
|
||||
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.
|
||||
|
||||
=end comment
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=contrib
|
||||
|
||||
=cut
|
||||
|
||||
# #################################################################################
|
||||
# Following example from current asterisk 1.4
|
||||
#> sip show peers
|
||||
#Name/username Host Dyn Nat ACL Port Status
|
||||
#104-RANDALLBUILT/104-RAND 74.218.176.166 D 5060 Unmonitored
|
||||
#...
|
||||
#102-ROCKSOLID/102-ROCKSOL (Unspecified) D 0 Unmonitored
|
||||
#101-ROCKSOLID/101-ROCKSOL (Unspecified) D N 0 UNKNOWN
|
||||
#20 sip peers [Monitored: 0 online, 1 offline Unmonitored: 2 online, 17 offline]
|
||||
# #################################################################################
|
||||
|
||||
use strict;
|
||||
|
||||
my $ret = undef;
|
||||
if (! eval "require Net::Telnet;")
|
||||
{
|
||||
$ret = "Net::Telnet not found";
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "graph_title Asterisk sip peers\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_order mon moff umon umoff\n";
|
||||
print "graph_vlabel peers\n";
|
||||
print "graph_category asterisk\n";
|
||||
#print "peers.label total\n";
|
||||
print "mon.draw AREA\n";
|
||||
print "mon.label monitored online\n";
|
||||
print "moff.draw STACK\n";
|
||||
print "moff.label monitored offline\n";
|
||||
print "umon.draw STACK\n";
|
||||
print "umon.label unmonitored online\n";
|
||||
print "umoff.draw STACK\n";
|
||||
print "umoff.label unmonitored offline\n";
|
||||
#graph_scale no
|
||||
#load.warning 10
|
||||
#load.critical 120
|
||||
#graph_info The ... describes ....
|
||||
#load.info Average load for the five minutes.
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
|
||||
my $port = exists $ENV{'port'} ? $ENV{'port'} : "5038";
|
||||
|
||||
my $username = $ENV{'username'};
|
||||
my $secret = $ENV{'secret'};
|
||||
|
||||
my $pop = new Net::Telnet (Telnetmode => 0);
|
||||
$pop->open(Host => $host,
|
||||
Port => $port);
|
||||
|
||||
## Read connection message.
|
||||
my $line = $pop->getline;
|
||||
die $line unless $line =~ /^Asterisk/;
|
||||
|
||||
## Send user name.
|
||||
$pop->print("Action: login");
|
||||
$pop->print("Username: $username");
|
||||
$pop->print("Secret: $secret");
|
||||
$pop->print("Events: off");
|
||||
$pop->print("");
|
||||
|
||||
#Response: Success
|
||||
#Message: Authentication accepted
|
||||
|
||||
## Request status of messages.
|
||||
$pop->print("Action: command");
|
||||
$pop->print("Command: sip show peers");
|
||||
$pop->print("");
|
||||
|
||||
my ($peers,$monitor_online,$monitor_offline,$unmonitor_online,$unmonitor_offline)=(0,0,0,0,0);
|
||||
|
||||
while (($line = $pop->getline) and ($line !~ /END COMMAND/o))
|
||||
{
|
||||
my @fields = split(' ', $line);
|
||||
my $count = @fields;
|
||||
#20 sip peers [Monitored: 0 online, 1 offline Unmonitored: 2 online, 17 offline]
|
||||
if (($count > 10) and ($fields[1] eq 'sip' and $fields[2] eq 'peers')) {
|
||||
$peers = $fields[0];
|
||||
$monitor_online = $fields[4];
|
||||
$monitor_offline = $fields[6];
|
||||
$unmonitor_online = $fields[9];
|
||||
$unmonitor_offline = $fields[11];
|
||||
#print STDERR "$peers $monitor_online $monitor_offline $unmonitor_online $unmonitor_offline\n";
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$pop->print("Action: logoff");
|
||||
$pop->print("");
|
||||
|
||||
# purge the last lines to avoid error message on CLI
|
||||
while ($line = $pop->getline)
|
||||
{
|
||||
# print STDERR " $line \n";
|
||||
}
|
||||
#print "peers.value $peers\n";
|
||||
print "mon.value $monitor_online\n";
|
||||
print "moff.value $monitor_offline\n";
|
||||
print "umon.value $unmonitor_online\n";
|
||||
print "umoff.value $unmonitor_offline\n";
|
||||
|
||||
# vim:syntax=perl
|
Loading…
Add table
Add a link
Reference in a new issue