Reading a value from a Web page

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
linker3000
Posts: 3
Joined: Wed Jan 04, 2012 11:26 am

Reading a value from a Web page

Post by linker3000 »

Hi,

Is there a plugin that allows a value to be read from a Web page and then for that value compared to defined thresholds?

I have a bash script that reads a USB temperature sensor, logs the data, sends email alerts if necessary and also generates a simple web page showing the temperature. If I could read the value on the page into Nagios it would mean I don't have to allow file-level access to the server or install any client apps etc (the server is only monitored by a ping test). I have full control over how the generated Web page looks so I could make it easy for the temperature to be found - it currently looks like this:

Code: Select all

Temperature reading for Server Room 4

Temperature was..... : 18.375C when sampled at 04-Jan-2012 16:30

Previous reading was : 18.375C when sampled at 04-Jan-2012 16:20

Temp differential is : 0C
All suggestions appreciated.

Thanks
LHammonds
Posts: 23
Joined: Mon Jan 02, 2012 9:03 pm
Location: Behind you!!!

Re: Reading a value from a Web page

Post by LHammonds »

Use WGET to download the html to a file, then read the file looking for your key/value.

Example:

Code: Select all

#!/bin/bash
wget --output-document=/tmp/out.htm http://www.mysite.com/temp.htm
For the rest, use Google to search for "bash read file"

To have this integrated into Nagios, I made a custom script and documented how I did it here --> check_https
Locked