Ad Widget

Collapse

Negative Numbers, Graphs, and Code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JoelG
    Member
    • Aug 2007
    • 32

    #1

    Negative Numbers, Graphs, and Code

    The good news - negative numbers are now supported.

    The bad news - default graphs don't seem to like them, as the graph y-axis ignores negative numbers, making them much less useful.

    Any suggestions on where to look to make the graphs use a meaningful set of default values for the y axis.
    ***UPDATE***
    It's the functions calculateMinY and calculateMaxY in graph.inc.php, but my math is weak, the code is not commented, and there is a lot of mantissa and exponent manipulation. A patch here would be very helpful!
    ***********

    Also, in the code, chart3.php, lines 46 and 47 are duplicates, one should be removed (yaxismax is duplicated).

    Code:
    	$fields=array(
    		"period"=>	array(T_ZBX_INT, O_OPT,	P_NZERO,	BETWEEN(ZBX_MIN_PERIOD,ZBX_MAX_PERIOD),	null),
    		"from"=>	array(T_ZBX_INT, O_OPT,	P_NZERO,	null,			null),
    		"stime"=>	array(T_ZBX_INT, O_OPT,	P_NZERO,	null,			null),
    		"border"=>	array(T_ZBX_INT, O_OPT,	P_NZERO,	IN('0,1'),		null),
    		"name"=>	array(T_ZBX_STR, O_OPT,	NULL,		null,			null),
    		"width"=>	array(T_ZBX_INT, O_OPT,	NULL,		BETWEEN(0,65535),	null),
    		"height"=>	array(T_ZBX_INT, O_OPT,	NULL,		BETWEEN(0,65535),	null),
    		"yaxistype"=>	array(T_ZBX_INT, O_OPT,	NULL,		IN("0,1"),		null),
    		"graphtype"=>	array(T_ZBX_INT, O_OPT,	NULL,		IN("0,1"),		null),
    		"yaxismin"=>	array(T_ZBX_DBL, O_OPT,	NULL,		BETWEEN(-65535,65535),	null),
    		"yaxismax"=>	array(T_ZBX_DBL, O_OPT,	NULL,		null,	null),
    		"yaxismax"=>	array(T_ZBX_DBL, O_OPT,	NULL,		null,	null),
    		"items"=>	array(T_ZBX_STR, O_OPT,	NULL,		null,			null)
    	);
    Last edited by JoelG; 22-08-2007, 18:04.
  • Aly
    ZABBIX developer
    • May 2007
    • 1126

    #2
    Could you attach an image with wrong graphs...?
    Zabbix | ex GUI developer

    Comment

    • JoelG
      Member
      • Aug 2007
      • 32

      #3
      Still wrong in 1.4.4

      Just took a look at this old thread.

      Version 1.4.4 has the same problem, this has not been fixed. I am running a patched version, so my graphs are working for my data set.

      A quick glance at the code referenced above will show that it is clipping at zero. This code is not ambiguous, as it has one of the few comments, here it is:

      Code:
      // Do not allow <0. However we may allow it, no problem.
      $minY = max(0,$minY);

      Comment

      • Aly
        ZABBIX developer
        • May 2007
        • 1126

        #4
        Negative values in graphs supported in pre v.1.6.
        Zabbix | ex GUI developer

        Comment

        • JoelG
          Member
          • Aug 2007
          • 32

          #5
          Small data range

          Clearly, this is not affecting many.

          For my data set, I usually see numbers in two ranges, -33.0 to -75.0, and temperature values in Celsius, so hopefully we don't see many approach -20.0.

          Comment

          • JoelG
            Member
            • Aug 2007
            • 32

            #6
            Something still wrong here

            I have just upgraded to 1.4.5, and negative numbers are STILL not supported in graphs.

            I will patch the code like I have done in previous releases, but my biggest concern is that the testing process is leaving this wide gap. How can you be sure that testing is complete and thorough when you never look at a graph with a negative number?

            Comment

            • Aly
              ZABBIX developer
              • May 2007
              • 1126

              #7
              It's not supported in v1.4.5, it's supported in v1.5.
              Zabbix | ex GUI developer

              Comment

              • JoelG
                Member
                • Aug 2007
                • 32

                #8
                I look forward to verifying this functionality in 1.5.

                Comment

                • fableman
                  Member
                  • Oct 2007
                  • 78

                  #9
                  I need support for negative numbers in graphs aswell..

                  Iam doding a trend graph's based on a given number. then negative numbers must be supported..

                  soo is it working in 1.5 ? (but I wont upgrade aslong its beta, soo I guess I wont be able to use it for some time then )

                  Comment

                  • fableman
                    Member
                    • Oct 2007
                    • 78

                    #10
                    I found a workaround..

                    I use a Fixed graph and min value: -100 and max: 100 then the graph will display negative numbers.

                    Comment

                    • JoelG
                      Member
                      • Aug 2007
                      • 32

                      #11
                      Simple Fix for limited data

                      Here is the code changes to function CalculateMinY in graph.inc.php

                      Code:
                          else {
                              $exp= 1.0; // change here
                              $mant=floor( $minY/9.5 ); // change here
                          }
                      
                          // below not needed
                          //	$mant=((round(($mant*11)/6)-1)*6)/10;
                          //	$mant=(floor($mant*1.1*10/6)+1)*6/10; /* MAX */
                      	
                          $minY = $mant*pow(10,$exp);
                      
                          // HERE IS PART OF THE PROBLEM
                          // Do not allow <0. However we may allow it, no problem.
                          //	$minY = max(0,$minY);
                      	
                          return $minY;
                          //  return 0;  // rest of the problem
                      This will work for a numbers greater then -99 for sure.

                      Comment

                      • tnt
                        Junior Member
                        • Jul 2008
                        • 15

                        #12
                        Originally posted by Aly
                        It's not supported in v1.4.5, it's supported in v1.5.
                        to aly:

                        hi, have 1.53 beta version, but graph from negative number dont works for me ...
                        i have snmpv1 devices (mikrotik OS) and signal is as negative number example: -61

                        when i create graph from: configuration -> graph -> create graph
                        and change y axis type: fixed - graph is OK (last screen)

                        where have i problem ?
                        can you help me, please ?

                        thanks

                        sorry for 4 attachments
                        date and time is bad on the screen
                        Attached Files
                        Last edited by tnt; 21-07-2008, 16:27.

                        Comment

                        • Aly
                          ZABBIX developer
                          • May 2007
                          • 1126

                          #13
                          Hard to tell.. because in my tests graphs are working correctly.
                          Attached Files
                          Zabbix | ex GUI developer

                          Comment

                          • tnt
                            Junior Member
                            • Jul 2008
                            • 15

                            #14
                            Originally posted by Aly
                            Hard to tell.. because in my tests graphs are working correctly.
                            hi aly,

                            i see, do you use negative and positive values in yuor graph.
                            i try this:
                            i create another item with positive values (cpu load from device mikrotik), and create graph.
                            i add only negative items to graph - graph is bad, but when then i add positive items with positive values graph is ok. i see positive and negative values in graph,
                            y axixs type: calculated

                            please, can you try create graph only from negative values ?
                            sorry for my call, i am new in zabbix ...
                            Attached Files
                            Last edited by tnt; 21-07-2008, 22:41.

                            Comment

                            • Aly
                              ZABBIX developer
                              • May 2007
                              • 1126

                              #15
                              Yes, you are correct, there is a problem with the only negative item. It'll be fixed in Zabbix 1.5.4
                              Zabbix | ex GUI developer

                              Comment

                              Working...