mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
36 lines
1.2 KiB
Perl
36 lines
1.2 KiB
Perl
|
|
||
|
|
||
|
|
||
|
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 );
|
||
|
|
||
|
};
|
||
|
|