Community discussions

MUM Europe 2020
 
Martin9700
just joined
Topic Author
Posts: 5
Joined: Fri Sep 18, 2009 6:01 pm

Uptime Probe

Thu Nov 05, 2009 11:15 pm

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: <blank>
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!
 
Morphology
just joined
Posts: 21
Joined: Mon Jan 26, 2009 7:51 pm

Re: Uptime Probe

Fri Nov 06, 2009 2:02 pm

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 <blank>

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.
 
Martin9700
just joined
Topic Author
Posts: 5
Joined: Fri Sep 18, 2009 6:01 pm

Re: Uptime Probe

Fri Nov 06, 2009 4:11 pm

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.
 
Martin9700
just joined
Topic Author
Posts: 5
Joined: Fri Sep 18, 2009 6:01 pm

Re: Uptime Probe

Fri Nov 06, 2009 4:30 pm

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........
 
Martin9700
just joined
Topic Author
Posts: 5
Joined: Fri Sep 18, 2009 6:01 pm

Re: Uptime Probe

Fri Nov 06, 2009 4:34 pm

And the more I think about this:

Value: if(array_element(ping(device_property("FirstAddress")), 1)=0, 0, 1)
 
User avatar
sady
Frequent Visitor
Frequent Visitor
Posts: 84
Joined: Fri Jul 11, 2008 11:30 am
Location: Russia

Re: Uptime Probe

Thu Nov 26, 2009 9:16 pm

why you can't use standart ping probe? you want to straight line graph of you up/down periods?
Please, please, Open Dude Source! Pleaaaaseeeee!!!!!
 
Martin9700
just joined
Topic Author
Posts: 5
Joined: Fri Sep 18, 2009 6:01 pm

Re: Uptime Probe

Mon Nov 30, 2009 4:12 pm

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).

Who is online

Users browsing this forum: Google [Bot] and 14 guests