https://github.com/v-zhuravlev/zabbix-weather
Collect weather conditions from openweathermap.org using host coordinates
https://github.com/v-zhuravlev/zabbix-weather
openweathermap weather zabbix
Last synced: 11 days ago
JSON representation
Collect weather conditions from openweathermap.org using host coordinates
- Host: GitHub
- URL: https://github.com/v-zhuravlev/zabbix-weather
- Owner: v-zhuravlev
- License: gpl-3.0
- Created: 2016-12-07T08:50:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-05-15T19:49:26.000Z (almost 3 years ago)
- Last Synced: 2025-04-09T18:11:02.057Z (13 days ago)
- Topics: openweathermap, weather, zabbix
- Language: Perl
- Homepage:
- Size: 42 KB
- Stars: 20
- Watchers: 3
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zabbix-weather
Collect weather conditions from openweathermap.org using host coordinates and Zabbix built-in HTTP agent + some JS preprocessing (Zabbix 4.2), HTTP agent only ( Zabbix 4.0 ) or perl script(Zabbix < 4.0).## Get key from openweathermap
http://openweathermap.org/appid## Template
1. Import sample template for Zabbix 2.4-3.4 or for Zabbix 4.2, 4.0.Currently supported items:
| Item | key | via script(Zabbix 2.4+) | via HTTP agent(Zabbix 4.0) | via HTTP agent+JS* (Zabbix 4.2+) |
|------------|-----------|------------|------------|-----|
| Temperature | temp | Y | Y | Y|
|Humidity|humidity|Y|Y|Y|
|Visibility|visibility|Y|Y|Y|
|Is dark|is_dark|Y|N|Y*|
|Wind speed|wind.speed|Y|Y|Y|
|Weather status|weather|Y|Y|Y|
|Weather description|weather.description|Y|Y|Y|
|Weather condition id |weather.condition.id|Y|Y|Y|2. Add global/template level Macro
`{$WEATHER_APIKEY} = YOURKEY`
add another global macro as prefered language for weather descriptions:
`{$WEATHER_LANG} = en`## Setup hosts
Add macros {$LAT} and {$LON} for each host that requires weather monitoring:
## Install the script(only for Zabbix < 4.0)
For Zabbix 2.4-3.4, please read below how to setup the collector script.
0. Dependencies
The script is written in Perl and you will need common modules in order to run it:
```
LWP
JSON::XS
```
There are numerous ways to install them:| in Debian | In Centos | using CPAN | using cpanm|
|------------|-----------|------------|------------|
| `apt-get install libwww-perl libjson-xs-perl` | `yum install perl-JSON-XS perl-libwww-perl perl-LWP-Protocol-https` | `PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install Bundle::LWP'` and `PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install JSON::XS'`| `cpanm install LWP` and `cpanm install JSON::XS`|
1. place get_weather.pl into externalscripts folder
then:
`chmod +x get_weather.pl`
`chown zabbix:zabbix get_weather.pl`
2. Check that it is working
`./get_weather.pl -lat 55.672944 -lon 38.478944 --hostname TEST --api_key YOURKEY`
You should receive `OK` as script output.2.1. If you need to use http proxy:
Make sure that you have environment variables `http_proxy` and `https_proxy` defined under user `zabbix`
For example:
```
export http_proxy=http://proxy_ip:3129/
export https_proxy=$http_proxy
./get_weather.pl -lat 55.672944 -lon 38.478944 --hostname TEST --api_key YOURKEY
```
## Demo
And that is it:

## More
Note: It would more logical to use Latitue and Longitude Inventory fields and not user macros, but {INVENTORY.*} values cannot be used in items keys.
A feature request to change that is here: https://support.zabbix.com/browse/ZBXNEXT-2546.