Handle case with no current work master
authorJoey Schulze <joey@infodrom.org>
Wed, 1 Oct 2014 22:23:38 +0000 (00:23 +0200)
committerJoey Schulze <joey@infodrom.org>
Wed, 1 Oct 2014 22:23:38 +0000 (00:23 +0200)
check_infocon

index 83f0d54..a265033 100755 (executable)
@@ -76,15 +76,19 @@ my $sth = $dbh->prepare($sql);
 $sth->execute;
 my $row = $sth->fetchrow_hashref;
 
 $sth->execute;
 my $row = $sth->fetchrow_hashref;
 
-if ($row->{open} > $config->{crit}) {
+if ($row->{open} && $row->{open} > $config->{crit}) {
     printf "CRITICAL: %s - EUR %.2f (%.2fh)\n", $config->{customer}, $row->{open}, $row->{hours};
     exit $ERRORS{'CRITICAL'};
 }
 
     printf "CRITICAL: %s - EUR %.2f (%.2fh)\n", $config->{customer}, $row->{open}, $row->{hours};
     exit $ERRORS{'CRITICAL'};
 }
 
-if ($row->{open} > $config->{warn}) {
+if ($row->{open} && $row->{open} > $config->{warn}) {
     printf "WARNING: %s - EUR %.2f (%.2fh)\n", $config->{customer}, $row->{open}, $row->{hours};
     exit $ERRORS{'WARNING'};
 }
 
     printf "WARNING: %s - EUR %.2f (%.2fh)\n", $config->{customer}, $row->{open}, $row->{hours};
     exit $ERRORS{'WARNING'};
 }
 
-printf "OK: %s - EUR %.2f (%.2fh)\n", $config->{customer}, $row->{open}, $row->{hours};
+if (defined $row->{open} && defined $row->{hours}) {
+    printf "OK: %s - EUR %.2f (%.2fh)\n", $config->{customer}, $row->{open}, $row->{hours};
+} else {
+    printf "OK: %s - Nyms\n", $config->{customer};
+}
 exit $ERRORS{'OK'};
 exit $ERRORS{'OK'};