Ticket #2469 (closed Bugs: fixed)

Opened 6 years ago

Last modified 5 years ago

Warning: Division by zero (dashboard - loadavg)

Reported by: wookie Assigned to: gregmac
Priority: minor Milestone: 2.4
Component: FreePBX System Status Version: 2.3.1
Keywords: Cc:
Confirmation: Need testing Distro:
Backend Engine: All Distro Ver:
Backend Ver: SVN Revision (if applicable):

Description

I am getting this on a very quiet system:

Warning: Division by zero in /var/www/html/admin/modules/dashboard/phpsysinfo/class.Linux.inc.php on line 135

It seems when both cpu total values ($total2 and $total) are zero, the division by zero warning appears.

Change History

10/30/07 17:40:35 changed by p_lindheimer

  • confirmation changed from Unreviewed to Need testing.

can you try this patch:

Index: class.Linux.inc.php
===================================================================
--- class.Linux.inc.php (revision 5166)
+++ class.Linux.inc.php (working copy)
@@ -132,7 +132,7 @@
        sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae);
        $load2 = $ab + $ac + $ad;
        $total2 = $ab + $ac + $ad + $ae;
-       $results['cpupercent'] = (100*($load2 - $load)) / ($total2 - $total);
+       $results['cpupercent'] = ($total2 != $total)?((100*($load2 - $load)) / ($total2 - $total)):0;
       }
     }
     return $results;

11/23/07 21:31:11 changed by p_lindheimer

  • status changed from new to closed.
  • resolution set to fixed.

confirmed bug and tested fix on customer system.

r5271, r5273