WeatherBug script & templates version 2.0

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

Moderators: Developers, Moderators

Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

WeatherBug script & templates version 2.0

Post by Alives »

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.
Attachments
weatherbug.pl
(1.19 KiB) Downloaded 1517 times
cacti_host_template_weatherbug.xml
(44.33 KiB) Downloaded 1838 times
Last edited by Alives on Sun Apr 06, 2008 3:41 pm, edited 4 times in total.
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

Graphs...
Attachments
graphs.png
graphs.png (132.5 KiB) Viewed 26054 times
Last edited by Alives on Wed Aug 08, 2007 1:38 pm, edited 1 time in total.
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

I just got some downtime in my graphs... the website www.aws.com was actually down... oh well.
User avatar
evert
Posts: 27
Joined: Sun Sep 21, 2003 6:39 am
Location: Sarpsborg, Norway
Contact:

Post by evert »

What is the recommended/only way to upgrade from version 1.x to 2.0? 8)
Regards,
Evert Meulie
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

If you dont need the new graphs, which didnt change that much, you can just replace the script. Comment out or delete line 25,

Code: Select all

$data{Tries} = $tries;
and it should be just fine. Just make sure you have www::mechanize installed. Give it a test on the command line first.
Smitty
Posts: 6
Joined: Mon Aug 13, 2007 8:05 pm

WWW::Mechanize on CentOS

Post by Smitty »

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!
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

I'll try to rewrite it so it uses LWP::Simple
User avatar
evert
Posts: 27
Joined: Sun Sep 21, 2003 6:39 am
Location: Sarpsborg, Norway
Contact:

Post by evert »

Hmm, looks like my cacti is not getting all values needed...

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
User avatar
evert
Posts: 27
Joined: Sun Sep 21, 2003 6:39 am
Location: Sarpsborg, Norway
Contact:

Post by evert »

Found it! 8)

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];
of course, but also:

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
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

ah yes, sorry about that i didnt consider people would want metric. You will want to adjust some of the graph ranges too probably
User avatar
streaker69
Cacti Pro User
Posts: 712
Joined: Mon Mar 27, 2006 10:35 am
Location: Psychic Amish Network Administrator

Post by streaker69 »

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

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.
Any ideas?
Alives
Cacti User
Posts: 103
Joined: Mon Jul 11, 2005 11:39 am

Post by Alives »

I have reposted the script. Re-download it and it will work. Uses LWP::Simple again so you shouldnt need to install anything extra out of the box.
User avatar
streaker69
Cacti Pro User
Posts: 712
Joined: Mon Mar 27, 2006 10:35 am
Location: Psychic Amish Network Administrator

Post by streaker69 »

Alives wrote:I have reposted the script. Re-download it and it will work. Uses LWP::Simple again so you shouldnt need to install anything extra out of the box.
Thanks, works great now.
User avatar
evert
Posts: 27
Joined: Sun Sep 21, 2003 6:39 am
Location: Sarpsborg, Norway
Contact:

Post by evert »

Alives wrote:I have reposted the script. Re-download it and it will work. Uses LWP::Simple again so you shouldnt need to install anything extra out of the box.
Is that version better than the Mechanize one? Should I switch?
Regards,
Evert Meulie
User avatar
evert
Posts: 27
Joined: Sun Sep 21, 2003 6:39 am
Location: Sarpsborg, Norway
Contact:

Post by evert »

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... :o
Regards,
Evert Meulie
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest