Weather monitoring with Zabbix, Weather Underground API, Python and PostgreSQL
Simple Python script for getting weather conditions for some certain city. (Example: Bratislava) and writing them to PostgreSQL database. Then we need to have a Zabbix server somewhere around, so we can watch some pretty graphs regarding temperature, pressure, dew point and so on..
This is just a first random draft, so do not expect much.
Disclaimer: All the steps,configs,scripts and templates are dealing with example weather for city "Bratislava" (Slovak Republic.) Change it accordingly.
- Create PostgreSQL user and database
weather+ grant him all the privileges over it.
- Create PostgreSQL table
conditions_your-cityby executing query in
- Append lines from
zabbx_agentd.confon your system.
- Create directory:
- Add scripts from
zabbix/scripts/*to your newly created dir from previous step.
- Import Weather template
zabbix/templatet-weather.xmlinto your ZABBIX server.
- Add cronjob
zabbix/crontab.listinto your cron daemon.
- Restart your ZABBIX agent daemon.
- Every 30 minutes the
conditionsPython script will request JSON file with current weather data from Weather Underground. (http://www.wunderground.com/)
- ZABBIX server will be periodically asking for these values:
- You can view graphs.
- Add weather forecast.
- Add triggers for temperature and it's actions - e.g. sending mail.
- Write blogpost with some closer looks.