1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

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.
This commit is contained in:
Gabriel Filion 2019-08-10 14:05:08 -04:00 committed by Lars Kruse
parent 0ca0e78b9d
commit f7ebe6833d

View file

@ -88,17 +88,19 @@ sub asterisk_command {
# Response: (Error|Follows|Success) # Response: (Error|Follows|Success)
$line = $socket->getline; $line = $socket->getline;
if ($line !~ /^Response: Success\r?\n$/) { 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; return undef;
} }
# Message: Command output follows # Message: Command output follows
$line = $socket->getline; $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. # Until we get the --END COMMAND-- marker, it's the command's output.
while ( $line = $socket->getline and $line =~ /^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 # Don't keep the "Output: " part of the response
substr($line, 0, 8, ''); substr($line, 0, 8, '');
$reply .= $line; $reply .= $line;