Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Wed Jul 17, 2019 9:40 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 51 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: AccuWeather script & templates
PostPosted: Tue Aug 09, 2005 1:46 am 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
This script monitors 22 different weather variables off the accuweather site. It is a standard perl html scraper script.

enjoy!

P.S. The results, as you can see, arent that accurate. I have another post with WeatherBug scrapes here: http://forums.cacti.net/viewtopic.php?p=38926 but its only 6 variables.

You need the LWP::Simple perl module installed


Attachments:
AccuWeather.pl.txt [1.68 KiB]
Downloaded 3167 times
cacti_host_template_accuweather.xml [59.46 KiB]
Downloaded 3503 times
accu.png
accu.png [ 31.42 KiB | Viewed 45682 times ]


Last edited by Alives on Tue Aug 09, 2005 2:02 pm, edited 2 times in total.
Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 12:34 pm 
Offline
Cacti User

Joined: Mon Nov 29, 2004 11:34 am
Posts: 67
When I run the script from the command line as the cactiuser I get what looks like the proper output, howver when the poller runs it, it fails.

Command Line Output:
sh-3.00$ scripts/AccuWeather.pl b3l1s3
Dewpoint:25 Humidity:99 WindChill:27 Departure:22 LowPast6hrs:17 ApparentTemp:25 MaxTemp:22 CloudCover:100 MinTemp:25 HighPast6hrs:25


Poller Ouput:
08/09/2005 02:18:45 PM - CMDPHP: Poller[0] Host[115] DS[1404] WARNING: Result from CMD not valid. Partial Result:
08/09/2005 02:18:45 PM - CMDPHP: Poller[0] Host[115] DS[1404] CMD: perl /var/www/html/cacti/scripts/AccuWeather.pl b3l1s3, output: U

Note, that I had to change the URL in the script to make it work for Canada and to show metric.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 1:14 pm 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
yeah... try putting that in quotes or just hardcoding it to the script... your input uses the pipe, |, which i think your shell is trying to interpret. easiest thing to do is to just hard code your script since you probably dont need the flexibility too much...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 2:41 am 
Offline

Joined: Mon Aug 08, 2005 5:14 am
Posts: 12
Location: france - toulouse
Hi,
when I import the accuweather_template, Cacti says : Error: XML: Hash version does not exist. :x
My Cacti version is 0.8.6c
I don't find where is the bug ??


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 7:39 am 
Offline
Cacti User

Joined: Mon Nov 29, 2004 11:34 am
Posts: 67
I couldn't import the file but I could copy/paste the contents of the file into the import area.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 8:20 am 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
this was made using cacti 0.8.6f


Top
 Profile  
 
 Post subject: Hash Error
PostPosted: Fri Aug 12, 2005 8:26 am 
Offline
Cacti User

Joined: Tue May 03, 2005 8:54 am
Posts: 298
Location: GA
I found a Hash error while importing into my cacti version f/// its on like line 112 , a variable RealFeel had the trademark symbol right after the work RealFeel, cacti or xml didnlt like that for me, i just removed it and saved the xml template and re-imported it// worked perfectly/


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 24, 2005 9:16 am 
Offline
Cacti User

Joined: Tue May 03, 2005 8:54 am
Posts: 298
Location: GA
Anyone using this accuweather script??

Does anyone notice that the Humidity is always 50% /// I ran this script agains like 5 zipcodes, always 50 %. Has anyone noitced this, corrected it?? How??

THanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 24, 2005 9:56 am 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
accuweather isnt all that accurate...thats why i did the weatherbug script... its VERY accurate with live updating.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 8:43 am 
Offline
Cacti User

Joined: Tue May 03, 2005 8:54 am
Posts: 298
Location: GA
I understand that but i dont think its accuweathers' site, I ran the script against 5 or so ziips. All said 50 % , even the pics in this thread say 50% for Humidity.....i think its the script?? I just dont see anything wrong right off, and i'm not the best with scripts or code?? Just was wondering if anyone had fixed that variable that pulls Humidity??

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 9:59 am 
Offline
Cacti User

Joined: Mon Jul 11, 2005 11:39 am
Posts: 103
it is the script... i would be honored if you would fix it as i am only working on the weatherbug one at this point. its just a simple regex, and, as many people will reply, you arent supposed to grab html pages with regex's... but whatever... it was quick adn easy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 10:13 am 
Offline
Cacti User

Joined: Tue May 03, 2005 8:54 am
Posts: 298
Location: GA
Calling all Perl Gurus' >> It seems to me the Accuweather scripts has a few flaws in it

if ($content =~ /(\d+)%/g) { $data{Humidity} = $1; }
if ($content =~ /(\d+)%/g) { $data{CloudCover} = $1; }

Those 2 are what I see wrong anyhow, no matter what zip you run the script against it pulls back 50% for Humidity and 99% for cloudcover. All the time!!! I think the search string above is messed up or something or its just finding the wrong data in the source of that web page. Its almost like its pulling back cell width % or something!!! Anyone feel like looking at it more to see if you see what's wrong??

Thanks all.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 6:53 am 
Offline

Joined: Tue Aug 30, 2005 5:17 am
Posts: 4
Change lines to these:
if ($content =~ /(\d+)%</g) { $data{Humidity} = $1; }
if ($content =~ /(\d+)%</g) { $data{CloudCover} = $1; }


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 8:07 am 
Offline
Cacti User

Joined: Tue May 03, 2005 8:54 am
Posts: 298
Location: GA
That did it, all variables now report the correct #'s !!! Thanks for that, I searched all kinds of regex characters and didnt' see that one, yet again i'm not a perl guy!! Thanks again!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 8:10 am 
Offline
Cacti User

Joined: Tue May 03, 2005 8:54 am
Posts: 298
Location: GA
Updated Accuweather perl script with corrected variables ( Humidity and CloudCover both reporting 50% for no matter what zip you add ) !! Thanks for the help zoltar!!!


Attachments:
accuweather.pl.txt [1.7 KiB]
Downloaded 2339 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group