web scrape uptime

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Ierlandfan
Posts: 2
Joined: Wed Feb 04, 2015 3:53 pm

web scrape uptime

Post 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?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: web scrape uptime

Post 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?
Ierlandfan
Posts: 2
Joined: Wed Feb 04, 2015 3:53 pm

Re: web scrape uptime

Post 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)
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: web scrape uptime

Post 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.
Former Nagios employee
Locked