# OpenWeatherMap by HTTP ## Overview This template is designed for the effortless deployment of OpenWeatherMap monitoring by Zabbix via HTTP and doesn't require any external scripts. ## Requirements Zabbix version: 7.0 and higher. ## Tested versions This template has been tested on: - OpenWeatherMap API ## Configuration > Zabbix should be configured according to the instructions in the [Templates out of the box](https://www.zabbix.com/documentation/7.0/manual/config/templates_out_of_the_box) section. ## Setup 1. Create a host. 2. Link the template to the host. 3. Customize the values of {$OPENWEATHERMAP.API.TOKEN} and {$LOCATION} macros. OpenWeatherMap API Tokens are available in your OpenWeatherMap account https://home.openweathermap.org/api_keys. Locations can be set by few ways: - by geo coordinates (for example: 56.95,24.0833) - by location name (for example: Riga) - by location ID. Link to the list of city ID: http://bulk.openweathermap.org/sample/city.list.json.gz - by zip/post code with a country code (for example: 94040,us) A few locations can be added to the macro at the same time by `|` delimiter. For example: `43.81821,7.76115|Riga|2643743|94040,us`. Please note that API requests by city name, zip-codes and city id will be deprecated soon. Language and units macros can be customized too if necessary. List of available languages: https://openweathermap.org/current#multi. Available units of measurement are: standard, metric and imperial https://openweathermap.org/current#data. ### Macros used |Name|Description|Default| |----|-----------|-------| |{$OPENWEATHERMAP.API.TOKEN}|

Specify openweathermap API key.

|| |{$LANG}|

List of available languages https://openweathermap.org/current#multi.

|`en`| |{$LOCATION}|

Locations can be set by few ways:

1. by geo coordinates (for example: 56.95,24.0833)

2. by location name (for example: Riga)

3. by location ID. Link to the list of city ID: http://bulk.openweathermap.org/sample/city.list.json.gz

4. by zip/post code with a country code (for example: 94040,us)

A few locations can be added to the macro at the same time by `\|` delimiter.

For example: `43.81821,7.76115\|Riga\|2643743\|94040,us`.

Please note that API requests by city name, zip-codes and city id will be deprecated soon.

|`Riga`| |{$OPENWEATHERMAP.API.ENDPOINT}|

OpenWeatherMap API endpoint.

|`api.openweathermap.org/data/2.5/weather?`| |{$UNITS}|

Available units of measurement are standard, metric and imperial https://openweathermap.org/current#data.

|`metric`| |{$OPENWEATHERMAP.DATA.TIMEOUT}|

Response timeout for OpenWeatherMap API.

|`3s`| |{$TEMP.CRIT.HIGH}|

Threshold for high temperature trigger.

|`30`| |{$TEMP.CRIT.LOW}|

Threshold for low temperature trigger.

|`-20`| ### Items |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Openweathermap: Get data|

JSON array with result of OpenWeatherMap API requests.

|Script|openweathermap.get.data| |Openweathermap: Get data collection errors|

Errors from get data requests by script item.

|Dependent item|openweathermap.get.errors

**Preprocessing**

| ### Triggers |Name|Description|Expression|Severity|Dependencies and additional info| |----|-----------|----------|--------|--------------------------------| |Openweathermap: There are errors in requests to OpenWeatherMap API|

Zabbix has received errors in requests to OpenWeatherMap API.

|`length(last(/OpenWeatherMap by HTTP/openweathermap.get.errors))>0`|Average|**Manual close**: Yes| ### LLD rule Locations discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Locations discovery|

Weather metrics discovery by location.

|Dependent item|openweathermap.locations.discovery

**Preprocessing**

| ### Item prototypes for Locations discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |[{#LOCATION}, {#COUNTRY}]: Data|

JSON with result of OpenWeatherMap API request by location.

|Dependent item|openweathermap.location.data[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Atmospheric pressure|

Atmospheric pressure in Pa.

|Dependent item|openweathermap.pressure[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Cloudiness|

Cloudiness in %.

|Dependent item|openweathermap.clouds[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Humidity|

Humidity in %.

|Dependent item|openweathermap.humidity[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Rain volume for the last one hour|

Rain volume for the lat one hour in m.

|Dependent item|openweathermap.rain[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Short weather status|

Short weather status description.

|Dependent item|openweathermap.description[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Snow volume for the last one hour|

Snow volume for the lat one hour in m.

|Dependent item|openweathermap.snow[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Temperature|

Atmospheric temperature value.

|Dependent item|openweathermap.temp[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Visibility|

Visibility in m.

|Dependent item|openweathermap.visibility[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Wind direction|

Wind direction in degrees.

|Dependent item|openweathermap.wind.direction[{#ID}]

**Preprocessing**

| |[{#LOCATION}, {#COUNTRY}]: Wind speed|

Wind speed value.

|Dependent item|openweathermap.wind.speed[{#ID}]

**Preprocessing**

| ### Trigger prototypes for Locations discovery |Name|Description|Expression|Severity|Dependencies and additional info| |----|-----------|----------|--------|--------------------------------| |[{#LOCATION}, {#COUNTRY}]: Temperature is too high|

Temperature value is too high.

|`min(/OpenWeatherMap by HTTP/openweathermap.temp[{#ID}],#3)>{$TEMP.CRIT.HIGH}`|Average|**Manual close**: Yes| |[{#LOCATION}, {#COUNTRY}]: Temperature is too low|

Temperature value is too low.

|`max(/OpenWeatherMap by HTTP/openweathermap.temp[{#ID}],#3)<{$TEMP.CRIT.LOW}`|Average|**Manual close**: Yes| ## Feedback Please report any issues with the template at [`https://support.zabbix.com`](https://support.zabbix.com) You can also provide feedback, discuss the template, or ask for help at [`ZABBIX forums`](https://www.zabbix.com/forum/zabbix-suggestions-and-feedback)