Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Khaliev <vyacheslav.khaliev@zabbix.com>2022-03-24 14:38:25 +0300
committerVyacheslav Khaliev <vyacheslav.khaliev@zabbix.com>2022-03-24 14:38:25 +0300
commitbf2f1297f3e713e90b889ef927c9ee4050ca5e2b (patch)
tree142cf84d38548028ad852aa5e8bf2194772d2032 /templates
parentde737cb624b0860b9be19471825d7375ce37ad4d (diff)
.........T [ZBXNEXT-6781] updated openweathermap template
Diffstat (limited to 'templates')
-rw-r--r--templates/app/openweathermap_http/README.md33
-rw-r--r--templates/app/openweathermap_http/template_app_openweathermap_http.yaml422
2 files changed, 296 insertions, 159 deletions
diff --git a/templates/app/openweathermap_http/README.md b/templates/app/openweathermap_http/README.md
index d3d24334672..bc1e9052e36 100644
--- a/templates/app/openweathermap_http/README.md
+++ b/templates/app/openweathermap_http/README.md
@@ -9,7 +9,7 @@ It works without any external scripts and uses the Script item.
## Setup
-> See [Zabbix template operation](https://www.zabbix.com/documentation/6.2/manual/config/templates_out_of_the_box/http) for basic instructions.
+> See [Zabbix template operation](https://www.zabbix.com/documentation/6.0/manual/config/templates_out_of_the_box/http) for basic instructions.
1. Create a host.
@@ -43,7 +43,6 @@ No specific Zabbix configuration is required.
|{$OPENWEATHERMAP.API.ENDPOINT} |<p>OpenWeatherMap API endpoint.</p> |`api.openweathermap.org/data/2.5/weather?` |
|{$OPENWEATHERMAP.API.TOKEN} |<p>Specify openweathermap API key.</p> |`` |
|{$OPENWEATHERMAP.DATA.TIMEOUT} |<p>Response timeout for OpenWeatherMap API.</p> |`3s` |
-|{$OPENWEATHERMAP.NODATA.PERIOD} |<p>Time limit period for nodata trigger.</p> |`30m` |
|{$TEMP.CRIT.HIGH} |<p>Threshold for high temperature trigger.</p> |`30` |
|{$TEMP.CRIT.LOW} |<p>Threshold for low temperature trigger.</p> |`-20` |
|{$UNITS} |<p>Available units of measurement are standard, metric and imperial https://openweathermap.org/current#data.</p> |`metric` |
@@ -56,31 +55,33 @@ There are no template links in this template.
|Name|Description|Type|Key and additional info|
|----|-----------|----|----|
-|Locations discovery |<p>Weather metrics discovery by location.</p> |DEPENDENT |openweathermap.locations.discovery<p>**Preprocessing**:</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|Locations discovery |<p>Weather metrics discovery by location.</p> |DEPENDENT |openweathermap.locations.discovery<p>**Preprocessing**:</p><p>- JSONPATH: `$.data`</p><p>- NOT_MATCHES_REGEX: `\[\]`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
## Items collected
|Group|Name|Description|Type|Key and additional info|
|-----|----|-----------|----|---------------------|
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Atmospheric pressure |<p>Atmospheric pressure in Pa.</p> |DEPENDENT |openweathermap.pressure[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].main.pressure.first()`</p><p>- MULTIPLIER: `100`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Cloudiness |<p>Cloudiness in %.</p> |DEPENDENT |openweathermap.clouds[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].clouds.all.first()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Humidity |<p>Humidity in %.</p> |DEPENDENT |openweathermap.humidity[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].main.humidity.first()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Rain volume for the lat one hour |<p>Rain volume for the lat one hour in m.</p> |DEPENDENT |openweathermap.rain[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].rain.1h.first()`</p><p>⛔️ON_FAIL: `CUSTOM_VALUE -> 0`</p><p>- MULTIPLIER: `0.001`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Short weather status |<p>Short weather status description.</p> |DEPENDENT |openweathermap.description[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].weather..description.first()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Snow volume for the lat one hour |<p>Snow volume for the lat one hour in m.</p> |DEPENDENT |openweathermap.snow[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].snow.1h.first()`</p><p>⛔️ON_FAIL: `CUSTOM_VALUE -> 0`</p><p>- MULTIPLIER: `0.001`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Temperature |<p>Atmospheric temperature value.</p> |DEPENDENT |openweathermap.temp[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].main.temp.first()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Visibility |<p>Visibility in m.</p> |DEPENDENT |openweathermap.visibility[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].visibility.first()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Wind direction |<p>Wind direction in degrees.</p> |DEPENDENT |openweathermap.wind.direction[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].wind.deg.first()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
-|OpenWeatherMap |OpenWeatherMap: {#LOCATION},{#COUNTRY}: Wind speed |<p>Wind speed value.</p> |DEPENDENT |openweathermap.wind.speed[{#LOCATION},{#COUNTRY}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.[?(@.name=='{#LOCATION}' && @.sys.country=='{#COUNTRY}')].wind.speed.first()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Data |<p>JSON with result of OpenWeatherMap API request by location.</p> |DEPENDENT |openweathermap.location.data[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.data.[?(@.id=='{#ID}')].first()`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Atmospheric pressure |<p>Atmospheric pressure in Pa.</p> |DEPENDENT |openweathermap.pressure[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.main.pressure`</p><p>- MULTIPLIER: `100`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Cloudiness |<p>Cloudiness in %.</p> |DEPENDENT |openweathermap.clouds[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.clouds.all`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Humidity |<p>Humidity in %.</p> |DEPENDENT |openweathermap.humidity[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.main.humidity`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Rain volume for the last one hour |<p>Rain volume for the lat one hour in m.</p> |DEPENDENT |openweathermap.rain[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.rain.1h`</p><p>⛔️ON_FAIL: `CUSTOM_VALUE -> 0`</p><p>- MULTIPLIER: `0.001`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Short weather status |<p>Short weather status description.</p> |DEPENDENT |openweathermap.description[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.weather..description.first()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Snow volume for the last one hour |<p>Snow volume for the lat one hour in m.</p> |DEPENDENT |openweathermap.snow[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.snow.1h`</p><p>⛔️ON_FAIL: `CUSTOM_VALUE -> 0`</p><p>- MULTIPLIER: `0.001`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Temperature |<p>Atmospheric temperature value.</p> |DEPENDENT |openweathermap.temp[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.main.temp`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Visibility |<p>Visibility in m.</p> |DEPENDENT |openweathermap.visibility[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.visibility`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Wind direction |<p>Wind direction in degrees.</p> |DEPENDENT |openweathermap.wind.direction[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.wind.deg`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
+|OpenWeatherMap |[{#LOCATION}, {#COUNTRY}]: Wind speed |<p>Wind speed value.</p> |DEPENDENT |openweathermap.wind.speed[{#ID}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.wind.speed`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
|Zabbix raw items |Openweathermap: Get data |<p>JSON array with result of OpenWeatherMap API requests.</p> |SCRIPT |openweathermap.get.data<p>**Expression**:</p>`The text is too long. Please see the template.` |
+|Zabbix raw items |Openweathermap: Get data collection errors |<p>Errors from get data requests by script item.</p> |DEPENDENT |openweathermap.get.errors<p>**Preprocessing**:</p><p>- JSONPATH: `$.errors`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> |
## Triggers
|Name|Description|Expression|Severity|Dependencies and additional info|
|----|-----------|----|----|----|
-|OpenWeatherMap: {#LOCATION},{#COUNTRY}: Temperature is too high (over {$TEMP.CRIT.HIGH} for 30m) |<p>Temperature value is too high.</p> |`min(/OpenWeatherMap by HTTP/openweathermap.temp[{#LOCATION},{#COUNTRY}],#3)>{$TEMP.CRIT.HIGH}` |AVERAGE |<p>Manual close: YES</p> |
-|OpenWeatherMap: {#LOCATION},{#COUNTRY}: Temperature is too low (below {$TEMP.CRIT.LOW} for 30m) |<p>Temperature value is too low.</p> |`max(/OpenWeatherMap by HTTP/openweathermap.temp[{#LOCATION},{#COUNTRY}],#3)<{$TEMP.CRIT.LOW}` |AVERAGE |<p>Manual close: YES</p> |
-|Openweathermap: Failed to fetch aggregate data (or no data for {$OPENWEATHERMAP.NODATA.PERIOD}) |<p>Zabbix has not received data from OpenWeatherMap API for the last few times.</p> |`nodata(/OpenWeatherMap by HTTP/openweathermap.get.data,{$OPENWEATHERMAP.NODATA.PERIOD})=1 or (last(/OpenWeatherMap by HTTP/openweathermap.get.data)="[]" and changecount(/OpenWeatherMap by HTTP/openweathermap.get.data,{$OPENWEATHERMAP.NODATA.PERIOD})=0)` |AVERAGE |<p>Manual close: YES</p> |
+|[{#LOCATION}, {#COUNTRY}]: Temperature is too high (over {$TEMP.CRIT.HIGH} for 30m) |<p>Temperature value is too high.</p> |`min(/OpenWeatherMap by HTTP/openweathermap.temp[{#ID}],#3)>{$TEMP.CRIT.HIGH}` |AVERAGE |<p>Manual close: YES</p> |
+|[{#LOCATION}, {#COUNTRY}]: Temperature is too low (below {$TEMP.CRIT.LOW} for 30m) |<p>Temperature value is too low.</p> |`max(/OpenWeatherMap by HTTP/openweathermap.temp[{#ID}],#3)<{$TEMP.CRIT.LOW}` |AVERAGE |<p>Manual close: YES</p> |
+|Openweathermap: There are errors in requests to OpenWeatherMap API |<p>Zabbix has received errors in requests to OpenWeatherMap API.</p> |`length(last(/OpenWeatherMap by HTTP/openweathermap.get.errors))>0` |AVERAGE |<p>Manual close: YES</p> |
## Feedback
diff --git a/templates/app/openweathermap_http/template_app_openweathermap_http.yaml b/templates/app/openweathermap_http/template_app_openweathermap_http.yaml
index d25beba5ed8..97532a5f60a 100644
--- a/templates/app/openweathermap_http/template_app_openweathermap_http.yaml
+++ b/templates/app/openweathermap_http/template_app_openweathermap_http.yaml
@@ -1,6 +1,6 @@
zabbix_export:
version: '6.0'
- date: '2022-03-08T19:02:46Z'
+ date: '2022-03-18T09:49:27Z'
groups:
-
uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
@@ -14,6 +14,26 @@ zabbix_export:
Get weather metrics from OpenWeatherMap current weather API by HTTP.
It works without any external scripts and uses the Script item.
+ 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.
+
You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/
Template tooling version used: 0.41
@@ -31,97 +51,118 @@ zabbix_export:
trends: '0'
value_type: TEXT
params: |
- var params = JSON.parse(value);
-
- var request = new HttpRequest();
-
- var data = [],
- errorMsg = '',
- measurement,
- temp_unit,
- wind_unit;
-
+ var params = JSON.parse(value),
+ request = new HttpRequest(),
+ data = [],
+ error_msg = [],
+ measurement,
+ temp_unit,
+ wind_unit,
+ errors_only = [],
+ error_locations = [],
+ unique_errors,
+ new_error_msg;
+
function getHttpData(query) {
- url = params.api_endpoint + query + '&appid=' + params.apikey + '&units=' + params.units + '&lang=' + params.lang;
- response = request.get(url);
- Zabbix.log(4, '[ Openweathermap ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
-
- if (response !== null) {
- try {
- response = JSON.parse(response);
- }
- catch (error) {
- throw 'Failed to parse response.';
+ url = params.api_endpoint + query + '&appid=' + params.apikey + '&units=' + params.units + '&lang=' + params.lang;
+ response = request.get(url);
+ Zabbix.log(4, '[ Openweathermap ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
+
+ if (response !== null) {
+ try {
+ response = JSON.parse(response);
+ }
+ catch (error) {
+ throw 'Failed to parse response.';
+ }
}
- }
-
- if (request.getStatus() !== 200) {
- if (response.error && response.error.message) {
- throw response.error.message;
- }
- else {
- throw 'Failed to receive data: invalid response status code.';
+
+ if (request.getStatus() !== 200) {
+ if (response.error && response.error.message) {
+ throw response.error.message;
+ }
+ else {
+ throw 'Failed to receive data. Invalid response status code: ' + request.getStatus();
+ }
}
- }
- return response;
- };
-
- if (params.units === 'metric') {
- measurement = "metric";
- temp_unit = "C";
- wind_unit = "meter/sec";
+ return response;
}
- else if (params.units === 'imperial'){
- measurement = "imperial";
- temp_unit = "F";
- wind_unit = "miles/hour";
+
+ switch (params.units) {
+ case 'metric':
+ measurement = 'metric';
+ temp_unit = 'C';
+ wind_unit = 'meter/sec';
+ break;
+ case 'imperial':
+ measurement = 'imperial';
+ temp_unit = 'F';
+ wind_unit = 'miles/hour';
+ break;
+ default:
+ measurement = 'standard';
+ temp_unit = 'K';
+ wind_unit = 'meter/sec';
}
- else {
- measurement = "standard";
- temp_unit = "K";
- wind_unit = "meter/sec";
- };
-
- try {
-
- locations = params.location.split('|');
- for (var i in locations) {
- if (/^[0-9]+$/g.test(locations[i])) {
- result = getHttpData('id=' + locations[i]);
- result.measurement = measurement;
- result.temp_unit = temp_unit;
- result.wind_unit = wind_unit;
- data.push(result);
- }
- else if (/^.*,[\w]+$/g.test(locations[i])) {
- result = getHttpData('zip=' + locations[i]);
- result.measurement = measurement;
- result.temp_unit = temp_unit;
- result.wind_unit = wind_unit;
- data.push(result);
- }
- else if (/^[0-9]{1,2}(\.[0-9]+)?,[0-9]{1,2}(\.[0-9]+)?/g.test(locations[i])) {
- coordinates = locations[i].split(',');
- result = getHttpData('lat=' + coordinates[0] + '&lon=' + coordinates[1]);
- result.measurement = measurement;
- result.temp_unit = temp_unit;
- result.wind_unit = wind_unit;
- data.push(result);
+
+ locations = params.location.split('|');
+ for (var i in locations) {
+ try {
+ if (/^[0-9]+$/g.test(locations[i])) {
+ result = getHttpData('id=' + locations[i]);
+ }
+ else if (/^.*,[\w]+$/g.test(locations[i])) {
+ result = getHttpData('zip=' + locations[i]);
+ }
+ else if (/^[0-9]{1,2}(\.[0-9]+)?,[0-9]{1,2}(\.[0-9]+)?/g.test(locations[i])) {
+ coordinates = locations[i].split(',');
+ result = getHttpData('lat=' + coordinates[0] + '&lon=' + coordinates[1]);
+ }
+ else {
+ result = getHttpData('q=' + encodeURIComponent(locations[i]));
+ }
+ if (!data.filter(function (location) { return location.id === result.id; }).length) {
+ result.measurement = measurement;
+ result.temp_unit = temp_unit;
+ result.wind_unit = wind_unit;
+ data.push(result);
+ }
+ } catch (error) {
+ errors = {};
+ errors.location = locations[i];
+ errors.error = error.toString();
+ error_msg.push(errors);
+ errors_only.push(error.toString());
}
- else {
- result = getHttpData('q=' + encodeURIComponent(locations[i]));
- result.measurement = measurement;
- result.temp_unit = temp_unit;
- result.wind_unit = wind_unit;
- data.push(result);
- };
- };
-
- } catch (error) {
- errorMsg = error;
- };
+ }
- return JSON.stringify(data);
+ if (error_msg.length === 0) {
+ return JSON.stringify({
+ 'data': data,
+ 'errors': error_msg.toString()
+ });
+ } else {
+ unique_errors = errors_only.filter(function (value, index, self) {
+ return self.indexOf(value) == index;
+ });
+
+ if (unique_errors.length === 1) {
+ for (var j in error_msg) {
+ error_locations.push(error_msg[j].location);
+ }
+ new_error_msg = 'Failed to retrieve data for the following locations: ' + error_locations + '. ' + unique_errors[0];
+
+ return JSON.stringify({
+ 'data': data,
+ 'errors': new_error_msg
+ });
+ } else {
+ return JSON.stringify({
+ 'data': data,
+ 'errors': error_msg
+ });
+ }
+ }
description: 'JSON array with result of OpenWeatherMap API requests.'
timeout: '{$OPENWEATHERMAP.DATA.TIMEOUT}'
parameters:
@@ -144,13 +185,42 @@ zabbix_export:
-
tag: component
value: raw
+ -
+ uuid: 2eb0520627084f2596743f53552c3744
+ name: 'Openweathermap: Get data collection errors'
+ type: DEPENDENT
+ key: openweathermap.get.errors
+ delay: '0'
+ history: 7d
+ trends: '0'
+ value_type: TEXT
+ description: 'Errors from get data requests by script item.'
+ preprocessing:
+ -
+ type: JSONPATH
+ parameters:
+ - $.errors
+ -
+ type: DISCARD_UNCHANGED_HEARTBEAT
+ parameters:
+ - 1h
+ master_item:
+ key: openweathermap.get.data
+ tags:
+ -
+ tag: component
+ value: application
+ -
+ tag: component
+ value: errors
triggers:
-
- uuid: 416d88c67ef940fb868f3985af4d88bf
- expression: 'nodata(/OpenWeatherMap by HTTP/openweathermap.get.data,{$OPENWEATHERMAP.NODATA.PERIOD})=1 or (last(/OpenWeatherMap by HTTP/openweathermap.get.data)="[]" and changecount(/OpenWeatherMap by HTTP/openweathermap.get.data,{$OPENWEATHERMAP.NODATA.PERIOD})=0)'
- name: 'Openweathermap: Failed to fetch aggregate data (or no data for {$OPENWEATHERMAP.NODATA.PERIOD})'
+ uuid: 8c2c6f81e1e74f97a28538e714eee474
+ expression: 'length(last(/OpenWeatherMap by HTTP/openweathermap.get.errors))>0'
+ name: 'Openweathermap: There are errors in requests to OpenWeatherMap API'
+ opdata: '{ITEM.LASTVALUE1}'
priority: AVERAGE
- description: 'Zabbix has not received data from OpenWeatherMap API for the last few times.'
+ description: 'Zabbix has received errors in requests to OpenWeatherMap API.'
manual_close: 'YES'
tags:
-
@@ -163,13 +233,14 @@ zabbix_export:
type: DEPENDENT
key: openweathermap.locations.discovery
delay: '0'
+ lifetime: 0d
description: 'Weather metrics discovery by location.'
item_prototypes:
-
uuid: 8d19b2e691a440dcb014a6518b7bb0d6
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Cloudiness'
+ name: '[{#LOCATION}, {#COUNTRY}]: Cloudiness'
type: DEPENDENT
- key: 'openweathermap.clouds[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.clouds[{#ID}]'
delay: '0'
history: 7d
units: '%'
@@ -178,13 +249,13 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].clouds.all.first()'
+ - $.clouds.all
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -197,9 +268,9 @@ zabbix_export:
value: '{#LOCATION}'
-
uuid: 02463505cab64ae0bbc4554531372818
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Short weather status'
+ name: '[{#LOCATION}, {#COUNTRY}]: Short weather status'
type: DEPENDENT
- key: 'openweathermap.description[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.description[{#ID}]'
delay: '0'
history: 7d
trends: '0'
@@ -209,13 +280,13 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].weather..description.first()'
+ - $.weather..description.first()
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -228,9 +299,9 @@ zabbix_export:
value: '{#LOCATION}'
-
uuid: 5f8fa36c0be5475bad5c5c9074afa7e4
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Humidity'
+ name: '[{#LOCATION}, {#COUNTRY}]: Humidity'
type: DEPENDENT
- key: 'openweathermap.humidity[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.humidity[{#ID}]'
delay: '0'
history: 7d
units: '%'
@@ -239,13 +310,13 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].main.humidity.first()'
+ - $.main.humidity
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -257,10 +328,37 @@ zabbix_export:
tag: location
value: '{#LOCATION}'
-
+ uuid: 51f79e4be0734ad5b548617eb535fae4
+ name: '[{#LOCATION}, {#COUNTRY}]: Data'
+ type: DEPENDENT
+ key: 'openweathermap.location.data[{#ID}]'
+ delay: '0'
+ history: 0d
+ trends: '0'
+ value_type: TEXT
+ description: 'JSON with result of OpenWeatherMap API request by location.'
+ preprocessing:
+ -
+ type: JSONPATH
+ parameters:
+ - '$.data.[?(@.id==''{#ID}'')].first()'
+ master_item:
+ key: openweathermap.get.data
+ tags:
+ -
+ tag: component
+ value: raw
+ -
+ tag: country
+ value: '{#COUNTRY}'
+ -
+ tag: location
+ value: '{#LOCATION}'
+ -
uuid: a9ef27e9702c4f41bfbb95579ff2014e
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Atmospheric pressure'
+ name: '[{#LOCATION}, {#COUNTRY}]: Atmospheric pressure'
type: DEPENDENT
- key: 'openweathermap.pressure[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.pressure[{#ID}]'
delay: '0'
history: 7d
units: Pa
@@ -269,7 +367,7 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].main.pressure.first()'
+ - $.main.pressure
-
type: MULTIPLIER
parameters:
@@ -279,7 +377,7 @@ zabbix_export:
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -292,9 +390,9 @@ zabbix_export:
value: '{#LOCATION}'
-
uuid: 6a0f10ae39a347319026ff147f1dc470
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Rain volume for the lat one hour'
+ name: '[{#LOCATION}, {#COUNTRY}]: Rain volume for the last one hour'
type: DEPENDENT
- key: 'openweathermap.rain[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.rain[{#ID}]'
delay: '0'
history: 7d
value_type: FLOAT
@@ -304,7 +402,7 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].rain.1h.first()'
+ - $.rain.1h
error_handler: CUSTOM_VALUE
error_handler_params: '0'
-
@@ -316,7 +414,7 @@ zabbix_export:
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -329,9 +427,9 @@ zabbix_export:
value: '{#LOCATION}'
-
uuid: 8310f65dceeb4b348f1a769b806d5239
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Snow volume for the lat one hour'
+ name: '[{#LOCATION}, {#COUNTRY}]: Snow volume for the last one hour'
type: DEPENDENT
- key: 'openweathermap.snow[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.snow[{#ID}]'
delay: '0'
history: 7d
value_type: FLOAT
@@ -341,7 +439,7 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].snow.1h.first()'
+ - $.snow.1h
error_handler: CUSTOM_VALUE
error_handler_params: '0'
-
@@ -353,7 +451,7 @@ zabbix_export:
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -366,9 +464,9 @@ zabbix_export:
value: '{#LOCATION}'
-
uuid: d30b8a4a56344ddd830d0bd633507b78
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Temperature'
+ name: '[{#LOCATION}, {#COUNTRY}]: Temperature'
type: DEPENDENT
- key: 'openweathermap.temp[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.temp[{#ID}]'
delay: '0'
history: 7d
value_type: FLOAT
@@ -378,13 +476,13 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].main.temp.first()'
+ - $.main.temp
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -398,8 +496,9 @@ zabbix_export:
trigger_prototypes:
-
uuid: 3b7e55f13c6a4ba2930709d5c51c8a09
- expression: 'min(/OpenWeatherMap by HTTP/openweathermap.temp[{#LOCATION},{#COUNTRY}],#3)>{$TEMP.CRIT.HIGH}'
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Temperature is too high (over {$TEMP.CRIT.HIGH} for 30m)'
+ expression: 'min(/OpenWeatherMap by HTTP/openweathermap.temp[{#ID}],#3)>{$TEMP.CRIT.HIGH}'
+ name: '[{#LOCATION}, {#COUNTRY}]: Temperature is too high (over {$TEMP.CRIT.HIGH} for 30m)'
+ opdata: 'Current temp: {ITEM.LASTVALUE1}'
priority: AVERAGE
description: 'Temperature value is too high.'
manual_close: 'YES'
@@ -409,8 +508,9 @@ zabbix_export:
value: notice
-
uuid: 7c98d2784a2e42faa76e67348a0df7ff
- expression: 'max(/OpenWeatherMap by HTTP/openweathermap.temp[{#LOCATION},{#COUNTRY}],#3)<{$TEMP.CRIT.LOW}'
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Temperature is too low (below {$TEMP.CRIT.LOW} for 30m)'
+ expression: 'max(/OpenWeatherMap by HTTP/openweathermap.temp[{#ID}],#3)<{$TEMP.CRIT.LOW}'
+ name: '[{#LOCATION}, {#COUNTRY}]: Temperature is too low (below {$TEMP.CRIT.LOW} for 30m)'
+ opdata: 'Current temp: {ITEM.LASTVALUE1}'
priority: AVERAGE
description: 'Temperature value is too low.'
manual_close: 'YES'
@@ -420,9 +520,9 @@ zabbix_export:
value: notice
-
uuid: 23d4152f794d46f6af705749b9443100
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Visibility'
+ name: '[{#LOCATION}, {#COUNTRY}]: Visibility'
type: DEPENDENT
- key: 'openweathermap.visibility[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.visibility[{#ID}]'
delay: '0'
history: 7d
units: m
@@ -431,13 +531,13 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].visibility.first()'
+ - $.visibility
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -450,9 +550,9 @@ zabbix_export:
value: '{#LOCATION}'
-
uuid: f3350dcbd4f247e7878c06b8695beddd
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Wind direction'
+ name: '[{#LOCATION}, {#COUNTRY}]: Wind direction'
type: DEPENDENT
- key: 'openweathermap.wind.direction[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.wind.direction[{#ID}]'
delay: '0'
history: 7d
value_type: FLOAT
@@ -464,13 +564,13 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].wind.deg.first()'
+ - $.wind.deg
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -483,9 +583,9 @@ zabbix_export:
value: '{#LOCATION}'
-
uuid: 67decabd27774e9fb6d9212621c43a54
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Wind speed'
+ name: '[{#LOCATION}, {#COUNTRY}]: Wind speed'
type: DEPENDENT
- key: 'openweathermap.wind.speed[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.wind.speed[{#ID}]'
delay: '0'
history: 7d
value_type: FLOAT
@@ -495,13 +595,13 @@ zabbix_export:
-
type: JSONPATH
parameters:
- - '$.[?(@.name==''{#LOCATION}'' && @.sys.country==''{#COUNTRY}'')].wind.speed.first()'
+ - $.wind.speed
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
- key: openweathermap.get.data
+ key: 'openweathermap.location.data[{#ID}]'
tags:
-
tag: component
@@ -514,31 +614,71 @@ zabbix_export:
value: '{#LOCATION}'
graph_prototypes:
-
+ uuid: 62ba0562f77d46e0b04a387d82c1a51e
+ name: '[{#LOCATION}, {#COUNTRY}]: Atmospheric pressure'
+ graph_items:
+ -
+ color: 1A7C11
+ item:
+ host: 'OpenWeatherMap by HTTP'
+ key: 'openweathermap.pressure[{#ID}]'
+ -
+ uuid: 6196267a6d974ef2acbebdb9b33f6b71
+ name: '[{#LOCATION}, {#COUNTRY}]: Rain volume'
+ graph_items:
+ -
+ color: 1A7C11
+ item:
+ host: 'OpenWeatherMap by HTTP'
+ key: 'openweathermap.rain[{#ID}]'
+ -
+ uuid: 27b47b89606e43f5a4180e9dde29d7d6
+ name: '[{#LOCATION}, {#COUNTRY}]: Snow volume'
+ graph_items:
+ -
+ color: 1A7C11
+ item:
+ host: 'OpenWeatherMap by HTTP'
+ key: 'openweathermap.snow[{#ID}]'
+ -
uuid: 3561e247237548f3a26c702924d05894
- name: 'OpenWeatherMap: {#LOCATION},{#COUNTRY}: Temperature'
+ name: '[{#LOCATION}, {#COUNTRY}]: Temperature'
graph_items:
-
color: 1A7C11
item:
host: 'OpenWeatherMap by HTTP'
- key: 'openweathermap.temp[{#LOCATION},{#COUNTRY}]'
+ key: 'openweathermap.temp[{#ID}]'
master_item:
key: openweathermap.get.data
lld_macro_paths:
-
lld_macro: '{#COUNTRY}'
- path: $..sys.country.first()
+ path: $.sys.country
+ -
+ lld_macro: '{#ID}'
+ path: $.id
-
lld_macro: '{#LOCATION}'
- path: $..name.first()
+ path: $.name
-
lld_macro: '{#TEMP.UNIT}'
- path: $..temp_unit.first()
+ path: $.temp_unit
-
lld_macro: '{#WIND.UNIT}'
- path: $..wind_unit.first()
+ path: $.wind_unit
preprocessing:
-
+ type: JSONPATH
+ parameters:
+ - $.data
+ -
+ type: NOT_MATCHES_REGEX
+ parameters:
+ - '\[\]'
+ error_handler: CUSTOM_ERROR
+ error_handler_params: 'Failed to receive data about required locations from API'
+ -
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
@@ -579,10 +719,6 @@ zabbix_export:
value: 3s
description: 'Response timeout for OpenWeatherMap API.'
-
- macro: '{$OPENWEATHERMAP.NODATA.PERIOD}'
- value: 30m
- description: 'Time limit period for nodata trigger.'
- -
macro: '{$TEMP.CRIT.HIGH}'
value: '30'
description: 'Threshold for high temperature trigger.'