|
|
| Author |
Message |
Hoffswell
Joined: 07 Jan 2005 Posts: 25
|
Posted: Fri Jan 21, 2005 11:26 am Post subject: Weather via wxer.pl - Weather conditions |
|
|
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
**************************
| Description: |
| tarball of all the xml files for cacti import. extract with tar xvf wxer-xml.tar and then import. |
|
 Download |
| Filename: |
wxer-xml.tar |
| Filesize: |
80 KB |
| Downloaded: |
1463 Time(s) |
| Description: |
| wxer.pl script. remove the .txt end when installing. |
|
 Download |
| Filename: |
wxer.pl.txt |
| Filesize: |
1.53 KB |
| Downloaded: |
1681 Time(s) |
Last edited by Hoffswell on Tue Feb 01, 2005 12:52 pm; edited 1 time in total |
|
| Back to top |
|
 |
Thomas Cacti User
Joined: 09 Dec 2004 Posts: 112 Location: Austria
|
Posted: Sat Jan 22, 2005 7:24 am Post subject: |
|
|
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!
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 13135 Location: MI, USA
|
Posted: Sat Jan 22, 2005 8:53 am Post subject: |
|
|
You can do that with a CDEF to the existing Graph Template or via the script.
TheWitness
|
|
| Back to top |
|
 |
Hoffswell
Joined: 07 Jan 2005 Posts: 25
|
Posted: Mon Jan 24, 2005 8:27 am Post subject: Temps C and F |
|
|
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: |
# 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!
|
|
| Back to top |
|
 |
placain
Joined: 09 Oct 2003 Posts: 11 Location: Philadelphia, PA
|
Posted: Mon Jan 24, 2005 10:51 pm Post subject: |
|
|
| When I try to import your XML it says there's a parse error ...
|
|
| Back to top |
|
 |
Hoffswell
Joined: 07 Jan 2005 Posts: 25
|
Posted: Tue Jan 25, 2005 8:03 am Post subject: |
|
|
| 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...
|
|
| Back to top |
|
 |
placain
Joined: 09 Oct 2003 Posts: 11 Location: Philadelphia, PA
|
Posted: Tue Jan 25, 2005 10:23 am Post subject: |
|
|
'c' also here, and that's the order I did it in.
I presume then that other people have imported them successfully?
|
|
| Back to top |
|
 |
flundy
Joined: 13 Oct 2004 Posts: 13
|
Posted: Tue Jan 25, 2005 10:48 am Post subject: |
|
|
| 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.
|
|
| Back to top |
|
 |
Yvan
Joined: 02 Apr 2003 Posts: 7 Location: Balegem, BE
|
Posted: Wed Jan 26, 2005 10:58 am Post subject: |
|
|
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
|
|
| Back to top |
|
 |
jarosoup
Joined: 17 Jan 2005 Posts: 13
|
Posted: Wed Jan 26, 2005 1:41 pm Post subject: |
|
|
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
|
|
| Back to top |
|
 |
Wernicke Cacti User
Joined: 08 Jun 2004 Posts: 60 Location: Bodø, Norway
|
Posted: Thu Jan 27, 2005 9:20 am Post subject: |
|
|
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
|
|
| Back to top |
|
 |
drywalldude
Joined: 28 Jan 2005 Posts: 11 Location: USA
|
Posted: Sun Jan 30, 2005 10:52 am Post subject: Weather Script Question |
|
|
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?????
|
|
| Back to top |
|
 |
placain
Joined: 09 Oct 2003 Posts: 11 Location: Philadelphia, PA
|
Posted: Sun Jan 30, 2005 12:34 pm Post subject: |
|
|
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/Weather-Underground-2.20/Underground.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?
|
|
| Back to top |
|
 |
frippe
Joined: 08 Dec 2004 Posts: 19
|
Posted: Mon Jan 31, 2005 6:38 am Post subject: |
|
|
| Yes, it works for me. I changed all the occurances of <site> to |site| in the xml-files before I imported.
|
|
| Back to top |
|
 |
frippe
Joined: 08 Dec 2004 Posts: 19
|
Posted: Mon Jan 31, 2005 9:17 am Post subject: |
|
|
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
| Description: |
|
| Filesize: |
40.59 KB |
| Viewed: |
27793 Time(s) |

|
|
|
| Back to top |
|
 |
|