|
|
| Author |
Message |
Mondo1287
Joined: 11 Oct 2006 Posts: 15
|
Posted: Tue Feb 06, 2007 10:18 pm Post subject: Weatherbug XML API script and templates |
|
|
The following is a simple implementation of WeatherBug's API, and Cacti to create some basic weather graphs. You'll need to register with WeatherBug to receive an "API Code". http://apireg.weatherbug.com/defaultAPI.aspx
This is probably not bug free, but seems to work well. Future updates will likely include more data from WeatherBug's API calls, such as adding predicted highs and lows to the temperature graph.
Note: I am in no way affiliated with WeatherBug.
Open the README file for further instructions.
I was hoping to create something a little easier to work with than the other cacti weather graphing solutions. Comments and criticisms are welcome.
Edit: You may need to edit php.ini and set allow_url_fopen = on
e.g. /etc/php/cli-php5/php.ini
I updated the graph templates and data template to handle negative numbers.
Edit: Added in TheWitness's modified polling script.
| Description: |
|
 Download |
| Filename: |
wbugapi.zip |
| Filesize: |
17.08 KB |
| Downloaded: |
383 Time(s) |
Last edited by Mondo1287 on Mon May 21, 2007 10:00 am; edited 3 times in total |
|
| Back to top |
|
 |
Mondo1287
Joined: 11 Oct 2006 Posts: 15
|
Posted: Wed Feb 07, 2007 3:56 pm Post subject: |
|
|
I updated the templates to handle negative numbers. If you already downloaded them, import the updated templates (it will just update the existing ones). Then navigate to <cacti path>/rra/ and run
rrdtool tune <rrd filename> --minimum DewPoint:-200
rrdtool tune <rrd filename> --minimum Temperature:-200
You can find the rrd filename by clicking Data Sources, then choose WeatherBug API DS.
|
|
| Back to top |
|
 |
MaffooClock
Joined: 12 Jul 2006 Posts: 17
|
Posted: Tue Mar 13, 2007 9:28 pm Post subject: |
|
|
I like this better than the other Weatherbug script, especially since this uses an XML API.
Cuerrently, I have the dreaded 'nan' issue with this, however, running the wbugxml.php script at the command-line produced values.
Regardless, once I figure out what my problem is, I'd like to tweak this more and get as much data from the API graphed as possible (as long as you don't mind, of course).
I'll post more feedback as I come across new issues/ideas...
|
|
| Back to top |
|
 |
MaffooClock
Joined: 12 Jul 2006 Posts: 17
|
Posted: Wed Mar 14, 2007 10:05 am Post subject: |
|
|
I spent HOURS troubleshooting the 'nan' issue and I didn't get anywhere. (By the way, I should mention that I am very proficient with Linux, PHP, MySQL, and Cacti.)
I noticed that I had not followed your instructions for installing the templates, so I removed ALL associated graph templates, data templates, data sources, graphs -- everything. I then re-installed all of this by following your instructions precisely. At that point, the graphs weren't being drawn at all. I found that because they are not associated with any hosts, they are never placed in the poller cache. Am I right about this? When I created a dummy host and re-associated all of the data sources and graphs to the new dummy host, the poller cache showed an entry, and the graphs were being generated (but still showing 'nan values').
I should mention that I created a test database for cacti aside from my operational cacti database so that I could tinker with this more. So, essentially, I have a brand new cacti installation, so all of these symptoms cannot be attributed to database corruption or any other misconfiguration.
As the author of these script/templates, I'm certain they work for you. But there's something you're missing (I think), especially when you wrote the README. I hope you'll have some time to help me with this, and I'll be happy to contribute any way I can to making this work for everyone.
But, hopefully I am just stupid and have missed something, and someone will point it out, call me an idiot, and then all will be well.
Last edited by MaffooClock on Wed Mar 14, 2007 4:56 pm; edited 1 time in total |
|
| Back to top |
|
 |
MaffooClock
Joined: 12 Jul 2006 Posts: 17
|
Posted: Wed Mar 14, 2007 1:26 pm Post subject: |
|
|
| Well, at this point, it seems that I have fixed my graphs. I removed all graphs, data sources, input methods, and everything else. Then, I installed everything according to the README, but then created a dummy host and assigned the data sources and graphs to that host. Now I have data in my graphs.
|
|
| Back to top |
|
 |
apperrault Cacti User
Joined: 16 Feb 2007 Posts: 351 Location: Emeryville, CA
|
Posted: Tue Mar 20, 2007 3:37 pm Post subject: |
|
|
Question, is there a way to setup multiple locations? I have 5 across the country, and one in Canada, and I would love to be able to add all of my sites to my Weather graph group.
Thanks much
app
|
|
| Back to top |
|
 |
