CDEF : MAX - MIN ????

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

Moderators: Developers, Moderators

chad
Posts: 2
Joined: Thu Aug 06, 2009 9:21 am

CDEF : MAX - MIN ????

Post by chad »

Hi,

I just want to create a cdef stuff to display (with GPRINT) the difference between the max value of a DS and the MIN value of the same DS on a graph.

I tried with :

Item 1# special data source: CURRENT_DS_MAX_VALUE
Item 2# special data source: CURRENT_DS_MIN_VALUE
Item 3# Operator: -

but it doesnt seem to work : ERROR: rpn expressions without DEF or CDEF variables are not supported

Does anyone know how to do what I want ?

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

Post by gandalf »

those "variables" are cacti internal only and will be replaced by numbers at runtime. That's why rrdtool complains about missing defs. You may want to append sth like "a,+,a,-" or anything that results in "NOP" and contains at least one DEF variable
Reinhard
chad
Posts: 2
Joined: Thu Aug 06, 2009 9:21 am

Post by chad »

Hi,

Thx for your help :)

When I try "a,+,a,-" I have the following error : ERROR: RPN stack underflow

Is there some documentation somewhere about those cdefs stuffs ?

Thx in advance
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Did you _append_ it to the maths given above?
Please see http://docs.cacti.net/manual:087:6_refe ... cdef#cdefs for docs
Reinhard
refractor
Posts: 8
Joined: Mon Apr 16, 2012 6:11 am
Location: Vienna/Austria

Re: CDEF : MAX - MIN ????

Post by refractor »

I'm also loooking for a nearly exact solution, but it won't work.

I want to calculate the value of LAST-MIN= and GPRINT the result.
The docs you've posted are very interesting, but I haven't found any way to calculate/get the MIN-Value for my calculation.

I've tried the following to calculate MAX-MIN (Wich is also OK for me, because in 99,999% of all cases LAST=MAX because the value is always increasing)
Did you _append_ it to the maths given above?

Code: Select all

Item 1# special data source: CURRENT_DS_MAX_VALUE 
Item 2# special data source: CURRENT_DS_MIN_VALUE 
Item 3# Operator: - 
Item 4# Custom String: a
Item 5# Operator: +
Item 6# Custom String: a
Item 7# Operator: -
but this results in "0", what was predictable.

Any ideas woud be very useful :) Thanks!
Regards,
Thomas
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: CDEF : MAX - MIN ????

Post by gandalf »

Well, let's go this way:
A CDEF at least needs the reference to a single DEF, let's take def = a for that.
In the case given, you don't really NEED that DEF, it's required only to satisfy rrdtool requirements. So far, the CDEF should look like

Code: Select all

CDEF=a,a,-
(This differs from the notation above, but this math still yields the result "0").

Now you add what you really need, e.g.

Code: Select all

CURRENT_DS_MAX_VALUE ,CURRENT_DS_MIN_VALUE,- 
which makes all in all

Code: Select all

CDEF=a,a,-,CURRENT_DS_MAX_VALUE ,CURRENT_DS_MIN_VALUE,- 
R.
refractor
Posts: 8
Joined: Mon Apr 16, 2012 6:11 am
Location: Vienna/Austria

Re: CDEF : MAX - MIN ????

Post by refractor »

Hi Reinhard,

thanks for your fast relpy!
Ah ok, I understand the meaning of the "a"!

I've tested your code, but maybe I've made some not quite correct, because it won't wok:

Code: Select all

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=1334574279 \
--end=1334660679 \
--title='WBB3 - Registered Members' \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale \
COMMENT:"From 16/04/2012 13\:04\:39 To 17/04/2012 13\:04\:39\c" \
COMMENT:"  \n" \
--vertical-label='Reg. Members' \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:9: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/wbb3_members_299.rrd":"members":AVERAGE \
CDEF:cdefc='a,a,-,0,0,-' \
CDEF:cdefd='LTIME,604800,%,172800,GT,LTIME,604800,%,345600,LT,INF,UNKN,a,*,IF,UNKN,a,*,IF' \
LINE2:a#55D6D3FF:"Registered Members"  \
GPRINT:a:LAST:"%8.0lf"  \
GPRINT:cdefc:LAST:"Trend\:%8.0lf\n"  \
LINE2:cdefd#750F7DFF:"" 
I think that

Code: Select all

CDEF:cdefc='a,a,-,0,0,-' \
is the Problem, CURRENT_DS_MAX_VALUE/CURRENT_DS_MIN_VALUE seems to be 0! But why? Do I have to Re-Create the Graph?

Code: Select all

GPRINT:cdefc:LAST:"Trend\:%8.0lf\n"  \
Ive also switched to CF AVERAGE, MIN and MAX, but I think thats not the problem, isn't it?

RRDtool says

Code: Select all

ERROR: RPN final stack size != 1
Regards,
Thomas
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: CDEF : MAX - MIN ????

Post by gandalf »

As the magic Cacti variable refer to current data source, it does matter which data source is related to the graph item where you're using this new CDEF. In case you didn't select any data source, the values will always be 0
R.
refractor
Posts: 8
Joined: Mon Apr 16, 2012 6:11 am
Location: Vienna/Austria

Re: CDEF : MAX - MIN ????

Post by refractor »

OK, it seems I've done something wrong. I've selected a Data Source (at least I believe that I have set it correct) (see att.)

So I set the Data source to "none" (the cacti output isn't changing) and back to the correct one (the cacti output isn't changing again) - It seems that Cacti is ignoring this Setting, but why?
Attachments
Template.JPG
Template.JPG (69.33 KiB) Viewed 4241 times
Regards,
Thomas
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: CDEF : MAX - MIN ????

Post by gandalf »

Oops, that's bad. The theory says, it should work. So I have to debug this. Please tell me your Cacti version
R.
refractor
Posts: 8
Joined: Mon Apr 16, 2012 6:11 am
Location: Vienna/Austria

Re: CDEF : MAX - MIN ????

Post by refractor »

OK, no problem!
I've updated a few days ago to 0.8.8.
Regards,
Thomas
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: CDEF : MAX - MIN ????

Post by gandalf »

Give me some time, then. I'm away from my dev system 'til weekend
R.
refractor
Posts: 8
Joined: Mon Apr 16, 2012 6:11 am
Location: Vienna/Austria

Re: CDEF : MAX - MIN ????

Post by refractor »

No Problem :) Thanks in Advance!
Regards,
Thomas
jocvtrhythgd
Posts: 5
Joined: Mon Apr 23, 2012 8:55 pm

Re: CDEF : MAX - MIN ????

Post by jocvtrhythgd »

So I have to debug this. Please tell me your Cacti version
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: CDEF : MAX - MIN ????

Post by gandalf »

gandalf wrote:

Code: Select all

CDEF=a,a,-,CURRENT_DS_MAX_VALUE ,CURRENT_DS_MIN_VALUE,- 
That's wrong, sorry. It should read

Code: Select all

CDEF=a,a,-,CURRENT_DS_MAX_VALUE ,CURRENT_DS_MIN_VALUE,-,+ 
The last operator was missing, sorry
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests