Weather Data: Temperature, Windspeed, Humidity, Air Pressure

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

Post Reply
blubbersuelze
Posts: 40
Joined: Mon Jun 15, 2009 12:55 pm

Weather Data: Temperature, Windspeed, Humidity, Air Pressure

Post by blubbersuelze »

#######################################################################
#
# This Cacti Addon is for getting:
# - Temperature Data
# - Humidity
# - Wind Speed
# - Air Pressure
# from the Locations you'd want Monitor (maybe Server Locations)
# via Openweather graphed in Cacti
#
#######################################################################
1)
You need to have Python Modul 'simplejson' installed.

If you are not familiar with Python you have to do this
(based on a Debian System):

Code: Select all

apt-get install python-pip
2)
after this you have to do this:

Code: Select all

pip install simplejson
3)
now copy openweathermap_data.py to the scripts-Directory
(On Debian Systems it's in "/usr/share/cacti/site/scripts/" )

4)
import the Templates in Cacti with "Import Templates"

5)
The last point is an optical Feature, with CDEF-Functions for Temperature Graph

You have to create 2 easy CDEF Functions,
(maybe there will be an export Function for CDEF in future versions of Cacti too):

go to "Graph Management" -> CDEFs
click on "Add"

give the name "Greater 0" and click on Create
now click on Add
now do this:
Type: Special Data Source
Value: CURRENT_DATA_SOURCE
(Create)
Type: Custom String
Value: 0
(Create)
Type: Function
Value: MAX
now click on Save

NOW
click on "Graph Management" -> CDEFs again
(yes again, its for creating the second one)
click on "Add"

give the name "Lower 0" and click on Create
now click on Add
now do this:
Type: Special Data Source
Value: CURRENT_DATA_SOURCE
(Create)
Type: Custom String
Value: 0
(Create)
Type: Function
Value: MIN
now click on Save

DONE

USAGE:
Now when you select in Devices an Host click on "Create Graphs for this Host",
select in the Section "Graph Templates" (formally the first one) from the Selection Box "open Weather Map - <the Datatype you want to monitor>"
and click CREATE on the bottom of this Page,
you will be asked for City and Country to get the Temperatures.
(Maybe London uk, or Berlin de, or Paris fr ?)


Tip:
In the first minutes the Title in Graph Template seems to be incomplete.
I found out, if you've got some values in the Graph,
select the Open Weather Map - Graph Template in Graph Templates,
click on save,
now there should be the City and Country listed in the Graph like expected.


Have fun with this Cacti Addon
temperature
temperature
temperature.png (15.46 KiB) Viewed 12997 times
windspeed
windspeed
windspeed.png (13.74 KiB) Viewed 12997 times
humidity
humidity
humidity.png (13.14 KiB) Viewed 12997 times
pressure
pressure
pressure.png (13.92 KiB) Viewed 12997 times
Attachments
openweather.zip
Templates
(13.33 KiB) Downloaded 573 times
elRadix
Posts: 3
Joined: Fri May 02, 2014 9:35 am

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pres

Post by elRadix »

Thank for your sharing this!

Can you let us know where to apply the CDEF in which graphs? on all Min and Max ones?
blubbersuelze
Posts: 40
Joined: Mon Jun 15, 2009 12:55 pm

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pres

Post by blubbersuelze »

here are some Pictures, i hope it will help to understand the written Description.

CDEF's can be handled here:
1
1
1.jpg (22.44 KiB) Viewed 12917 times
here you see greater 0 CDEF ready configured
2
2
2.jpg (56.47 KiB) Viewed 12917 times
here is the Line1 Configuration in Graph Template for Temperature with the CDEF Template:
(the CDEF Templates lower 0 and greater 0 are only needed at the Line-Graph's in the Temperature Template.)
3
3
3.jpg (116.92 KiB) Viewed 12917 times
stroem
Posts: 5
Joined: Wed Mar 04, 2015 6:49 am

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pres

Post by stroem »

You must use an API key for working
It's free
Then you change in script :
add a new variable
api ="&appid=xxxxxxxxxxxxxxxxxxxxxxxxx" where xxxxxxxxxx is your api key
and change
result = simplejson.load(urllib.urlopen(url + city + ',' + country + api))
blubbersuelze
Posts: 40
Joined: Mon Jun 15, 2009 12:55 pm

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pres

Post by blubbersuelze »

you are right,

Openweather Map added a free Registration for the Usage of the API.

The Information to get a API Key can be found in the Script, where to place the Key also.

I updated the Script to handle the API Key.
Attachments
openweather.zip
(13.4 KiB) Downloaded 434 times
uclabsllc2018
Posts: 20
Joined: Sun Apr 17, 2022 8:50 am

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pressure

Post by uclabsllc2018 »

This is not working at getting DATA from OpenWeathrMap in the latest version of Cacti!!!!!
uclabsllc2018
Posts: 20
Joined: Sun Apr 17, 2022 8:50 am

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pressure

Post by uclabsllc2018 »

Had to completely rewrite the Python Script. Now it works as of 2022 !!
ledeni
Posts: 1
Joined: Fri Apr 28, 2023 6:28 pm

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pressure

Post by ledeni »

uclabsllc2018 wrote: Tue Apr 19, 2022 7:43 am Had to completely rewrite the Python Script. Now it works as of 2022 !!
Can you share your Python Script,I have my api key but can't populate data. :(
Never mind like you said need to rewrite Python Script and set database for cacti but it is doable
Screenshot from 2023-05-02 20-59-05.png
Screenshot from 2023-05-02 20-59-05.png (81.05 KiB) Viewed 5867 times
phoner
Posts: 1
Joined: Thu Jun 30, 2016 2:42 pm

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pressure

Post by phoner »

Can you share the working script?

I've noticed the old script will no longer work with newer versions of python.
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Weather Data: Temperature, Windspeed, Humidity, Air Pressure

Post by TheWitness »

Unfortunately, they have monitized. You need to feed an API key. Simple change...

https://openweathermap.org/api

Too bad.
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