Changeset 117de5423d008dc004459bff76cfcd44a3ab4068

Show
Ignore:
Timestamp:
04/23/10 20:07:07 (9 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1272053227 +0000
git-parent:

[adc0c32724b1112928ca8ad246ca3989aa6f4b5e]

git-author:
Mark Harrison <mark@omniti.com> 1272053227 +0000
Message:

Allow die in modules to return error messages.

Note that you should add "\n" to die messages in order to avoid having the
line number and filename included in the message.

git-svn-id: https://labs.omniti.com/resmon/branches/resmon2@313 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • resmon

    r7f12705 r117de54  
    115115            }; 
    116116            if($checkproblem) { 
    117                 $results->{metric} = { "message" => 
    118                     "Bad module or problem running handler code."}; 
    119                 if ($checkproblem eq "alarm\n") { 
    120                     $results->{metric} = { "message" => "Check timeout"}; 
    121                     Resmon::ExtComm::clean_up; 
     117                chomp $checkproblem; 
     118                $results->{metric} = { "error" => ["$checkproblem", "s"]}; 
     119                if ($checkproblem eq "alarm") { 
     120                    $results->{metric} = { "error" => ["Check timeout", "s"]}; 
    122121                } 
     122                Resmon::ExtComm::clean_up; 
    123123            } 
    124124            $status->store($module_name,$monitor_obj->{'check_name'}, $results); 
  • resources/testmod

    r11be783 r117de54  
    8888} 
    8989my $obj = $module->new($check_name, $kvs); 
    90 my $metrics = $obj->handler(); 
     90my $metrics; 
     91eval { $metrics = $obj->handler(); }; 
     92if ($@) { 
     93    chomp $@; 
     94    $metrics = { "error" => ["$@", "s"] }; 
     95
     96 
    9197print "$module $check_name\n\n"; 
    9298for my $k (sort keys %$metrics) {