Weather via wxer.pl - Weather conditions

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

Moderators: Developers, Moderators

Hoffswell
Posts: 26
Joined: Fri Jan 07, 2005 10:28 am

Weather via wxer.pl - Weather conditions

Post by Hoffswell »

Good day to you -

I have been working on a new weather data capture, using data from wunderground.com, and the Weather::Underground perl module. I named my script wxer.pl "weather-er" so to speak.

I have a functioning system, that I wanted to post for comment.

My work is based off helzerr's excellent stuff using weatherbug at http://forums.cacti.net/viewtopic.php?t=3234

In addition to his stuff, I have added:

* Ability to use data templates, allowing the creation of weather by zipcode.
* graph templates.

This is my first go at developing a cacti solution. Comments and suggestions are apprectated!

TO USE:


* place wxer.pl in your scripts directory
* Access Cacti to Add Input method:
- Data Input Methods -> New
- Name Weather by Zip
- Input type Script/Command
- string: perl <path_cacti>/scripts/wxer.pl <zip>
- Add one input field called zip
- Add 5 output fields:
wx_wind_chill_f Wind Chill Temperature
wx_humidity Humidity
wx_pressure Barometric Pressure
wx_wind_speed Wind Speed
wx_temp_f Temperature (F)
* Import the xml templates to your cacti installation
* Access Cacti to create data source and graphs.
- Data Sources -> Add -> Selected Data Template: Weather via Wxer
- Set zipcode, and save
- Graph Management -> Add -> Selected Graph Template: Weather - Outside Temperature
- Connect to data source
- Add graph to tree

I think that is correct. Partially from memory.

Let me know if it works for you, and what you think!

** Note FEB 01 2005 ********
The template script does NOT work well, please read the full thread before attempting to import it
**************************
Attachments
wxer.pl.txt
wxer.pl script. remove the .txt end when installing.
(1.53 KiB) Downloaded 4975 times
wxer-xml.tar
tarball of all the xml files for cacti import. extract with tar xvf wxer-xml.tar and then import.
(80 KiB) Downloaded 4220 times
Last edited by Hoffswell on Tue Feb 01, 2005 12:52 pm, edited 1 time in total.
- Pete
Thomas
Cacti User
Posts: 112
Joined: Thu Dec 09, 2004 1:51 pm
Location: Austria

Post by Thomas »

Hi Pete,
I had a fast look at your scripts and checked that weatherinfo for my hometown Bregenz, Austria, Europe is available.
Do you think it's possible to modify you script to get temperature information in Celsius or Fahrenheit?
Thanks a lot for your work!
Thomas Rupp
User avatar
TheWitness
Developer
Posts: 16997
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

You can do that with a CDEF to the existing Graph Template or via the script.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Hoffswell
Posts: 26
Joined: Fri Jan 07, 2005 10:28 am

Temps C and F

Post by Hoffswell »

If you access the wxer.pl script, you will see that you can turn on a debug mode. If you run it, you will get:


networker:/usr/local/cacti/cacti-0.8.6c/scripts # perl wxer.pl 49424
MATCH:
celsius = -3
pressure = 29.99 in / 1016 hPa
temperature_celsius = -3
place = Holland, Michigan
windchill_celsius = -10
wind = 21 mph 33 km/h from the SW
fahrenheit = 27
updated = 7:53 AM EST on January 24, 2005
windchill_fahrenheit = 13
conditions = Mostly Cloudy
temperature_fahrenheit = 27
humidity = 75
networker:/usr/local/cacti/cacti-0.8.6c/scripts #

That shows you all the stuff you can get from weather underground.


Go ahead and change the {temperature_fahrenheit} to {temperature_celsius}, and the same for windchill.

Code: Select all


   # print output
   print
     "wx_temp_f:" . $arrayref->[0]->{temperature_fahrenheit}
     . " wx_wind_speed:" . $wx_wind_speed
     . " wx_pressure:" . $wx_pressure
     . " wx_humidity:" . $arrayref->[0]->{humidity}
     . " wx_wind_chill_f:" . $arrayref->[0]->{windchill_fahrenheit}
     ;
   }

Then you will get outputs of celsius. If you change the variable name, wx_temp_f, then you will also need to change it in cacti.

Good luck!
- Pete
placain
Posts: 11
Joined: Thu Oct 09, 2003 9:37 am
Location: Philadelphia, PA
Contact:

Post by placain »

When I try to import your XML it says there's a parse error ...
Hoffswell
Posts: 26
Joined: Fri Jan 07, 2005 10:28 am

Post by Hoffswell »

placain wrote:When I try to import your XML it says there's a parse error ...

I am running cacti-0.8.6c.

I would imagine that you want to create the data input method first, then import the data template, then import the graph templates.

Beyond that, I'm unsure...
- Pete
placain
Posts: 11
Joined: Thu Oct 09, 2003 9:37 am
Location: Philadelphia, PA
Contact:

Post by placain »

'c' also here, and that's the order I did it in.

