From 66d48afbbb2f99ed10a0cb548fc681cbc3f5e482 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Sun, 6 Nov 2016 12:37:28 +0100 Subject: [PATCH] [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 --- plugins/asterisk/asterisk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/asterisk/asterisk b/plugins/asterisk/asterisk index 7a3c13ce..e6581e11 100755 --- a/plugins/asterisk/asterisk +++ b/plugins/asterisk/asterisk @@ -320,11 +320,12 @@ END } # 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); - my @iaxchannels = $iaxchannels_response ? split(/\r\n/, $iaxchannels_response) : (); + my @iaxchannels = $iaxchannels_response ? split(/\r\n|\n/, $iaxchannels_response) : (); pop(@iaxchannels); shift(@iaxchannels); + $i = 0; foreach my $sipchan (@sipchannels) { my $found = 0; my @fields = split ' ', $sipchan; @@ -346,6 +347,7 @@ END } } + $i = 0; foreach my $iaxchan (@iaxchannels) { my $found = 0; my @fields = split ' ', $iaxchan; @@ -354,7 +356,7 @@ END $unknown += 1; next; } - foreach my $codec (@CODECSX) { + foreach my $codec (@CODECS) { if ($fields[8] eq "$codec") { $results[$i] = $results[$i] + 1; $found = 1;