Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-10343

bcdiv(): Division by zero [chart.php:126

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 2.4.7
    • Frontend (F)

      I'm creating a stacked graph (20 items) with a maximum summed value of 1.1780625038049E+15 (bytes).

      The error I get is:
      ERROR: Y axis MAX value must be greater than Y axis MIN value
      bcdiv(): Division by zero [chart.php:126 → ClineGraphDraw->draw() → bcdiv() in /usr/share/zabbix/include/classes/graphdraw/CLineGraphDraw.php:2364

      It seems that the bcmath functions do not handle scientifically notated strings properly (or at all). Evidence: http://stackoverflow.com/questions/21886257/bcdiv-using-very-small-float-with-scientific-notation-cause-division-by-zero-e

      I hacked myself a solution: if I detect a value in scientific notation, use sprintf to convert it to "unscientific" notation. You will probably construct a better and more permanent solution.

      [root@zbx01 ~]# diff -u /usr/share/zabbix/include/classes/graphdraw/CLineGraphDraw.php{-dd20160203BD,}
      --- /usr/share/zabbix/include/classes/graphdraw/CLineGraphDraw.php-dd20160203BD	2015-11-12 11:12:33.000000000 +0100
      +++ /usr/share/zabbix/include/classes/graphdraw/CLineGraphDraw.php	2016-02-03 13:58:31.390193635 +0100
      @@ -684,7 +684,12 @@
       					continue;
       				}
       
      -				$val[$ci] = bcadd($shift_val[$ci], $val[$ci]);
      +				if (preg_match ('/^[+-]?(\d*\.)?\d+[eE][+-]?\d+$/', $shift_val[$ci])) {
      +					$val[$ci] = bcadd(sprintf('%f', $shift_val[$ci]), $val[$ci]);
      +				}
      +				else {
      +					$val[$ci] = bcadd($shift_val[$ci], $val[$ci]);
      +				}
       			}
       
       			if (!isset($maxY)) {
      

            Unassigned Unassigned
            Gammuts Bart Dopheide
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: