From f7ebe6833dffa2313f9b233ab4f10868ea957461 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 10 Aug 2019 14:05:08 -0400 Subject: [PATCH] asterisk: turn output into debug-only lines I apparently forgot to clear out two lines of debugging output from the script before submitting a pull request. Those lines of output are super useful for debugging whenever things are not working as expected (e.g. asterisk has changed its output). So it'll be more productive to keep them around but only output them if MUNIN_DEBUG is set. --- plugins/asterisk/asterisk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/asterisk/asterisk b/plugins/asterisk/asterisk index 5c28a6df..798f9aee 100755 --- a/plugins/asterisk/asterisk +++ b/plugins/asterisk/asterisk @@ -88,17 +88,19 @@ sub asterisk_command { # Response: (Error|Follows|Success) $line = $socket->getline; if ($line !~ /^Response: Success\r?\n$/) { - while ( $line = $socket->getline and $line !~ /^\r?\n$/ ) {} + while ( $line = $socket->getline and $line !~ /^\r?\n$/ ) { + print STDERR "COMMAND: Ignoring unwanted line: $line" if $Munin::Plugin::DEBUG; + } return undef; } # Message: Command output follows $line = $socket->getline; - print STDERR "Command: got response: $line\n"; + print STDERR "COMMAND got response: $line" if $Munin::Plugin::DEBUG; # Until we get the --END COMMAND-- marker, it's the command's output. while ( $line = $socket->getline and $line =~ /^Output:/ ) { - print STDERR "Command: got response: $line\n"; + print STDERR "COMMAND: got response: $line" if $Munin::Plugin::DEBUG; # Don't keep the "Output: " part of the response substr($line, 0, 8, ''); $reply .= $line;