mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
asterisk: add support for showing the per-type breakdown of channels.
This makes it possible for a single graph to replace the two apache_channels and apache_channeltypes plugins.
This commit is contained in:
parent
fce7502342
commit
f5064c9398
1 changed files with 38 additions and 6 deletions
|
@ -5,6 +5,14 @@
|
||||||
|
|
||||||
asterisk - Multigraph-capable plugin to monitor Asterisk
|
asterisk - Multigraph-capable plugin to monitor Asterisk
|
||||||
|
|
||||||
|
=head1 NOTES
|
||||||
|
|
||||||
|
This plugin will produce multiple graphs showing:
|
||||||
|
|
||||||
|
- total number of active channels (replaces asterisk_channels),
|
||||||
|
together with breakdown of specific channel types (replaces
|
||||||
|
asterisk_channelstypes).
|
||||||
|
|
||||||
=head1 CONFIGURATION
|
=head1 CONFIGURATION
|
||||||
|
|
||||||
The following configuration parameters are used by this plugin
|
The following configuration parameters are used by this plugin
|
||||||
|
@ -14,6 +22,7 @@ The following configuration parameters are used by this plugin
|
||||||
env.port - port number to connect to
|
env.port - port number to connect to
|
||||||
env.username - username used for authentication
|
env.username - username used for authentication
|
||||||
env.secret - secret used for authentication
|
env.secret - secret used for authentication
|
||||||
|
env.channels - The channel types to look for
|
||||||
|
|
||||||
The "username" and "secret" parameters are mandatory, and have no
|
The "username" and "secret" parameters are mandatory, and have no
|
||||||
defaults.
|
defaults.
|
||||||
|
@ -23,6 +32,7 @@ defaults.
|
||||||
[asterisk]
|
[asterisk]
|
||||||
env.host 127.0.0.1
|
env.host 127.0.0.1
|
||||||
env.port 5038
|
env.port 5038
|
||||||
|
env.channels Zap IAX2 SIP
|
||||||
|
|
||||||
=head2 WILDCARD CONFIGURATION
|
=head2 WILDCARD CONFIGURATION
|
||||||
|
|
||||||
|
@ -75,6 +85,8 @@ my $peerport = $ENV{'port'} || '5038';
|
||||||
my $username = $ENV{'username'};
|
my $username = $ENV{'username'};
|
||||||
my $secret = $ENV{'secret'};
|
my $secret = $ENV{'secret'};
|
||||||
|
|
||||||
|
my @CHANNELS = exists $ENV{'channels'} ? split ' ',$ENV{'channels'} : qw(Zap IAX2 SIP);
|
||||||
|
|
||||||
my $line, my $error;
|
my $line, my $error;
|
||||||
my $socket = new IO::Socket::INET(PeerAddr => $peeraddr,
|
my $socket = new IO::Socket::INET(PeerAddr => $peeraddr,
|
||||||
PeerPort => $peerport,
|
PeerPort => $peerport,
|
||||||
|
@ -114,10 +126,16 @@ graph_title Asterisk active channels
|
||||||
graph_args --base 1000 -l 0
|
graph_args --base 1000 -l 0
|
||||||
graph_vlabel channels
|
graph_vlabel channels
|
||||||
graph_category asterisk
|
graph_category asterisk
|
||||||
channels.draw AREA
|
total.label channels
|
||||||
channels.label channels
|
|
||||||
END
|
END
|
||||||
|
|
||||||
|
foreach my $channel (@CHANNELS) {
|
||||||
|
print <<END;
|
||||||
|
$channel.draw AREASTACK
|
||||||
|
$channel.label $channel channels
|
||||||
|
END
|
||||||
|
}
|
||||||
|
|
||||||
unless ( ($ENV{MUNIN_CAP_DIRTYCONFIG} || 0) == 1 ) {
|
unless ( ($ENV{MUNIN_CAP_DIRTYCONFIG} || 0) == 1 ) {
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
@ -127,15 +145,29 @@ END
|
||||||
die $error unless $socket;
|
die $error unless $socket;
|
||||||
|
|
||||||
$socket->print("Action: command\nCommand: core show channels\n\n");
|
$socket->print("Action: command\nCommand: core show channels\n\n");
|
||||||
|
#Response: Follows
|
||||||
|
#Channel Location State Application(Data)
|
||||||
|
#Zap/pseudo-198641660 s@frompstn:1 Rsrvd (None)
|
||||||
|
#Zap/1-1 4@frompstn:1 Up MeetMe(5500)
|
||||||
|
#2 active channels
|
||||||
|
#1 active call
|
||||||
|
#--END COMMAND--
|
||||||
my $shown_channels = readreply $socket;
|
my $shown_channels = readreply $socket;
|
||||||
|
|
||||||
my $channels = 'U';
|
$socket->close();
|
||||||
$channels = $1 if $shown_channels =~ /\n([0-9]+) active channels/;
|
|
||||||
|
my $active_channels = 'U';
|
||||||
|
$active_channels = $1 if $shown_channels =~ /\n([0-9]+) active channels/;
|
||||||
|
|
||||||
print <<END;
|
print <<END;
|
||||||
|
|
||||||
multigraph asterisk_channels
|
multigraph asterisk_channels
|
||||||
channels.value $channels
|
total.value $active_channels
|
||||||
END
|
END
|
||||||
|
|
||||||
$socket->close();
|
my @channels_list = split(/\r\n/, $shown_channels);
|
||||||
|
foreach my $channel (@CHANNELS) {
|
||||||
|
print "$channel.value " .
|
||||||
|
scalar(grep(/^$channel\//, @channels_list))
|
||||||
|
. "\n";
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue