Code Monkey home page Code Monkey logo

zabbix-weather's Introduction

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
  1. 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:
image

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:
screencapture--1481663617632

image

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.