Mondo1287
Joined: 11 Oct 2006 Posts: 15
|
Posted: Mon Mar 26, 2007 9:19 am Post subject: |
|
|
| MaffooClock, sorry for the late reply. Have you checked to ensure the script is working? Try running wbugxml.php from a shell prompt and make sure there are no errors. It should just output the weather values. I haven't looked at this in quite some time, so I'll try and do a clean install following my instructions and see if there's something I left out.
|
|
| Back to top |
|
 |
Mondo1287
Joined: 11 Oct 2006 Posts: 15
|
Posted: Mon Mar 26, 2007 3:04 pm Post subject: |
|
|
I just did a fresh install of Cacti and I didn't have any issues with my script or templates. I did, however, run into a couple of problems I seem to usually have when installing Cacti. Permission problems with the rra and log folders are common. For testing purposes just do | Code: | | chmod -R 777 rra/ log/ | from the cacti folder. If you are having nan problems on a fresh install, make sure that cacti is functioning correctly. Create a standard snmp graph for example just to make sure the poller and everything is functioning properly.
|
|
| Back to top |
|
 |
Mondo1287
Joined: 11 Oct 2006 Posts: 15
|
Posted: Mon Mar 26, 2007 3:18 pm Post subject: |
|
|
| apperrault wrote: | Question, is there a way to setup multiple locations? I have 5 across the country, and one in Canada, and I would love to be able to add all of my sites to my Weather graph group.
Thanks much
app |
I can't think of a simple solution for this. I wouldn't mind being able to graph multiple locations myself, so if I get around to it I'll post a write up and probably some updated templates and a script.
|
|
| Back to top |
|
 |
cacti_user_md
Joined: 19 Apr 2007 Posts: 2
|
Posted: Tue May 01, 2007 3:14 pm Post subject: Gaps in graphs? |
|
|
Has anyone else had any problems with gaps in the Weatherbug graphs? The problem seems to be with the Weatherbug server and not Cacti. The gaps appear much more frequently during the day than at night, so it might be caused by heavy traffic to Weatherbug. Just looking for ideas.
| Description: |
|
| Filesize: |
151.71 KB |
| Viewed: |
8548 Time(s) |

|
|
|
| Back to top |
|
 |
Mondo1287
Joined: 11 Oct 2006 Posts: 15
|
Posted: Wed May 02, 2007 6:01 am Post subject: |
|
|
| I have the same gaps in my graphs so it must be their server. There is usually an occasional gap but this week there seems to be a ton of them.
|
|
| Back to top |
|
 |
tstrathdee
Joined: 17 May 2007 Posts: 3
|
Posted: Thu May 17, 2007 10:09 pm Post subject: Fatal Error on wbugxml.php from command line |
|
|
After installing, I wasn't getting any data on my graphs so I tried to run wbugxml.php from the command line. I am getting the following error message
Fatal error: Call to a member function children() on a non-object in /var/www/cacti/scripts/wbugxml.php on line 10
Any ideas on what might be causing this?
Thanks.
|
|
| Back to top |
|
 |
Mondo1287
Joined: 11 Oct 2006 Posts: 15
|
Posted: Fri May 18, 2007 10:32 am Post subject: |
|
|
It may be a problem with PHP not having simplexml support compiled in, but I would assume it would fail on line 7 if that was the case. It sounds like it's not loading the xml data from their website. Comment out lines 10-24, and then add
Run it from the command line and it should give you the URL it is using, paste that in your browser and you should see the xml. If you get some kind of error then something is probably wrong with your api code, station id, or zipcode.
|
|
| Back to top |
|
 |
tstrathdee
Joined: 17 May 2007 Posts: 3
|
Posted: Sun May 20, 2007 9:32 pm Post subject: You were right! |
|
|
| Mondo1287 wrote: | It may be a problem with PHP not having simplexml support compiled in, but I would assume it would fail on line 7 if that was the case. It sounds like it's not loading the xml data from their website. Comment out lines 10-24, and then add
Run it from the command line and it should give you the URL it is using, paste that in your browser and you should see the xml. If you get some kind of error then something is probably wrong with your api code, station id, or zipcode. |
Thanks, I am embarrassed to say it was a typo in the Site ID... Thanks for your help!
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9689 Location: MI, USA
|
Posted: Mon May 21, 2007 6:05 am Post subject: |
|
|
All,
Reviewing Mondo1287's script, I noted an issue relative to the outputing of the script results. The method chosen will cause problems with Cactid. Therefore, I have revised the code attached.
TheWitness
| Description: |
|
 Download |
| Filename: |
wbugxml.zip |
| Filesize: |
521 Bytes |
| Downloaded: |
234 Time(s) |
|
|
| Back to top |
|
 |
|