I presume then that other people have imported them successfully?
flundy
Posts: 13
Joined: Wed Oct 13, 2004 3:38 pm

Post by flundy »

placain wrote:'c' also here, and that's the order I did it in.

I presume then that other people have imported them successfully?
I had the xml parse error, as well.
Yvan
Posts: 7
Joined: Wed Apr 02, 2003 2:28 pm
Location: Balegem, BE

Post by Yvan »

The problem is <site> tag on line 6.

I changed the tag to |site| and the imports worked just fine.

But when I try to get the zeather for the zip code in your example, the only RRA it creates, is wx_windchill_279.rrd

No name in front of it, so makeing a graph is not possible.

Greetings,

Yvan
jarosoup
Posts: 13
Joined: Mon Jan 17, 2005 9:20 pm

Post by jarosoup »

I am still unable to download the xml.tar file but downloaded the perl script just fine. Just wanted to comment on your work - good job! I created the data and graph templates manually and it works great. Thanks for the contribution :)
User avatar
Wernicke
Cacti User
Posts: 61
Joined: Tue Jun 08, 2004 3:07 am
Location: Bodø, Norway
Contact:

Post by Wernicke »

I finaly had everything set-up, but i can't seem to generate the RRA files. there is no errormessage about this weatherscript in the logfiles, but it is in the poller cache. Even when i generate the rra manualy, it won't update.. Strange

I use 0.8.6c and cactid

-Sigurd
drywalldude
Posts: 11
Joined: Fri Jan 28, 2005 9:41 pm
Location: USA
Contact:

Weather Script Question

Post by drywalldude »

When I try to run this script manualy I get the following :

[root@linuxserver scripts]# perl wxer.pl 30127
Can't locate Weather/Underground.pm in @INC (@INC contains: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.6.1/i386-linux /usr/lib/perl5/vendor_perl/5.6.1 /usr/lib/perl5/vendor_perl .) at wxer.pl line 16.
BEGIN failed--compilation aborted at wxer.pl line 16.
[root@linuxserver scripts]# perl wxer.pl Atlanta, Georgia
Can't locate Weather/Underground.pm in @INC (@INC contains: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.6.1/i386-linux /usr/lib/perl5/vendor_perl/5.6.1 /usr/lib/perl5/vendor_perl .) at wxer.pl line 16.
BEGIN failed--compilation aborted at wxer.pl line 16.

Am I doing something wrong?????
placain
Posts: 11
Joined: Thu Oct 09, 2003 9:37 am
Location: Philadelphia, PA
Contact:

Post by placain »

That one's easy enough to fix. If you know how to install Perl modules, install Weather::Underground. If not, just install this one locally.

Get this file:
http://search.cpan.org/src/MNAGUIB/Weat ... rground.pm

Create a directory 'Weather' in the scripts directory.

Put the 'Underground.pm' file in it.

That will solve your problem.

Has *anyone* gotten the XML to work yet?
frippe
Posts: 19
Joined: Wed Dec 08, 2004 4:41 am

Post by frippe »

Yes, it works for me. I changed all the occurances of <site> to |site| in the xml-files before I imported.
frippe
Posts: 19
Joined: Wed Dec 08, 2004 4:41 am

Post by frippe »

However, I get some error readings now and then which will destroy the perspective of the graph. Se picture for an example. What I have seen at this point is that the database always looks like this:

timestamp wx_windchill wx_humid wx_wind wx_barom wx_temp

1107141900: 2.9000000000e+01 9.3000000000e+01 6.0000000000e+00 2.9420000000e+01 3.4000000000e+01
1107142200: 2.9000000000e+01 9.3000000000e+01 6.1966666667e+00 2.9420000000e+01 2.2398000000e+02
1107142500: nan nan 7.0000000000e+00 nan 1.0000000000e+03
1107142800: nan nan 7.0000000000e+00 nan 1.0000000000e+03
1107143100: nan nan 7.0000000000e+00 nan 1.0000000000e+03
1107143400: nan nan 7.0000000000e+00 nan 1.0000000000e+03
1107143700: nan nan 7.0000000000e+00 nan 1.0000000000e+03
1107144000: nan nan 7.0000000000e+00 nan 1.0000000000e+03
1107144300: 2.6000000000e+01 9.3000000000e+01 7.0000000000e+00 2.9420000000e+01 3.5226666667e+01
1107144600: 2.6000000000e+01 9.3000000000e+01 7.0000000000e+00 2.9420000000e+01 3.2000000000e+01
1107144900: 2.6000000000e+01 9.3000000000e+01 7.0000000000e+00 2.9420000000e+01 3.2000000000e+01

That is:
wx_windchill=nan
wx_humid=nan
wx_wind=7.0000000000e+00
wx_barom=nan
wx_temp=1.0000000000e+03

Does it default to these values when it cannot read the info or what can it be? The site i'm monitoring is Bromma in Sweden
Attachments
Temperature.jpg
Temperature.jpg (40.59 KiB) Viewed 56900 times
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests