LP#1711194: avoid division by zero errors
[opensrf-equinox.git] / bin / opensrf-perl.pl.in
index 021f00e..40015e3 100755 (executable)
@@ -267,8 +267,12 @@ sub do_diagnostic {
                 my @drones = `pgrep -f "Drone \\[$svc\\]"`;
                 my $dcount = scalar(@drones);
                 my $dmax = $max_children_map{$svc};
-                $str .= "#drones=$dcount/$dmax ";
-                $str .= sprintf('%3d%%', (int(($dcount / $dmax) * 100)));
+                if (defined($dmax) && $dmax > 0) {
+                    $str .= "#drones=$dcount/$dmax ";
+                    $str .= sprintf('%3d%%', (int(($dcount / $dmax) * 100)));
+                } else {
+                    $str .= "#drones=$dcount";
+                }
                 msg($str);
                 msg("\tERR $svc has no running drones.") unless @drones;
             }