WeatherBug script & templates version 2.0

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

Moderators: Developers, Moderators

User avatar
zorrosam
Cacti User
Posts: 244
Joined: Thu May 03, 2007 3:17 pm
Location: Italy

problem with data (nan value)

Post by zorrosam »

Sorry,

the scripts weatherbug.perl works well .. even if i have no data in my cacti graph. (nan) Can you help me?

The log is ok:

0/02/2007 04:40:13 PM - CACTID: Poller[0] Host[1] DS[8062] SCRIPT: perl /var/www/cacti/scripts/weatherbug.pl get code from http://www.aws.com/aws_2001/asp/getLiveWeather.asp , output: current_temp:26 wind_speed:5 barometer:1019.98 humidity:47 high_temp:26 low_temp:12 dew_point_temp:14 wind_chill_temp:27

please help me
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

how does this work with proxy server? I have a proxy server that requires authentication as well.

however, i dont even get error on command line:

[root@intranet scripts]# ./weatherbug.pl KEWR
[root@intranet scripts]#

Thanks!

Just as a test, it does work fine on my non-public server:

[jweinraub@rockhopper:~]
$ ./weatherbug.pl KEWR
Tries:1 Humidity:56.0 FeelsLike:22.8 Wind:14.8 DewPoint:13.8 Temp:22.8 Rain:0.00 Pressure:102.74
hipsterdoofus
Cacti User
Posts: 87
Joined: Fri Mar 09, 2007 12:35 pm

Post by hipsterdoofus »

I ended up redoing the script a bit personally using ideas from the wxer - get much better values back from wunderground than weatherbug/aws.
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

if i export http_proxy with my credentials it works fine on my production web server on command line.

however, it doesnt work in script. is there a way to put these vars in the perl script itself?
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

okay i got it to work finally.

if anybody else is in my scenario this is what i did:

Code: Select all

#!/usr/bin/perl
use warnings;
#use strict;

use LWP::UserAgent;

$ua = LWP::UserAgent->new;
$ua->proxy(['http', 'ftp'] => 'http://jweinraub:password@proxy:8080');
# ... snip ...
 my $req = new HTTP::Request('GET', $httpaddr);
 $content = $ua->request($req)->as_string;
User avatar
zorrosam
Cacti User
Posts: 244
Joined: Thu May 03, 2007 3:17 pm
Location: Italy

problems!

Post by zorrosam »

Hi all!

i have configured these ... script more template for milan(italy)

When i launch the scripts the data are get in the correct way ... cacti from log launch the script correctly .... but hav no graph in my installation?

any idea?

any help is appreciate.

sam
User avatar
zorrosam
Cacti User
Posts: 244
Joined: Thu May 03, 2007 3:17 pm
Location: Italy

help

Post by zorrosam »

evert wrote: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; }   
sorry sir!

can you explain me wich is the file that i have to change?

sam
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

I made those changes and adjusted the Graph Templates as well.
I decided to use the METAR Code as a Hostname (e.g. EDDM for Munic Airport) to avoid being prompted for the METAR Code for each Graph Template. You will avoid entering a community string and this deactivates Host Availability checking.
I renamed the script to avoid misunderstanding.
Reinhard

Updated the XML for the Templates. Requires at least cacti 0.8.6j
Attachments
cacti_host_template_weatherbug-metric.xml
Corrected Templates; no need to define LAST consolidation function
(45.17 KiB) Downloaded 603 times
weatherbug-metric.pl
The Script
(1.19 KiB) Downloaded 507 times
Smitty
Posts: 6
Joined: Mon Aug 13, 2007 8:05 pm

Dead Weather Bug?

Post by Smitty »

Did anyone else's weather bug stop working?
bort13
Posts: 4
Joined: Fri Jan 05, 2007 12:36 pm

Post by bort13 »

Yep, aws.com has changed something, so you're not getting the page returned that the script is intending to parse.
Smitty
Posts: 6
Joined: Mon Aug 13, 2007 8:05 pm

Post by Smitty »

Yep, I thought that is what happened to it but just wanted to make sure it was not just me.

Thanks!
micro98
Posts: 2
Joined: Wed Nov 07, 2007 4:12 am

Post by micro98 »

"http://www.aws.com/aws_2001/asp/obsforecast.asp?id="

need so be changed to

"http://www.aws.com/obsforecast.asp?id="

And Works Fine after i edit the weatherbug.pl
bort13
Posts: 4
Joined: Fri Jan 05, 2007 12:36 pm

Post by bort13 »

micro98 wrote:"http://www.aws.com/aws_2001/asp/obsforecast.asp?id="

need so be changed to

"http://www.aws.com/obsforecast.asp?id="

And Works Fine after i edit the weatherbug.pl
If you want to use a zip code, you can also use

Code: Select all

http://www.aws.com/obsforecast.asp?&zipcode=
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

Does the zip code work for Canadian Zip codes as well? I am having a hell of a time locating the correct code for two of my offices in Canada.

just wondering if i could use this instead.

app
[b]Cacti Version[/b] - 0.8.7b
[b]Plugin Architecture[/b] - 2.2 Beta
[b]Poller Type[/b] - CMD.php
[b]Server Info[/b] - Linux 2.6.9-78.0.1.ELsmp
[b]Web Server[/b] - Apache/2.0.52 (Red Hat)
[b]PHP[/b] - 4.3.9
[b]MySQL[/b] - 4.1.22
[b]RRDTool[/b] - 1.2.23
[b]SNMP[/b] - 5.1.2
[b]Plugins[/b][list]Global Plugin Settings (settings - v0.5)
SuperLinks (superlinks - v0.72)
Host Info (hostinfo - v0.2)
Report Creator (reports - v0.3)
Update Checker (update - v0.4)
Realtime for Cacti (realtime - v0.35)
Cacti Log View (clog - v1.1)
RRD File Cleaner (rrdclean - v0.36)
Network Discovery (discovery - v0.9)
Uptime (uptime - v0.4)[/list]
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

apperrault wrote:Does the zip code work for Canadian Zip codes as well? I am having a hell of a time locating the correct code for two of my offices in Canada.

just wondering if i could use this instead.

app
It does work, but I decided to use Environment Canada's Weather Office pages instead.

See the attached templates and perl script.

Works the same as the Weather Bug templates, except there's no Rainfall graph. I did however add a graph for 'visibility' as it's listed on the Weather Office pages.

To find your weather code, go to http://text.www.weatheroffice.gc.ca/canada_e.html and find the city you want to graph weather for.
Once you're at the page, copy the first argument to the page and use it as your location code.

For example, I'm in Ottawa, so my URL is:
http://text.www.weatheroffice.gc.ca/for ... 118&unit=m
This makes my Code: on-118

If you want Imperial units, change the last M to an I in the perl script and you're off to the races. You'll also have to change the legends and descriptors in the graphs to represent °F, MPH and wind speed and pressure.
Attachments
Weather Office host template.xml
Host Template for Weather Office graphs
(49.85 KiB) Downloaded 562 times
weatheroffice.pl
Perl script to pick up the data from EC's Weather Office pages
(1.83 KiB) Downloaded 354 times
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests