WeatherBug script & templates version 2.0
Moderators: Developers, Moderators
WeatherBug script & templates version 2.0
THIS THREAD IS DEPRECATED... NEW THREAD IS HERE:
http://forums.cacti.net/viewtopic.php?t=26712
==============================================
Old thread is here: http://forums.cacti.net/viewtopic.php?t=8821 Please check it if you have questions
-------------------------------------------------------------------
SCRIPT
The script takes the same arguments, just the weather site code from the URL ( http://www.aws.com/aws_2001/asp/obsforecast.asp?id= ). If you want metric, alter the URL.
You need to set the timeout values in the script by hand.
$timeout is the time in seconds that each http get request will timeout.
$total_time is the total amount of time the script will try to get the data. If this total time is reached, the script exits.
** It is important that you keep in mind the value in the console settings under poller that determines how long cacti pollers will wait for script data. The default is 25 I think. You can play around with this, but keep in mind that all of your polling must finish within 5 minutes (300 seconds) in order for cacti to be working properly. **
The script now outputs the number of tries that it takes to get the weather data. I was using this for debugging purposes, but it seems somewhat useful to determine if the weather station you chose sucks or not.
GRAPHS
Not much new here. There is a new graph called Tries that shows the number of tries it took the script to pull the weather data.
Trendlines (CDEF) have been added to wind and tries to give a better understanding of what is going on.
I have exported my host template which includes all dependencies.
This host template was exported from 0.8.6h so it should work for you unless you are a couple versions behind.
http://forums.cacti.net/viewtopic.php?t=26712
==============================================
Old thread is here: http://forums.cacti.net/viewtopic.php?t=8821 Please check it if you have questions
-------------------------------------------------------------------
SCRIPT
The script takes the same arguments, just the weather site code from the URL ( http://www.aws.com/aws_2001/asp/obsforecast.asp?id= ). If you want metric, alter the URL.
You need to set the timeout values in the script by hand.
$timeout is the time in seconds that each http get request will timeout.
$total_time is the total amount of time the script will try to get the data. If this total time is reached, the script exits.
** It is important that you keep in mind the value in the console settings under poller that determines how long cacti pollers will wait for script data. The default is 25 I think. You can play around with this, but keep in mind that all of your polling must finish within 5 minutes (300 seconds) in order for cacti to be working properly. **
The script now outputs the number of tries that it takes to get the weather data. I was using this for debugging purposes, but it seems somewhat useful to determine if the weather station you chose sucks or not.
GRAPHS
Not much new here. There is a new graph called Tries that shows the number of tries it took the script to pull the weather data.
Trendlines (CDEF) have been added to wind and tries to give a better understanding of what is going on.
I have exported my host template which includes all dependencies.
This host template was exported from 0.8.6h so it should work for you unless you are a couple versions behind.
- Attachments
-
- weatherbug.pl
- (1.19 KiB) Downloaded 1520 times
-
- cacti_host_template_weatherbug.xml
- (44.33 KiB) Downloaded 1841 times
Last edited by Alives on Sun Apr 06, 2008 3:41 pm, edited 4 times in total.
I just got some downtime in my graphs... the website www.aws.com was actually down... oh well.
If you dont need the new graphs, which didnt change that much, you can just replace the script. Comment out or delete line 25, and it should be just fine. Just make sure you have www::mechanize installed. Give it a test on the command line first.
Code: Select all
$data{Tries} = $tries;
WWW::Mechanize on CentOS
Can anyone help me install the WWW::Mechanize with yum?
Thanks Alives for bring this back, just hope I can figure this WWW::Mechanize out so I can use it.
Thanks everyone!
Thanks Alives for bring this back, just hope I can figure this WWW::Mechanize out so I can use it.
Thanks everyone!
Hmm, looks like my cacti is not getting all values needed...
Here is an output of weatherbug.pl KJFK:
Why are the other values not returned? I am using the units=1 setting, but that shouldn't block them, right?
Here is an output of weatherbug.pl KJFK:
Code: Select all
DewPoint:10.9 Tries:1 Humidity:63.7 FeelsLike:17.7
Why are the other values not returned? I am using the units=1 setting, but that shouldn't block them, right?
Regards,
Evert Meulie
Evert Meulie
Found it!
Some of the variables like mph & "Hg that are used on the AWS site are hard-coded in weatherbug.pl.
The following alterations will make it work for the Metric system:
of course, but also:
Some of the variables like mph & "Hg that are used on the AWS site are hard-coded in weatherbug.pl.
The following alterations will make it work for the Metric system:
Code: Select all
my $httpaddr = "http://www.aws.com/aws_2001/asp/obsforecast.asp?units=1&id=" . $ARGV[0];
Code: Select all
# regex in html source order
if ($_ =~ /Temperature\(\DC\)\s(-?\d+?\.\d+?)\s/g) { $data{Temp} = $1; }
if ($_ =~ /Humidity\s\(\D\)\s(\d+?\.\d+?)\s/g) { $data{Humidity} = $1; }
if ($_ =~ /Wind\s\(kph\).+?(\d+?\.\d+?)\s/g) { $data{Wind} = $1; }
if ($_ =~ /Daily\sRain\s\(cm\)\s(\d+?\.\d+?)\s/g) { $data{Rain} = $1; }
if ($_ =~ /Pressure\s\(kPa\)\s(\d+?\.\d+?)\s/g) { $data{Pressure} = $1; }
if ($_ =~ /(HEAT INDEX|WIND CHILL):(\d+?\.\d+?)\s/g) { $data{FeelsLike} = $2; }
if ($_ =~ /DEW\sPOINT:\s(\d+?\.\d+?)\s/g) { $data{DewPoint} = $1; }
Regards,
Evert Meulie
Evert Meulie
- streaker69
- Cacti Pro User
- Posts: 712
- Joined: Mon Mar 27, 2006 10:35 am
- Location: Psychic Amish Network Administrator
Ok, I give up, I believe I have WWW::Mechanize installed properly, but the script isn't working. Below is what I get if I try to run the script from the command line
Any ideas?
Code: Select all
Can't locate HTML/TokeParser.pm in @INC (@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/site_perl/5.8.5/WWW/Mechanize.pm line 107.
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.5/WWW/Mechanize.pm line 107.
Compilation failed in require at weatherbug.pl line 4.
BEGIN failed--compilation aborted at weatherbug.pl line 4.
- streaker69
- Cacti Pro User
- Posts: 712
- Joined: Mon Mar 27, 2006 10:35 am
- Location: Psychic Amish Network Administrator
BTW, not always accurate/complete, the info from AWS...
http://www.aws.com/aws_2001/asp/obsFore ... RY&units=1 says it is dry. It's been raining for hours now...
http://www.aws.com/aws_2001/asp/obsFore ... RY&units=1 says it is dry. It's been raining for hours now...
Regards,
Evert Meulie
Evert Meulie
Who is online
Users browsing this forum: No registered users and 1 guest