2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

[asterisk] fix codecs accounting (Closes: #699)

The following issues are fixed by lelutin:
* line ending matching does not match for lines that only use \n as
  line ending
* iteration is broken because the index for setting values in the
  codecs accounting array is never reset to 0 before new loops.
* iax channels don't use a codec hex value, but rather their names
  (sip still uses the hex values as far as I can see)

see https://github.com/munin-monitoring/contrib/issues/699
This commit is contained in:
Lars Kruse 2016-11-06 12:37:28 +01:00
parent 7724b4cd6f
commit 66d48afbbb

View File

@ -320,11 +320,12 @@ END
} }
# split the channels' listing and drop header and footnotes # split the channels' listing and drop header and footnotes
my @sipchannels = $sipchannels_response ? split(/\r\n/, $sipchannels_response) : (); my @sipchannels = $sipchannels_response ? split(/\r\n|\n/, $sipchannels_response) : ();
pop(@sipchannels); shift(@sipchannels); pop(@sipchannels); shift(@sipchannels);
my @iaxchannels = $iaxchannels_response ? split(/\r\n/, $iaxchannels_response) : (); my @iaxchannels = $iaxchannels_response ? split(/\r\n|\n/, $iaxchannels_response) : ();
pop(@iaxchannels); shift(@iaxchannels); pop(@iaxchannels); shift(@iaxchannels);
$i = 0;
foreach my $sipchan (@sipchannels) { foreach my $sipchan (@sipchannels) {
my $found = 0; my $found = 0;
my @fields = split ' ', $sipchan; my @fields = split ' ', $sipchan;
@ -346,6 +347,7 @@ END
} }
} }
$i = 0;
foreach my $iaxchan (@iaxchannels) { foreach my $iaxchan (@iaxchannels) {
my $found = 0; my $found = 0;
my @fields = split ' ', $iaxchan; my @fields = split ' ', $iaxchan;
@ -354,7 +356,7 @@ END
$unknown += 1; $unknown += 1;
next; next;
} }
foreach my $codec (@CODECSX) { foreach my $codec (@CODECS) {
if ($fields[8] eq "$codec") { if ($fields[8] eq "$codec") {
$results[$i] = $results[$i] + 1; $results[$i] = $results[$i] + 1;
$found = 1; $found = 1;