Why GAUGE of int values is a float?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

art79
Posts: 11
Joined: Mon Aug 17, 2009 3:05 pm

Why GAUGE of int values is a float?

Post by art79 »

Hi there

I thought that if my input method script produces only integers and my data template describes field as GAUGE it would be always integer on the graph.

Am i wrong? i thought that GAUGE is not averaged in any way over time, or is it?

- My script does cast to integer so im sure values are only ints.
- My data template describes fields as ints as well.
- I gather every 60 seconds and failure threshold is set to 300 seconds.

And my graph looks like this attached image.

What am i doing wrong?

THANKS A MILLION!!!!
Attachments
non_int.jpg
non_int.jpg (70.55 KiB) Viewed 15452 times
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

All looks good except the keep alive data item. Please post a graph debug and data source debug outputs for that. Also an 'rrdtool info filename.rrd' output.
engeishi
Cacti User
Posts: 75
Joined: Sun Aug 23, 2009 12:03 pm
Location: Tokyo, Japan

Post by engeishi »

This happens because of specification of RRDtool.

In many case, The data collection is not performed according to the interval defined .
For example, there are a lot of devices to poll, it will take some time the script returns the result, and so on.
The data collection interval tends to become longer than the defined interval.

RRDtool corrects data to become a defined interval when the graph drawing.
Refer to the attached figure.

P.S. Sorry for my broken English. English is not my native language.
Attachments
rrdtool_data_correction.png
rrdtool_data_correction.png (27.79 KiB) Viewed 15417 times
art79
Posts: 11
Joined: Mon Aug 17, 2009 3:05 pm

THANKS

Post by art79 »

Wow! thats really cool answer.

That would explain everything :- )

Thanks a million!
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

engeishi wrote:This happens because of specification of RRDtool.

In many case, The data collection is not performed according to the interval defined .
For example, there are a lot of devices to poll, it will take some time the script returns the result, and so on.
The data collection interval tends to become longer than the defined interval.

RRDtool corrects data to become a defined interval when the graph drawing.
Refer to the attached figure.

P.S. Sorry for my broken English. English is not my native language.
That is indeed not only correct but well explained! I'd like to put this into cacti documentation; is this ok for you?
Reinhard
engeishi
Cacti User
Posts: 75
Joined: Sun Aug 23, 2009 12:03 pm
Location: Tokyo, Japan

Post by engeishi »

Of course, Yes!
it is very happy for me to contribute to the community.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please see the result at http://docs.cacti.net/manual:087:8_rrdt ... n_integers
If you see improvements of the text, please let me know
Reinhard
engeishi
Cacti User
Posts: 75
Joined: Sun Aug 23, 2009 12:03 pm
Location: Tokyo, Japan

Post by engeishi »

Awesome work!
Good example makes easy to understand the concept.
Thank you.
User avatar
schurzi
Posts: 42
Joined: Sat Oct 11, 2008 8:45 am
Location: Germany
Contact:

Post by schurzi »

I had the same problem with integers which were displayed als float values. I used a CDEF to round them to integers again.

The CDEF is:
CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,FLOOR,-,0.5,-,CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,FLOOR,-,0.5,-,ABS,+,CURRENT_DATA_SOURCE,CEIL,CURRENT_DATA_SOURCE,FLOOR,IF

The long equation is because RRDTool does not know a round function. So I had to extract the fraction part of the value and then use FLOOR and CEIL to round either up or down.

From looking at my Graphs this would solve the visualization problems of this RRDTool "feature".
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
mgupta
Posts: 16
Joined: Thu Aug 13, 2009 4:29 pm
Location: Canada

Post by mgupta »

[quote="schurzi"]I had the same problem with integers which were displayed als float values. I used a CDEF to round them to integers again.

The CDEF is:
CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,FLOOR,-,0.5,-,CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,FLOOR,-,0.5,-,ABS,+,CURRENT_DATA_SOURCE,CEIL,CURRENT_DATA_SOURCE,FLOOR,IF

The long equation is because RRDTool does not know a round function. So I had to extract the fraction part of the value and then use FLOOR and CEIL to round either up or down.

From looking at my Graphs this would solve the visualization problems of this RRDTool "feature".[/quote]

This is a very dumb question. ABS mentioned above is Absolute Value correct? I don't see a pre-defined CDEF for it.
User avatar
schurzi
Posts: 42
Joined: Sat Oct 11, 2008 8:45 am
Location: Germany
Contact:

Post by schurzi »

mgupta wrote:This is a very dumb question. ABS mentioned above is Absolute Value correct? I don't see a pre-defined CDEF for it.
Exactly, ABS is for Absolute Vaule. It is a standard RRDTool function.

Maybe to explain the CDEF:

For example, RRDTool generates the Value 3.6:

CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,FLOOR,-,
0.5,-,

3.6 - 3
0.6 - 0.5
=
0.1

CURRENT_DATA_SOURCE, CURRENT_DATA_SOURCE,FLOOR,-,
0.5,-,


3.6 - 3
0.6 - 0.5
=
0.1

ABS,+

0.1 + ABS(0.1)
=
0.2

CURRENT_DATA_SOURCE,CEIL

3.6 = 4

CURRENT_DATA_SOURCE,FLOOR

3.6 = 3

IF

The if looks at 0.2, if it is non 0 the Value from CEIL is returned, if it is 0 the Value from Floor is returned.

For 3.4 it looks that way:

3.4 - 3
0.4 - 0.5
= -0.1

-0.1 + ABS(-0.1)
= 0

...
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
mgupta
Posts: 16
Joined: Thu Aug 13, 2009 4:29 pm
Location: Canada

Post by mgupta »

Thanks!
User avatar
smlick
Cacti User
Posts: 267
Joined: Tue May 20, 2008 4:09 am
Location: Italy, Rome

Re: Why GAUGE of int values is a float?

Post by smlick »

I understand why the system produce a non integer value but I didn't understand how to solve it.
For example I made a graph with SNMP generic OID for Asterisk to graph current calls but sometimes the value is not integer, how to solve?
Can you explain with simple words :) or with some screenshot?

Regards
Alessio
Cacti Version 0.8.8c production / 0.8.8c test W2008 -- Plugin:Weathermap - Monitor - CAMM 1.6.7 :) - Nectar - GPS Map
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Why GAUGE of int values is a float?

Post by gandalf »

You can't "solve" this.
See e.g. 1st link of my sig, RRDTool chapter for more help in case the picture from above is not enough.
But you can cut off fractional part by using a GPRINT preset
R.
User avatar
smlick
Cacti User
Posts: 267
Joined: Tue May 20, 2008 4:09 am
Location: Italy, Rome

Re: Why GAUGE of int values is a float?

Post by smlick »

But shurzi did it!!!! Some post before, but I didn't understand well how to set CDEF.
schurzi wrote:I had the same problem with integers which were displayed als float values. I used a CDEF to round them to integers again.

The CDEF is:
CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,FLOOR,-,0.5,-,CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,FLOOR,-,0.5,-,ABS,+,CURRENT_DATA_SOURCE,CEIL,CURRENT_DATA_SOURCE,FLOOR,IF
.


Regards
Alessio
Cacti Version 0.8.8c production / 0.8.8c test W2008 -- Plugin:Weathermap - Monitor - CAMM 1.6.7 :) - Nectar - GPS Map
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests