2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/asterisk/asterisk_14_fax_ffa/TEMPLATE
Kenyon Ralph c33bbb90e5 organize asterisk plugins
untar asterisk-fax and move asterisk-multigraph-munin-plugin
2012-04-24 01:55:09 -07:00

66 lines
2.2 KiB
Perl
Executable File

#!/usr/bin/perl
use Carp;
use strict;
use Asterisk::AMI;
my $ret = undef;
if ( ! eval "require Asterisk::AMI;" ) {
$ret = "Asterisk::AMI not found";
};
if ( $ARGV[ 0 ] and $ARGV[ 0 ] eq "config" ) {
print "graph_title Asterisk Fax - Cancelled Faxes (T.38 and G.711)\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Number of Cancelled Faxes\n";
print "graph_category asterisk\n";
print "t38_cancelled.draw AREA\n";
print "t38_cancelled.label Cancelled T.38 Faxes\n";
print "g711_cancelled.draw AREA\n";
print "g711_cancelled.label Cancelled G.711 Faxes\n";
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 $username = 'manager';
my $host = '192.168.1.70';
my $port = '5038';
my $secret = 'insecure';
my $timeout = '5';
my $astman = Asterisk::AMI->new(PeerAddr => "$host",
PeerPort => "$port",
Username => "$username",
Secret => "$secret"
);
croak "Unable to connect to asterisk" unless ( $astman );
my $actionid = $astman->send_action({ Action => 'Command',
Command => 'fax show stats',
$timeout});
my $response = $astman->get_response( $actionid );
my $arrayref = $response->{CMD};
my $null = qq{};
my ( %faxstats, $section );
foreach my $line ( @$arrayref ) {
next if ( ( ! $line ) || ( $line =~ /-----------/ ) );
my ( $key, $value ) = split( ':', $line );
$section = $key if ( $value eq $null );
$key =~ s/\s+$//g;
$value =~ s/^\s+//g;
$faxstats{ "$section" }{ "$key" } = $value if ( $value ne $null );
};
$astman->disconnect;
print "t38_cancelled.value $faxstats{'Digium T.38'}{'Canceled'}\n";
print "g711_cancelled.value $faxstats{'Digium G.711'}{'Canceled'}\n";
exit( 0 );