|
|
| Author |
Message |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Wed Mar 22, 2006 11:56 am Post subject: |
|
|
| 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. |
Many thanks for the clear and consise instructions - I will give it a go now and hopefully it will be a breeze ( ) |
|
| Back to top |
|
 |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Wed Mar 22, 2006 12:19 pm Post subject: |
|
|
o.k. - all fine apart from not being prompted for the code when creating the graphs...can I just change this in the data imput method or is there a better way perhaps?
Thanks,
Lard |
|
| Back to top |
|
 |
ottomatic
Joined: 20 Mar 2006 Posts: 9
|
Posted: Wed Mar 22, 2006 2:12 pm Post subject: |
|
|
| 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." |
|
| Back to top |
|
 |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Wed Mar 22, 2006 2:18 pm Post subject: |
|
|
| 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." |
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,
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 |
|
| Back to top |
|
 |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Fri Mar 24, 2006 7:42 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Fri Mar 24, 2006 7:47 am Post subject: |
|
|
| 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 |
Please forgive me for spamming the forums - I had an errant "?" in the URL!
Best,
Lard |
|
| Back to top |
|
 |
qwertz Cacti User
Joined: 16 Feb 2006 Posts: 98
|
Posted: Fri Mar 24, 2006 9:36 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Fri Mar 24, 2006 9:54 am Post subject: |
|
|
| 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 |
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,
Happy weather bugging
Cheerio,
Lard |
|
| Back to top |
|
 |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Fri Mar 24, 2006 9:57 am Post subject: |
|
|
| lard wrote: | | 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 |
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,
Happy weather bugging
Cheerio,
Lard |
Here's one for Geneva LSGG
Lard |
|
| Back to top |
|
 |
qwertz Cacti User
Joined: 16 Feb 2006 Posts: 98
|
Posted: Fri Mar 24, 2006 1:46 pm Post subject: |
|
|
| THANK YOU |
|
| Back to top |
|
 |
kegrif
Joined: 29 Mar 2006 Posts: 1
|
Posted: Wed Mar 29, 2006 6:45 pm Post subject: |
|
|
I still get this error when trying to import the XML file
Error: XML: Hash version does not exist.
I am running on Debian with Cacti Version 0.8.6c
Thanks. |
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12295 Location: Muenster, Germany
|
Posted: Thu Mar 30, 2006 11:04 am Post subject: |
|
|
This seems to be a downlevel cacti. Importing must be performed with at least the same level as exporting. And 0.8.6c is quite outdated
Reinhard |
|
| Back to top |
|
 |
tkdan235
Joined: 27 Apr 2006 Posts: 17 Location: Sacramento, Ca
|
Posted: Tue May 09, 2006 2:00 pm Post subject: |
|
|
| 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.
|
The link I have for my area is =
http://www.aws.com/aws_2001/asp/obsForecast.asp?zipcode=95814&srch.x=19&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? |
|
| Back to top |
|
 |
Jeff_Smith
Joined: 04 May 2006 Posts: 14
|
Posted: Wed May 10, 2006 12:19 pm Post subject: |
|
|
| Below the stats there is a link to Full Observation. click that link and pull the ID from that URL. |
|
| Back to top |
|
 |
tkdan235
Joined: 27 Apr 2006 Posts: 17 Location: Sacramento, Ca
|
Posted: Tue May 16, 2006 12:39 pm Post subject: |
|
|
That is bring up the id, which for me is = KSAC
When I entered this code, it went through, but there is no data in my graphs. I am running 0.8.6g, and the rest of my graphs are working fine. I also tried entering = KSAC&obs=full just in case, but with no avail.
Any suggestions? |
|
| Back to top |
|
 |
|