Announcement

Collapse
No announcement yet.

Division by zero in ...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Division by zero in ...

    I am getting snmp-memory info from my hosts usung the /usr/nagios/linexec/snmp_mem.pl script. All data appears in my perfparse DB as expected:

    Code:
    mysql> select * from perfdata_service_bin where host_name="ldap.bart.nl" and service_description="snmpMemory";
    +------+-------------------+---------------------+-----------+---------------------+--------+--------+----------+-------+
    | id   | host_name         | service_description | metric    | ctime               | value  | warn   | critical | state |
    +------+-------------------+---------------------+-----------+---------------------+--------+--------+----------+-------+
    | 1325 | ldap.bart.nl | snmpMemory          | ram_used  | 2006-11-13 21:35:30 | 125308 | 129761 |   131072 |     0 |
    | 1326 | ldap.bart.nl | snmpMemory          | swap_used | 2006-11-13 21:35:30 |   8232 | 196602 |   222816 |     0 |
    | 1363 | ldap.bart.nl | snmpMemory          | ram_used  | 2006-11-13 21:39:51 | 125308 | 131072 |   131072 |     0 |
    | 1364 | ldap.bart.nl | snmpMemory          | swap_used | 2006-11-13 21:39:51 |   8232 | 196602 |   222816 |     0 |
    | 1387 | ldap.bart.nl | snmpMemory          | ram_used  | 2006-11-13 21:42:51 | 125448 | 131072 |   131072 |     0 |
    | 1388 | ldap.bart.nl | snmpMemory          | swap_used | 2006-11-13 21:42:51 |   8232 | 196602 |   222816 |     0 |
    | 1417 | ldap.bart.nl | snmpMemory          | ram_used  | 2006-11-13 21:45:51 | 125448 | 131072 |   131072 |     0 |
    | 1418 | ldap.bart.nl | snmpMemory          | swap_used | 2006-11-13 21:45:51 |   8232 | 196602 |   222816 |     0 |
    | 1443 | ldap.bart.nl | snmpMemory          | ram_used  | 2006-11-13 21:48:51 | 125448 | 131072 |   131072 |     0 |
    | 1444 | ldap.bart.nl | snmpMemory          | swap_used | 2006-11-13 21:48:51 |   8232 | 196602 |   222816 |     0 |
    | 1471 | ldap.bart.nl | snmpMemory          | ram_used  | 2006-11-13 21:51:51 | 125588 | 131072 |   131072 |     0 |
    | 1472 | ldap.bart.nl | snmpMemory          | swap_used | 2006-11-13 21:51:51 |   8232 | 196602 |   222816 |     0 |
    | 1495 | ldap.bart.nl | snmpMemory          | ram_used  | 2006-11-13 21:54:51 | 125588 | 131072 |   131072 |     0 |
    | 1496 | ldap.bart.nl | snmpMemory          | swap_used | 2006-11-13 21:54:51 |   8232 | 196602 |   222816 |     0 |
    +------+-------------------+---------------------+-----------+---------------------+--------+--------+----------+-------+
    14 rows in set (0.00 sec)
    This look good I think..

    However, if I go to Monitorring -> service detail and click on the graph-icon for the memory usage, I always get:

    Code:
    Warning: Division by zero in /usr/local/oreon/www/include/views/graphs/simpleRenderer/simpleRenderer.php on line 303
    
    Warning: Division by zero in /usr/local/oreon/www/include/views/graphs/simpleRenderer/simpleRenderer.php on line 303
    
    Warning: Division by zero in /usr/local/oreon/www/include/views/graphs/simpleRenderer/simpleRenderer.php on line 303
    One line for every entry in the database..

    Since the data looks good for me, I have no idea where this error comes from.. any suggestions??

    Thing is that there is still no graph

  • #2
    yes I have juste find this bug today.

    juste add befor the foreach in this file at line ~ 295:

    Code:
    				if (isset($_GET["step"]) && $_GET["step"] == 0)
    					$_GET["step"] = 1;
    I would be better.[/code]
    Julien Mathis
    Centreon Project Leader
    www.merethis.com |

    Comment


    • #3
      Not completely sure, but my code looks like this now:

      Code:
      #####################################################################
      286                                 # Mise en memoire des valeurs remontees de la base de donnees MySQL
      287                                 # Init Lower Value
      288                                 $time_start_mysql = microtime_float();
      289                                 $GMT = 0;
      290                                 $lower = 0;
      291                                 $tab_bin = array();
      292                                 if (isset($_GET["step"]) && $_GET["step"] == 0)
      293                                         $_GET["step"] = 1;
      294                                 foreach ($ppMetrics as $key => $value){
      295                                         $get =  "SELECT SQL_BIG_RESULT HIGH_PRIORITY value,ctime FROM `perfdata_service_bin` WHERE `host_name` = '".$ret["host_name"]."' ".
      296                                                         "AND `service_description` = '".$ret["service_description"]."' AND `metric` = '".$value["metric"]."' ".
      297                                                         "AND `ctime` >= '".date("Y-m-d G:i:s", $start)."' AND `ctime` <= '".date("Y-m-d G:i:s", $end)."' ORDER BY ctime";
      298                                         $req =& $pearDBpp->query($get);
      299                                         if (PEAR::isError($pearDBpp))
      300                                                 print "Mysql Error : ".$pearDBpp->getMessage();
      301                                         $r = $str = NULL;
      302                                         for ($cpt = 0,$cpt_real = 0;$r =& $req->fetchRow();$cpt++){
      303                                                 preg_match("/^([0-9]*)-([0-9]*)-([0-9]*) ([0-9]*):([0-9]*):([0-9]*)/", $r["ctime"], $matches);
      304                                                 $time_temp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1], 1);
      305                                 if ((isset($ret["step"]) && $ret["step"] == "1") || (isset($ret["step"]) && ($cpt % $ret["step"] == 0)) || (!isset($ret["step"]))){
      306                                                         $tab_bin[$time_temp + (3600 * $GMT)][$value["metric"]] = $r["value"];
      307                                                         $cpt_real++;
      308                                                 }
      309                                         }
      310                                         $cpt_total_values += $cpt;
      311                                         $cpt_total_graphed_values += $cpt_real;
      312                                 }
      The lines you pointed are are line 292-293

      But still the same error, only now it's on line 305

      Code:
      Warning: Division by zero in /usr/local/oreon/www/include/views/graphs/simpleRenderer/simpleRenderer.php on line 305
      Did I understand your solution?

      Comment


      • #4
        I created a bug-report for this:

        http://bugs.oreon-project.org/?do=details&id=270

        Comment

        Working...
        X