Page 1 of 1

Reading a value from a Web page

Posted: Wed Jan 04, 2012 11:42 am
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

Re: Reading a value from a Web page

Posted: Wed Jan 04, 2012 12:30 pm
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