Weather Graphs

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
mattl
Posts: 6
Joined: Mon Feb 11, 2008 11:44 am

Weather Graphs

Post by mattl »

1) Make sure you have libwww-perl installed (Ubuntu users run: #apt-get install libwww-perl)
http://search.cpan.org/~gaas/libwww-perl/

2) Download the xml and pl files attached to this topic.

3) Import the xml using the cacti import utility.

4) Save the pl script to your cacti scripts directory.
/your/cacti-install-directory/cacti/scripts/weatherbug.pl
5) Get a location code from the ICAO column here. http://www.rap.ucar.edu/weather/surface/stations.txt

6) Test the script is working
#perl weatherbug.pl KMAF
You should get a printout like this
Tries:1 Humidity:11.3 FeelsLike:72.5 Wind:18.4 DewPoint:18.5 Temp:75.9 Rain:0.00 Pressure:29.82
7) Create a new device in cacti.
Description: Weather KMAF (Midland, TX)
Hostname: 127.0.0.1 (or any snmp host, not used but is a required field)
Host Template: WeatherBug
Fill in your specific snmp info for Hostname above

8) Create Graphs for Host (select all)

9) Fill in your location code from step 4, for each WeatherCode field.

10) Add the host to a Graph Tree.

Enjoy
Attachments
weatherbug.pl
(1.17 KiB) Downloaded 807 times
cacti_host_template_weatherbug_349.xml
(40.51 KiB) Downloaded 827 times
Last edited by mattl on Tue May 12, 2009 3:52 pm, edited 1 time in total.
mattl
Posts: 6
Joined: Mon Feb 11, 2008 11:44 am

Post by mattl »

I cleaned up the weatherbug.pl script a bit, all variables are being pulled correctly.

If the format of the weatherbug data is changed the script will need to be adapted to the new format. Pretty easy.
mattl
Posts: 6
Joined: Mon Feb 11, 2008 11:44 am

Post by mattl »

Demo graphs.

Image
Image
Image
Image
Image
Image

Migrated Cacti Box to a private server. No more demo graphs.
mattl
Posts: 6
Joined: Mon Feb 11, 2008 11:44 am

Post by mattl »

Just upgraded my Cacti Box.

Glad I wrote this. Everything works great with the new versions.
kels0
Posts: 8
Joined: Wed Dec 23, 2009 2:35 pm

Re: Weather Graphs

Post by kels0 »

Recently upgraded to the latest cacti and it stopped the graphing we had in place.

So, I figured id set it up again using this guide, and all apears to be working except its not placing any data on the graphs.

I verified that I can run the command from command line.

There is nothing in any logs that tells me somethign is wrong, i have debug set to high in settings as well.

Code: Select all


06/28/2011 08:56:05 AM - SPINE: Poller[0] Host[88] TH[1] DS[2758] SCRIPT: perl /var/www/html/scripts/weatherbug.pl KFMY, output: 0
06/28/2011 08:56:05 AM - SPINE: Poller[0] Host[88] TH[1] DS[2759] SCRIPT: perl /var/www/html/scripts/weatherbug.pl KFMY, output: 0
06/28/2011 08:56:05 AM - SPINE: Poller[0] Host[88] TH[1] DS[2760] SCRIPT: perl /var/www/html/scripts/weatherbug.pl KFMY, output: 0
06/28/2011 08:56:05 AM - SPINE: Poller[0] Host[88] TH[1] DS[2761] SCRIPT: perl /var/www/html/scripts/weatherbug.pl KFMY, output: 0
06/28/2011 08:56:06 AM - SPINE: Poller[0] Host[88] TH[1] DS[2762] SCRIPT: perl /var/www/html/scripts/weatherbug.pl KFMY, output: 0
06/28/2011 08:56:06 AM - SPINE: Poller[0] Host[88] TH[1] DS[2763] SCRIPT: perl /var/www/html/scripts/weatherbug.pl KFMY, output: 0
and this is the output from the above

Code: Select all

DewPoint:71.8 Tries:1 Humidity:89.5 Temp:75.0 Wind:3.3 Pressure:30.05 Rain:0.00
one more thing i noticed that may help.. its not creating the xml files and doesnt appear to be updating the graphs further (im guessing because of the lack of xml file for graph).

Code: Select all

-rw-r--r--  1 www-data root   3808984 2011-06-28 09:00 weather_-_ft_myers_dewpoint_2758.rrd
-rw-r--r--  1 www-data root   3808984 2011-06-28 09:00 weather_-_ft_myers_dewpoint_2759.rrd
-rw-r--r--  1 www-data root   3808984 2011-06-28 09:00 weather_-_ft_myers_dewpoint_2760.rrd
-rw-r--r--  1 www-data root   3808984 2011-06-28 09:00 weather_-_ft_myers_dewpoint_2761.rrd
-rw-r--r--  1 www-data root   3808984 2011-06-28 09:00 weather_-_ft_myers_dewpoint_2762.rrd
-rw-r--r--  1 www-data root   3808984 2011-06-28 09:00 weather_-_ft_myers_dewpoint_2763.rrd
the RRA folder IS chmod 777, i tested removing the above files, but this made no difference, it did recreate them fine.
sammyc53
Posts: 13
Joined: Fri Mar 21, 2008 1:55 pm

