Uptime Probe

I’m trying to create a simple probe to monitor uptime. Either 1 for “up” or 0 for “down”.


Using a Probe:
Type: Function
Agent: default
Available: if(array_element(ping(“192.168.4.5”), 3)=“ok”, 1, -1)
Error: 0
Value: 1
Unit:
Rate: none

I just get a “down” probe all he time (Error field triggering). I’ve tried a few settings in “Available” like:

array_element(ping(“192.168.4.5”), 3)=“ok”

and

array_find(ping(“192.168.4.5”), “ok”)>0

But it always error’s out and runs that line. I’ve even pasted the code above into the error line so I could see if I was working off of the right fields and it looks like I am.

Any assistance would be appreciated!

The Ping function itself returns exactly the opposite of what you want (-1 if Ping Fails), so to graph the System Down Times you would create a probe with the following elements:

================

name: Is Up

Type: Function

Agent: default

Available: not(ping(device_property(“FirstAddress”)))

Error: “”

Value 1

unit

Rate: none

===============

I’ve used ping(device_property(“FirstAddress”)) rather than hard coded the IP address because you can then apply it to any device whose up time you want to graph.

By all means replace this with ping(“192.168.0.1”) or whatever.

Morph.

Hey Morph,

Unfortunately, that’s not working either. I put your code in the available (I did want to make it more generic eventually, I was just working on making it work first) and I still get the error line executing.

I wonder if the Available line can’t handle array’s, but the error line can. Maybe I’ll try a custom function that uses ping, but only returns one item.

Ah, now I’m starting to get it.

The ERROR line is what actually creates the data. And non-error must return “” to generate the VALUE line. So:

Err: if(array_element(ping(device_property(“FirstAddress”)), 1)=0,0,“”)
Value: 1

Light dawns on marble head…

And the more I think about this:

Value: if(array_element(ping(device_property(“FirstAddress”)), 1)=0, 0, 1)

why you can’t use standart ping probe? you want to straight line graph of you up/down periods?

Exactly, just a simple “up” or “down” return (1, 0).