Many thanks for the clear and consise instructions - I will give it a go now and hopefully it will be a breeze ( )ottomatic wrote:Ok... After much frustration I figured out how this works.
Step 1: Import the template and copy the perl script to the scripts directory
Step 2: Make sure that in your Settings > Poller > Downed Host Detection is set to "Ping and SNMP"
Step 3: Devices and create a new host by clicking Add.
Step 4: Enter your description. Then your hostname... you can add a host that is pingable or 127.0.0.1. Then change the host template to "WeatherBug." then click create.
Step 5: Click on "Create Graphs for this Host"
Step 6: Then click on the types of weather you want to graph. I just checked them all.
Step 7: Now... In all of the blanks that say... "get code from..." Go to that website and search for your code. Once have found the weather for your city. In the address bar there is a "?id=" and then there is a few letters... That is your code. Put that in all the blanks that say "get code from..." then click create at the bottom.
Step 8: Now go to your Graph Trees and add the host (the description is what you should look for) that we created earlier in step 1. Then wait for the poller go get the weather.
WeatherBug script & templates
Moderators: Developers, Moderators
---- lard007skype ----
Excellent spotted that one - if you change the data template and select the "ignore this value" checkbox and enter "null" in the code field it will then ask you for them when you create the graphs,ottomatic wrote:You can go to "Data Sources" then look for weatherbug. You should have 5 (if you selected all 5 graphs). Click on one of the weatherbug's and then put the code in the last blank what says "Weather Code."
Having an issue with the perl script though as it was on widows 2k - putting it on the centos server and I'm sure it will work fine!
Thanks for the help!
Lard
---- lard007skype ----
Strange but when I run this code I always only get two variables returned - does not seem to matter what code I enter as the METAR:
[root@localhost /]# usr/bin/perl /var/www/html/scripts/weatherbug.pl EGSC
DewPoint:1.2 HeatIndex:1.2
[root@localhost /]# usr/bin/perl /var/www/html/scripts/weatherbug.pl ABCD
DewPoint:1.2 HeatIndex:1.2
The script is:
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
my $httpaddr = "http://www.aws.com/aws_2001/asp/obsforecast.asp?id=?" . $ARGV[0];
my %data;
my %trash;
my $content = LWP::Simple::get($httpaddr) or die "Couldn't get it!";
# regex in html source order
if ($content =~ /(<b>Temperature<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(-?\d+\.\d+)<\/b>/g) { $data{Temp} = $1; }
if ($content =~ /(<b>Humidity<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Humidity} = $1; }
if ($content =~ /(<b>Wind<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)<\/b>/g) { $data{Wind} = $1; }
if ($content =~ /(<b>Daily Rain<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Rain} = $1; }
if ($content =~ /(<b>Pressure<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Pressure} = $1; }
if ($content =~ /(HEAT INDEX|WIND CHILL)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)/g) { $data{HeatIndex} = $1; }
if ($content =~ /(DEW POINT:)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)/g) { $data{DewPoint} = $1; }
for (keys %data) {
printf "%s:%s ", $_, $data{$_};
}
print "\n";
I notice that the variables that are returning are in CAPS - could this be the issue?
Thanks,
Lard
[root@localhost /]# usr/bin/perl /var/www/html/scripts/weatherbug.pl EGSC
DewPoint:1.2 HeatIndex:1.2
[root@localhost /]# usr/bin/perl /var/www/html/scripts/weatherbug.pl ABCD
DewPoint:1.2 HeatIndex:1.2
The script is:
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
my $httpaddr = "http://www.aws.com/aws_2001/asp/obsforecast.asp?id=?" . $ARGV[0];
my %data;
my %trash;
my $content = LWP::Simple::get($httpaddr) or die "Couldn't get it!";
# regex in html source order
if ($content =~ /(<b>Temperature<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(-?\d+\.\d+)<\/b>/g) { $data{Temp} = $1; }
if ($content =~ /(<b>Humidity<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Humidity} = $1; }
if ($content =~ /(<b>Wind<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)<\/b>/g) { $data{Wind} = $1; }
if ($content =~ /(<b>Daily Rain<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Rain} = $1; }
if ($content =~ /(<b>Pressure<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Pressure} = $1; }
if ($content =~ /(HEAT INDEX|WIND CHILL)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)/g) { $data{HeatIndex} = $1; }
if ($content =~ /(DEW POINT:)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)/g) { $data{DewPoint} = $1; }
for (keys %data) {
printf "%s:%s ", $_, $data{$_};
}
print "\n";
I notice that the variables that are returning are in CAPS - could this be the issue?
Thanks,
Lard
---- lard007skype ----
Please forgive me for spamming the forums - I had an errant "?" in the URL!lard wrote:Strange but when I run this code I always only get two variables returned - does not seem to matter what code I enter as the METAR:
[root@localhost /]# usr/bin/perl /var/www/html/scripts/weatherbug.pl EGSC
DewPoint:1.2 HeatIndex:1.2
[root@localhost /]# usr/bin/perl /var/www/html/scripts/weatherbug.pl ABCD
DewPoint:1.2 HeatIndex:1.2
The script is:
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
my $httpaddr = "http://www.aws.com/aws_2001/asp/obsforecast.asp?id=?" . $ARGV[0];
my %data;
my %trash;
my $content = LWP::Simple::get($httpaddr) or die "Couldn't get it!";
# regex in html source order
if ($content =~ /(<b>Temperature<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(-?\d+\.\d+)<\/b>/g) { $data{Temp} = $1; }
if ($content =~ /(<b>Humidity<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Humidity} = $1; }
if ($content =~ /(<b>Wind<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)<\/b>/g) { $data{Wind} = $1; }
if ($content =~ /(<b>Daily Rain<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Rain} = $1; }
if ($content =~ /(<b>Pressure<\/b>)/g) { $trash{a} = $1; }
if ($content =~ /<b>(\d+\.\d+)<\/b>/g) { $data{Pressure} = $1; }
if ($content =~ /(HEAT INDEX|WIND CHILL)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)/g) { $data{HeatIndex} = $1; }
if ($content =~ /(DEW POINT:)/g) { $trash{a} = $1; }
if ($content =~ /(\d+\.\d+)/g) { $data{DewPoint} = $1; }
for (keys %data) {
printf "%s:%s ", $_, $data{$_};
}
print "\n";
I notice that the variables that are returning are in CAPS - could this be the issue?
Thanks,
Lard
Best,
Lard
---- lard007skype ----
Sure - I'm in the UK and just googled for ICIA or WEBAR weatherstation codes on google.co.uk and hey presto it came out - the weatherstations all have a unique code, it's just that the site it uses to scrape only lets you search for US ones,qwertz wrote:what a beautiful script !!!
The "problem" is that i'm living in Switzerland /Europe ...
Is there a place where i could catch weather info for European countries ?
Thank you very much
Qwertz
Happy weather bugging
Cheerio,
Lard
---- lard007skype ----
Here's one for Geneva LSGGlard wrote:Sure - I'm in the UK and just googled for ICIA or WEBAR weatherstation codes on google.co.uk and hey presto it came out - the weatherstations all have a unique code, it's just that the site it uses to scrape only lets you search for US ones,qwertz wrote:what a beautiful script !!!
The "problem" is that i'm living in Switzerland /Europe ...
Is there a place where i could catch weather info for European countries ?
Thank you very much
Qwertz
Happy weather bugging
Cheerio,
Lard
Lard
---- lard007skype ----
The link I have for my area is =ottomatic wrote:Ok... After much frustration I figured out how this works.......
Step 7: Now... In all of the blanks that say... "get code from..." Go to that website and search for your code. Once have found the weather for your city. In the address bar there is a "?id=" and then there is a few letters... That is your code. Put that in all the blanks that say "get code from..." then click create at the bottom.
http://www.aws.com/aws_2001/asp/obsFore ... &srch.y=13
The problem is that in that url there is no "?id=" ... I can't seem to add anything that will work. Is there something else I can put in these fields?
-
- Posts: 14
- Joined: Thu May 04, 2006 11:53 am
Who is online
Users browsing this forum: No registered users and 4 guests