Re: Weather Graphs

Post by sammyc53 »

Did the weatherbug API get shut down?
Just noticed that my graphs can't get a reading since about April or May 2014.
sibberio
Posts: 2
Joined: Tue Jul 29, 2014 5:45 am

Re: Weather Graphs

Post by sibberio »

Hi,
I've solved the problem changed this part

Code: Select all

# regex in html source order
if ($_ =~ /Temperature\(\DF\)\s(-?\d+?\.\d+?)\s/g)    { $data{Temp} = $1; }
if ($_ =~ /Humidity\s\(\D\)\s(\d+?\.\d+?)\s/g)        { $data{Humidity} = $1; }
if ($_ =~ /Wind\s\(mph\).+?(\d+?\.\d+?)\s/g)          { $data{Wind} = $1; }
if ($_ =~ /Daily\sRain\s\(\"\)\s(\d+?\.\d+?)\s/g)     { $data{Rain} = $1; }
if ($_ =~ /Pressure\(\"Hg\)\s(\d+?\.\d+?)\s/g)        { $data{Pressure} = $1; }
if ($_ =~ /WIND\sCHILL:\s(\d+?\.\d+?)\s/g)            { $data{FeelsLike} = $1; }
if ($_ =~ /DEW\sPOINT:\s(\d+?\.\d+?)\s/g)             { $data{DewPoint} = $1; }
With this one

Code: Select all

# regex in html source order
if ($_ =~ /"temp":(\d+)/)    { $data{Temp} = $1; }
if ($_ =~ /"hum":(\d+)/)        { $data{Humidity} = $1; }
if ($_ =~ /"tmaws":(\d+)/)          { $data{Wind} = $1; }
if ($_ =~ /"dlyrn":(\d+)/)     { $data{Rain} = $1; }
if ($_ =~ /"prs":(\d+)/)        { $data{Pressure} = $1; }
# if ($_ =~ /WIND\sCHILL:\s(\d+?\.\d+?)\s/g)            { $data{FeelsLike} = $1; }
if ($_ =~ /"dewpt":(\d+)/)             { $data{DewPoint} = $1; }
As you can see I didn't find any solution for the Wind Chill.

Also I cannot change the unit. I'm in Italy and we use Celsius instead of Farenheit
Gattancha
Posts: 4
Joined: Thu Dec 04, 2014 4:27 am

Re: Weather Graphs

Post by Gattancha »

I've managed to fix the WindChill:

Code: Select all

if ($_ =~ /"wdchl":(\d+?\.\d+?)/)            { $data{FeelsLike} = $1; }
Also, I've amended the code for displaying in Celsius rather than in Farenheit:

Code: Select all

# regex in html source order
if ($_ =~ /"temp":(\d+)/)    { $data{Temp} = ($1-32)*5/9; }
if ($_ =~ /"wdchl":(d+?)/)            { $data{FeelsLike} = ($1-32)*5/9; }
if ($_ =~ /"dwpt":(\d+)/)             { $data{DewPoint} = ($1-32)*5/9; }
if ($_ =~ /"hum":(\d+)/)        { $data{Humidity} = $1; }
if ($_ =~ /"prs":(\d+)/)        { $data{Pressure} = $1; }
if ($_ =~ /"dlyrn":(\d+)/)     { $data{Rain} = $1; }
if ($_ =~ /"tmaws":(\d+)/)          { $data{Wind} = $1; }

for (keys %data) {
  printf "%s:%s ", $_, $data{$_};
}
Last edited by Gattancha on Tue Dec 16, 2014 5:28 am, edited 1 time in total.
Gattancha
Posts: 4
Joined: Thu Dec 04, 2014 4:27 am

Re: Weather Graphs

Post by Gattancha »

Ok been having a bit of oddness around the FeelsLike value

When I first tested (and posted) the script I was getting a value of "3.6", but then I started getting no results
Looking at the source code from the URL, I noticed that "wdchl" had a NULL value, which was throwing the script off

I have had to add an extra check to set the "FeelsLike" value to that of "Temp" should it be NULL..

Code: Select all

if ($_ =~ /"wdchl":(null)/)      { $data{FeelsLike} =  $data{Temp}}
Output when "NULL":

Code: Select all

Tries:1 Humidity:87 Wind:0 FeelsLike:5.6 DewPoint:3.9 Temp:5.6 Pressure:29 Rain:0
Output with Data:

Code: Select all

Tries:1 Humidity:87 Wind:0 FeelsLike:3.3 DewPoint:3.9 Temp:5.6 Pressure:29 Rain:0
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests