@@ -584,8 +584,19 @@ sub _check_inventory {
584
584
}
585
585
586
586
my $t1 = [gettimeofday];
587
+ my ($checks , $checks_num , $hst , $hostobj );
587
588
588
- my ($checks , $checks_num , $hst , $hostobj ) = _get_checks($c , $hostname , $opt , 1);
589
+ eval {
590
+ ($checks , $checks_num , $hst , $hostobj ) = _get_checks($c , $hostname , $opt , 1);
591
+ };
592
+ my $err = $@ ;
593
+ if ($err ) {
594
+ _debug(" inventory failed: %s " , $err );
595
+ $err =~ s / ^UNKNOWN\ \-\ // gmx ;
596
+ $err =~ s /\s +at\s +.*?\. pm\s +line\s +\d +\. // gmx ;
597
+ $err =~ s / ("https?:\/\/ .*?)\/ [^"]*"/ $1 \/ ..."/ gmx ;
598
+ return (sprintf (" UNKNOWN - %s " , $err ), 3);
599
+ }
589
600
return (sprintf (" UNKNOWN - no host found with enabled agent and name: %s \n " , $hostname ), 3) unless $hst ;
590
601
return (sprintf (" UNKNOWN - no host found by name: %s \n " , $hostname ), 3) unless $hostobj ;
591
602
@@ -720,7 +731,7 @@ sub _get_checks {
720
731
my ($inv , $err ) = Thruk::Utils::Agents::update_inventory($c , $hostname , $hostobj , $data );
721
732
die ($err ) if $err ;
722
733
} else {
723
- my $err = Thruk::Utils::Agents::scan_agent($c , $data );
734
+ my $err = Thruk::Utils::Agents::scan_agent($c , $data );
724
735
die ($err ) if $err ;
725
736
}
726
737
}
0 commit comments