Weatherbug XML API script and templates
Moderators: Developers, Moderators
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.
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.
- Attachments
-
- wbugapi.zip
- (17.08 KiB) Downloaded 1812 times
Last edited by Mondo1287 on Mon May 21, 2007 10:00 am, edited 3 times in total.
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.
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.
-
- Posts: 17
- Joined: Wed Jul 12, 2006 11:25 pm
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...
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...
-
- Posts: 17
- Joined: Wed Jul 12, 2006 11:25 pm
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.
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.
-
- Posts: 17
- Joined: Wed Jul 12, 2006 11:25 pm
-
- Cacti User
- Posts: 379
- Joined: Fri Feb 16, 2007 11:37 am
- Location: Emeryville, CA
- Contact:
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
Thanks much
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]
[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]
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.
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 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.
Code: Select all
chmod -R 777 rra/ log/
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.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
-
- Posts: 2
- Joined: Thu Apr 19, 2007 11:31 am
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.
- Attachments
-
- weatherbug.jpg (151.71 KiB) Viewed 32921 times
-
- Posts: 3
- Joined: Thu May 17, 2007 9:57 pm
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.
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.
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.
Code: Select all
echo $url;
-
- Posts: 3
- Joined: Thu May 17, 2007 9:57 pm
You were right!
Thanks, I am embarrassed to say it was a typo in the Site ID... Thanks for your help!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.Code: Select all
echo $url;
- TheWitness
- Developer
- Posts: 17007
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
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
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
- Attachments
-
- wbugxml.zip
- (521 Bytes) Downloaded 1216 times
True understanding begins only when we realize how little we truly understand...
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Who is online
Users browsing this forum: No registered users and 1 guest