In need of assistance with function-coding

Hi all,

I use a function to retreive the relative humidity from an environmental probe. The read-out is in percentage, of which the range from 40-60 is OK, all the rest is not what we want..
The function looks like this: Relative Humidity Percentage and at this point in time I only use it to graph the returned values.

Available:
if(oid("1.3.6.1.4.1.3854.1.2.2.1.17.1.3.4")>0,1,-1)

Error:
if(oid("1.3.6.1.4.1.3854.1.2.2.1.17.1.3.4")>0,"","No problem")

Value:
oid("1.3.6.1.4.1.3854.1.2.2.1.17.1.3.4")

Unit:

%

Rate:
none

Now I want to (if possible) tune the function so that it changes state from up (or partially down) to down if the function gets values outside of the previous mentioned range. So, if it gets back a value of let's say 35% it's really down instead of OK, if the returned value is 45% it's stating OK and it's up.
When I'm able to do something similar with the existing function for temperature readings (the 17 in the OID changes into 16), then combine these two functions, then The Dude should be able to let a device really go down when both functions fail and when only one is down, the device should change it's state to partially down. With the current function I don't have a clue what I've to change to tell the function which values are OK and which aren't. Therefore I'm unable to reach a totally down state and am overwhelmed with a lot of partially down states, which is just not quite enough for me..

Since I'm not a hero with functions etc I would really appreciate any help/answer given by one of you guys, if even it would be a solid NO with an explanation why it won't work..

Thanks in advance and regards,
Minollie

Hello anyone there?

I’m still having problems with this.. (not to say I’m frustrated I can’t get it to work.. :frowning: ). Somebody willing to help?

Regards,
Minollie

To check if value is in specific range you can use this in Probes ‘Error’
field:

if(or(oid(“1.3.6.1.4.1.3854.1.2.2.1.17.1.3.4”) < 40,
oid(“1.3.6.1.4.1.3854.1.2.2.1.17.1.3.4”) > 60), concatenate("humidity out of
range ", oid(“1.3.6.1.4.1.3854.1.2.2.1.17.1.3.4”)), “”)

in case oid is smaller than 40 or bigger than 60 service will be down, and
problem description would be ‘humidity out of range 95’ or similar.

Hi Uldis,

In advance thanks for helping me.. Now the bad news..
It’s not doing what I (and presumably you too..) was thinking it would do.

Using your code (little adjusted ofcourse):
a RH of 27 % here, results in an OK from this probe (function).
a RH of 45 % here, results in an OK and so does a RH 65%.

This is also displayed within the services tab of a device, the flag remains green..

The following function (x on the end is the port/instance of the OID):

if(or(oid(“1.3.6.1.4.1.3854.1.2.2.1.17.1.3.x”)<40,oid(“1.3.6.1.4.1.3854.1.2.2.1.17.1.3.x”)>60),concatenate(“Relative Humidity out of range. Current percentage = “,oid(“1.3.6.1.4.1.3854.1.2.2.1.17.1.3.x”)),””)

seems always to result in an OK which is not the result I exspect.. (even though the logic behind it, appears to be OK in my human eyes.. :wink:).

Is it an idea to create a function that looks if the value is within the specified range rather than if the value is outside of that range?
That would mean (in my brain at least) that you’ve to check if the returned value is >= 40 AND <= 60. I’ve tried to replace OR in the function with AND but that doesn’t do the trick..
Question (for me) remains how to code that in the function..
Could/would you help me? :wink:

Regards,
Minollie

thank you for your input, there was a bug that made
functions ‘and’, ‘or’, ‘not’ return wrong results.

Hi Uldis,

OK, if I understand you correctly there is a bug in the current version of the Dude (2.0) which prevent functions ‘or/and/not’ to return correct results?

If so, is there a solution pending for this bug? Or is a new Dude version imminent to see the light in which this (and some other bugs) is solved?

Could you please tell me if the function should be like your first one, or that it should be different? In the last case, please provide me with it :wink:

Regards,
Minollie

Yes, bug is fixed, everything should work as soon as you install new version
which is going out soon.

Hi Uldis!

Great news that the bug is fixed and resolved within the new version of The Dude!! Thanks in advance..

Looking forward to the release date of the new version which is when actually? :wink:

Regards,
Minollie