CDEF "IF, then, else"

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

Moderators: Developers, Moderators

Post Reply
Cybernet1k
Posts: 7
Joined: Thu Jan 24, 2013 10:34 am

CDEF "IF, then, else"

Post by Cybernet1k »

Hello! I can not make a simple function:
If CURRENT_DATA_SOURCE = 4 then 1 else 0 .
In http://oss.oetiker.ch/rrdtool/tut/rpntutorial.en.html
..."2,20,200,IF" ("if 2 then 20 else 200") evaluates to 20. And "0,1,2,IF" ("if 0 then 1 else 2) evaluates to 2...
But in debug mode "cdef=4,1,0,IF": RRDTool Says: ERROR: rpn expressions without DEF or CDEF variables are not supported.

Please help...Need cdef : if CURRENT_DATA_SOURCE = 4 then 1 else 0 :(
victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Re: CDEF "IF, then, else"

Post by victorantunes »

you can't have a CDEF without variables

try:

CURRENT_DATA_SOURCE,POP,4,1,0,IF
Cybernet1k
Posts: 7
Joined: Thu Jan 24, 2013 10:34 am

Re: CDEF "IF, then, else"

Post by Cybernet1k »

victorantunes wrote:you can't have a CDEF without variables

try:

CURRENT_DATA_SOURCE,POP,4,1,0,IF
In this case, the graph value is only "1".
victorantunes
Cacti User
Posts: 111
Joined: Fri Sep 28, 2012 6:52 pm

Re: CDEF "IF, then, else"

Post by victorantunes »

And thats not what you wanted?
Cybernet1k
Posts: 7
Joined: Thu Jan 24, 2013 10:34 am

Re: CDEF "IF, then, else"

Post by Cybernet1k »

The device gives the SNMP values ​​from 1 to 5. I need to add cdef with a condition: If the current value is 4 then 1, else 0. For a start, used to do so: if current value used not 4 then 0. You are from Russia?
Cybernet1k
Posts: 7
Joined: Thu Jan 24, 2013 10:34 am

Re: CDEF "IF, then, else"

Post by Cybernet1k »

Understood ...
cdef=CURRENT_DATA_SOURCE,3,EQ,3,0,IF

Code: Select all

if (  CURRENT_DATA_SOURCE = 3 ) then
    value = 3
else
    value = 0
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest