Skip Menu |

This queue is for tickets about the Nagios-Status-Service CPAN distribution.

Report information
The Basics
Id: 48903
Status: patched
Worked: 10 min
Priority: 0/
Queue: Nagios-Status-Service

People
Owner: RCROWDER [...] cpan.org
Requestors: Jeremy.Krieg [...] youramigo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Service status doesn't parse descriptions containing "="
Date: Fri, 21 Aug 2009 16:28:45 +0930
To: bug-Nagios-Status-Service [...] rt.cpan.org
From: "Krieg, Jeremy" <Jeremy.Krieg [...] youramigo.com>
Dear Mr Crowder, I am running a Nagios installation where some of our service status descriptions have "=" signs in them. This seems to break the parser in this module. Here is a proposed fix, which I have implemented locally: sub set_attribute { my ($self, $attr) = @_; if (!defined $attr) { return; } # if if ( $attr =~ /^\s*([^=]+)=(.*?\S)\s*$/ ) { $self->{attributes}->{$1} = $2; return 1; } return; } I also modified sub _populate to call this function, so as to avoid duplicated code: sub _populate { my ($self, $serv) = @_; my %attributes; my $found = 0; my $found_serv = 0; open(STATUS, $self->{status_log}) or croak "Cannot open status log file: $!"; print STDERR "Opened the status log file!\n"; while(my $line = <STATUS>) { if ($line =~ /^servicestatus\s*{/) { $found = 1; next; } # if if ($found and $line =~ /$serv/) { $found_serv = 1; } if ($found and $line =~ /}/) { if ($found_serv) { foreach (keys %attributes) { $self->{attributes}->{$_} = $attributes{$_}; } # foreach last; } else { %attributes = (); $found = 0; } # if/else } # if if (!$found) { next; } else { $self->set_attribute($line); } # if/else } # while close(STATUS); } # _populate I haven't added any tests to check for cases where = is part of a field value. I also removed the "return undef", replacing it with a simple "return". (This is in accordance with the recommendations of the Perl Best Practices guide.) Regards, ------------------------- Jeremy Krieg System Administrator/Senior Software Engineer YourAmigo Ltd. Phone: +61 (0) 8 8211 9211 IMPORTANT - This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information in which case neither is intended to be waived. YourAmigo retains ownership of all copyright, trade secrets and other intellectual property rights in the email and attachments. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify us and remove it from your system. It is your responsibility to check any attachments for viruses and defects before opening or sending them on. YourAmigo collects personal information to provide and market our services. For more information about use, disclosure and access, see our privacy policy at http://www.youramigo.com
Thank you for sending in this patch and alerting me to the error. I have patched the module and it is uploaded to PAUSE. It should propagate through the system and be available very soon. Thanks again, Roy Crowder (rcrowder@cpan.org)