Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Tue Jun 25, 2019 1:05 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Weatherbug XML API script and templates
PostPosted: Tue Feb 06, 2007 10:18 pm 
Offline

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


Last edited by Mondo1287 on Mon May 21, 2007 10:00 am, edited 3 times in total.
Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 3:56 pm 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 13, 2007 9:28 pm 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 10:05 am 
Offline

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

Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 1:26 pm 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 3:37 pm 
Offline
Cacti User

Joined: Fri Feb 16, 2007 11:37 am
Posts: 372
Location: Emeryville, CA
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

_________________
Cacti Version - 0.8.7b
Plugin Architecture - 2.2 Beta
Poller Type - CMD.php
Server Info - Linux 2.6.9-78.0.1.ELsmp
Web Server - Apache/2.0.52 (Red Hat)
PHP - 4.3.9
MySQL - 4.1.22
RRDTool - 1.2.23
SNMP - 5.1.2
Plugins
    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)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 9:19 am 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 3:04 pm 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 3:18 pm 
Offline

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


Top
 Profile  
 
 Post subject: Gaps in graphs?
PostPosted: Tue May 01, 2007 3:14 pm 
Offline

Joined: Thu Apr 19, 2007 11:31 am
Posts: 2
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 25290 times ]
Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 6:01 am 
Offline

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


Top
 Profile  
 
 Post subject: Fatal Error on wbugxml.php from command line
PostPosted: Thu May 17, 2007 10:09 pm 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 10:32 am 
Offline

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


Top
 Profile  
 
 Post subject: You were right!
PostPosted: Sun May 20, 2007 9:32 pm 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 6:05 am 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14804
Location: MI, USA
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 862 times

_________________
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google Adsense [Bot] 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