root / plugins / asterisk / asterisk_14_fax_ffa / TEMPLATE @ 45391005
Historique | Voir | Annoter | Télécharger (2,19 ko)
| 1 |
#!/usr/bin/perl |
|---|---|
| 2 |
|
| 3 |
use Carp; |
| 4 |
use strict; |
| 5 |
use Asterisk::AMI; |
| 6 |
|
| 7 |
my $ret = undef; |
| 8 |
if ( ! eval "require Asterisk::AMI;" ) {
|
| 9 |
$ret = "Asterisk::AMI not found"; |
| 10 |
}; |
| 11 |
|
| 12 |
if ( $ARGV[ 0 ] and $ARGV[ 0 ] eq "config" ) {
|
| 13 |
print "graph_title Asterisk Fax - Cancelled Faxes (T.38 and G.711)\n"; |
| 14 |
print "graph_args --base 1000 -l 0\n"; |
| 15 |
print "graph_vlabel Number of Cancelled Faxes\n"; |
| 16 |
print "graph_category other\n"; |
| 17 |
print "t38_cancelled.draw AREA\n"; |
| 18 |
print "t38_cancelled.label Cancelled T.38 Faxes\n"; |
| 19 |
print "g711_cancelled.draw AREA\n"; |
| 20 |
print "g711_cancelled.label Cancelled G.711 Faxes\n"; |
| 21 |
exit ( 0 ); |
| 22 |
}; |
| 23 |
|
| 24 |
#my $host = exists $ENV{ 'host' } ? $ENV{ 'host' } : "127.0.0.1";
|
| 25 |
#my $port = exists $ENV{ 'port' } ? $ENV{ 'port' } : "5038";
|
| 26 |
#my $username = $ENV{ 'username' };
|
| 27 |
#my $secret = $ENV{ 'secret' };
|
| 28 |
|
| 29 |
my $username = 'manager'; |
| 30 |
my $host = '192.168.1.70'; |
| 31 |
my $port = '5038'; |
| 32 |
my $secret = 'insecure'; |
| 33 |
my $timeout = '5'; |
| 34 |
|
| 35 |
my $astman = Asterisk::AMI->new(PeerAddr => "$host", |
| 36 |
PeerPort => "$port", |
| 37 |
Username => "$username", |
| 38 |
Secret => "$secret" |
| 39 |
); |
| 40 |
|
| 41 |
croak "Unable to connect to asterisk" unless ( $astman ); |
| 42 |
my $actionid = $astman->send_action({ Action => 'Command',
|
| 43 |
Command => 'fax show stats', |
| 44 |
$timeout}); |
| 45 |
my $response = $astman->get_response( $actionid ); |
| 46 |
my $arrayref = $response->{CMD};
|
| 47 |
my $null = qq{};
|
| 48 |
my ( %faxstats, $section ); |
| 49 |
foreach my $line ( @$arrayref ) {
|
| 50 |
next if ( ( ! $line ) || ( $line =~ /-----------/ ) ); |
| 51 |
my ( $key, $value ) = split( ':', $line ); |
| 52 |
$section = $key if ( $value eq $null ); |
| 53 |
$key =~ s/\s+$//g; |
| 54 |
$value =~ s/^\s+//g; |
| 55 |
$faxstats{ "$section" }{ "$key" } = $value if ( $value ne $null );
|
| 56 |
}; |
| 57 |
$astman->disconnect; |
| 58 |
|
| 59 |
print "t38_cancelled.value $faxstats{'Digium T.38'}{'Canceled'}\n";
|
| 60 |
print "g711_cancelled.value $faxstats{'Digium G.711'}{'Canceled'}\n";
|
| 61 |
|
| 62 |
exit( 0 ); |
| 63 |
|
| 64 |
|
| 65 |
|
