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/get_fax_stats.pl
Kenyon Ralph c33bbb90e5 organize asterisk plugins
untar asterisk-fax and move asterisk-multigraph-munin-plugin
2012-04-24 01:55:09 -07:00

36 lines
1.2 KiB
Perl
Executable File

sub get_fax_stats {
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',
$amiparams{ timeout } });
my $response = $astman->get_response( $actionid );
my $arrayref = $response->{CMD};
my @array = @$arrayref;
my $null = qq{};
my ( %faxstats, $section);
foreach my $line ( @array ) {
next if ( ( ! $line ) || ( $line =~ /-----------/ ) );
my ( $key, $value ) = split( ':', $line );
$section = $key if ( $value eq $null );
$key =~ s/\s+$//g;
$value =~ s/^\s+//g;
#$faxstats{ "$key" } = $value if ( $value ne $null );
$faxstats{ "$section" }{ "$key" } = $value if ( $value ne $null );
};
$astman->disconnect;
return( %faxstats );
};