Changeset 3822

Show
Ignore:
Timestamp:
07/26/10 15:02:09 (2 years ago)
Author:
ligne
Message:

check the return from the open and print calls, and log errors if something went wrong.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/node/lib/Munin/Node/SpoolWriter.pm

    r3803 r3822  
    4848        # work out where to store the line 
    4949        if ($line =~ m/(?:\w+)\.value (?:[0-9]+:)?(?:-?[0-9.]+|U)/) { 
    50             # It's a data line 
    51             $fh = $fh_data ||= IO::File->new($self->{spooldir} . "/munin-daemon.$service.data", "a+"); 
    52  
    5350            # If the value line isn't timestamped 
    5451            # we have to add the timestamp on the line 
    5552            $line =~ s/(\w+)\.value (?!\d+:)(-?[0-9.]+|U)/$1.value $timestamp:$2/; 
    56         } else { 
     53 
     54            # It's a data line 
     55            $fh = $fh_data ||= IO::File->new($self->{spooldir} . "/munin-daemon.$service.data", "a+"); 
     56        } 
     57        else { 
    5758            # It's a config line 
    5859            $fh = $fh_config ||= IO::File->new($self->{spooldir} . "/munin-daemon.$service.config", "w"); 
    5960        } 
    6061 
    61         print {$fh} $line, "\n"; 
     62        unless ($fh) { 
     63            logger("Unable to open spool file: $!"); 
     64            return; 
     65        } 
     66 
     67        print {$fh} $line, "\n" or logger("Error writing results: $!"); 
    6268    } 
    6369