Page 1 of 1

web scrape uptime

Posted: Wed Feb 04, 2015 4:23 pm
by Ierlandfan
I need to monitor the status of a VPN connection on a Draytek.
It has a web interface that shows the Uptime.
So what I want is scrape that web interface and monitor the uptime.
Step 1. with Web scraper. Done.

Step 2.
Let's say check is every 5 minutes.
So let's say first check uptime output is 0:05 (minutes) and next check outputs uptime is 0:10 (minutes) Then 1 (ok)
Imagine the VPN drops and reconnects so uptime is reset and the check returns 0:03 (minutes) Then 3 criticial!
Failsafe: Conection is lost, so no uptime. Then 3 critical!

How can I accomplish this?

Re: web scrape uptime

Posted: Wed Feb 04, 2015 4:47 pm
by slansing
So, you want anything past 5 minutes to be okay, but anything less to be critical? If not please elaborate a bit more. Can you also share the command you are running?

Re: web scrape uptime

Posted: Wed Feb 04, 2015 6:19 pm
by Ierlandfan
Example Draytek Vigor outer (2920n) (check is every five minutes)

Let's say:

Last check output was Uptime:1:00:00
Current check outputs is Uptime:1:05:00
Good output because Uptime has increased!

Now a bad (Unfortunately real) situation
Last check output was Uptime:1:00:00
Current check outputs is Uptime:0:05:00
Bad output because Uptime decreased.

The command I use now is uhmm..my eyes.
I login to the router and check on the status page what the uptime is.

So a simplified form of the script would be like

curl -v (some options) $user:$pass $IP:$port /vpn_status.htm |grep Uptime
#Compare last Uptime vs current Uptime
If $current_Uptime is > $last_uptime
Nagios code =1 (Ok)
If $current_Uptime is < $last_uptime
Nagios code =3 (Down)

Re: web scrape uptime

Posted: Thu Feb 05, 2015 12:00 pm
by tmcdonald
In this case you will need to store the results of the last check in a file somewhere, then read that back in for each check and compare the results.