Weatherbug XML API script and templates

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Mondo1287
Posts: 15
Joined: Wed Oct 11, 2006 8:08 am

Weatherbug XML API script and templates

Post by Mondo1287 »

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.
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.
Mondo1287
Posts: 15
Joined: Wed Oct 11, 2006 8:08 am

Post by Mondo1287 »

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.
MaffooClock
Posts: 17
Joined: Wed Jul 12, 2006 11:25 pm

Post by MaffooClock »

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...
MaffooClock
Posts: 17
Joined: Wed Jul 12, 2006 11:25 pm

Post by MaffooClock »

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.
MaffooClock
Posts: 17
Joined: Wed Jul 12, 2006 11:25 pm

Post by MaffooClock »

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.
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

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
[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]
Mondo1287
Posts: 15
Joined: Wed Oct 11, 2006 8:08 am

Post by Mondo1287 »

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.
Mondo1287
Posts: 15
Joined: Wed Oct 11, 2006 8:08 am

Post by Mondo1287 »

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: Select all

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.
Mondo1287
Posts: 15
Joined: Wed Oct 11, 2006 8:08 am

Post by Mondo1287 »

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.
cacti_user_md
Posts: 2
Joined: Thu Apr 19, 2007 11:31 am

Gaps in graphs?

Post by cacti_user_md »

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
weatherbug.jpg (151.71 KiB) Viewed 32929 times
Mondo1287
Posts: 15
Joined: Wed Oct 11, 2006 8:08 am

Post by Mondo1287 »

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.
tstrathdee
Posts: 3
Joined: Thu May 17, 2007 9:57 pm

Fatal Error on wbugxml.php from command line

Post by tstrathdee »

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.
Mondo1287
Posts: 15
Joined: Wed Oct 11, 2006 8:08 am

Post by Mondo1287 »

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

Code: Select all

echo $url;
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.
tstrathdee
Posts: 3
Joined: Thu May 17, 2007 9:57 pm

You were right!

Post by tstrathdee »

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

Code: Select all

echo $url;
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!
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

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
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?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest