Backup de templates Zabbix 7.0.31
This commit is contained in:
@@ -0,0 +1,409 @@
|
||||
zabbix_export:
|
||||
version: '7.0'
|
||||
template_groups:
|
||||
- uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
|
||||
name: Templates/Applications
|
||||
- uuid: 36bff6c29af64692839d077febfc7079
|
||||
name: 'Templates/Network devices'
|
||||
host_groups:
|
||||
- uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
|
||||
name: Applications
|
||||
templates:
|
||||
- uuid: 2fca6b60914b4fa98132b1a7885ab014
|
||||
template: 'Cisco Meraki dashboard by HTTP'
|
||||
name: 'Cisco Meraki dashboard by HTTP'
|
||||
description: |
|
||||
Template for monitoring Cisco Meraki dashboard https://meraki.cisco.com/products/meraki-dashboard/
|
||||
|
||||
You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/
|
||||
|
||||
Generated by official Zabbix template tool "Templator"
|
||||
vendor:
|
||||
name: Zabbix
|
||||
version: 7.0-6
|
||||
groups:
|
||||
- name: Templates/Applications
|
||||
- name: 'Templates/Network devices'
|
||||
items:
|
||||
- uuid: d1a5f3c79a604bae98c314d2aed64ff4
|
||||
name: 'Get data'
|
||||
type: SCRIPT
|
||||
key: meraki.get.data
|
||||
delay: 1h
|
||||
history: '0'
|
||||
value_type: TEXT
|
||||
trends: '0'
|
||||
params: |
|
||||
const CTlsConfig = function (raw_value) {
|
||||
raw_value = String(raw_value).trim().toLowerCase();
|
||||
|
||||
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
||||
raw_value = 'full';
|
||||
}
|
||||
|
||||
this.options = {
|
||||
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
||||
SSLVerifyHost: (raw_value === 'full')
|
||||
};
|
||||
|
||||
this.enabled = (raw_value !== 'none');
|
||||
|
||||
this.checkURL = function (url) {
|
||||
if (this.enabled && !/^https:\/\//i.test(url)) {
|
||||
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
||||
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var params = JSON.parse(value);
|
||||
|
||||
var tls = new CTlsConfig(params.tls_verify);
|
||||
|
||||
var r_match = '{$MERAKI.ORGANIZATION.NAME.MATCHES}';
|
||||
var r_not_match = '{$MERAKI.ORGANIZATION.NAME.NOT_MATCHES}';
|
||||
|
||||
var request = new HttpRequest(tls.options);
|
||||
|
||||
request.addHeader('X-Cisco-Meraki-API-Key:' + params.token);
|
||||
request.addHeader('User-Agent: ZabbixServer/1.2 Zabbix');
|
||||
|
||||
var response,
|
||||
error_msg = '',
|
||||
organizations = [],
|
||||
devices = [];
|
||||
|
||||
function hasHeader(headers, name) {
|
||||
if (typeof headers !== 'object' || headers === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var target = name.toLowerCase();
|
||||
|
||||
for (var key in headers) {
|
||||
if (key.toLowerCase() === target) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getHttpData(url) {
|
||||
var startTime = new Date().getTime();
|
||||
var maxWait = 1 * 60 * 60 * 1000;
|
||||
var waitFor = 1000;
|
||||
|
||||
while (true) {
|
||||
response = request.get(url);
|
||||
Zabbix.log(4, '[ Meraki API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
|
||||
|
||||
var status = request.getStatus();
|
||||
|
||||
if (response !== null) {
|
||||
try {
|
||||
response = JSON.parse(response);
|
||||
}
|
||||
catch (error) {
|
||||
throw 'Failed to parse response received from Meraki API. Check debug log for more information.';
|
||||
}
|
||||
}
|
||||
|
||||
if (status === 429 && response && response.errors && Array.isArray(response.errors) &&
|
||||
response.errors.indexOf("API rate limit exceeded for organization") !== -1) {
|
||||
var now = new Date().getTime();
|
||||
var headers = request.getHeaders(false);
|
||||
|
||||
if (hasHeader(headers, 'Retry-After')) {
|
||||
var retryAfter = headers['Retry-After'];
|
||||
Zabbix.log(4, '[ Meraki API ] API rate limit exceeded. Retrying after ' + retryAfter + ' seconds.');
|
||||
waitFor = parseInt(retryAfter) * 1000;
|
||||
}
|
||||
else {
|
||||
Zabbix.log(4, '[ Meraki API ] API rate limit exceeded. No Retry-After header. Retrying after 1 second.');
|
||||
}
|
||||
if (now - startTime + waitFor > maxWait) {
|
||||
throw 'Failed to receive data: API rate limit exceeded and retry timeout reached.';
|
||||
}
|
||||
Zabbix.sleep(waitFor);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (status !== 200) {
|
||||
if (response.errors) {
|
||||
throw response.errors.join(', ');
|
||||
}
|
||||
else {
|
||||
throw 'Failed to receive data: invalid response status code.';
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof (response) !== 'object' || response === null) {
|
||||
throw 'Cannot process response data: received data is not an object.';
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
if (params.token === '{' + '$MERAKI.TOKEN}') {
|
||||
throw 'Please change {' + '$MERAKI.TOKEN} macro to the proper value.';
|
||||
}
|
||||
|
||||
if (params.url.indexOf('http://') === -1 && params.url.indexOf('https://') === -1) {
|
||||
params.url = 'https://' + params.url;
|
||||
}
|
||||
|
||||
if (!params.url.endsWith('/')) {
|
||||
params.url += '/';
|
||||
}
|
||||
|
||||
tls.checkURL(params.url);
|
||||
|
||||
if (typeof params.httpproxy !== 'undefined' && params.httpproxy !== '') {
|
||||
request.setProxy(params.httpproxy);
|
||||
}
|
||||
|
||||
organizations = getHttpData(params.url + 'organizations');
|
||||
|
||||
organizations = organizations.filter(function (x) {
|
||||
return new RegExp(r_match).test(x.name) & !new RegExp(r_not_match).test(x.name);
|
||||
});
|
||||
|
||||
if (Array.isArray(organizations) && organizations.length > 0) {
|
||||
for (i in organizations) {
|
||||
if ('id' in organizations[i] && 'name' in organizations[i]) {
|
||||
try {
|
||||
organization_devices = getHttpData(params.url + 'organizations/' + encodeURIComponent(organizations[i].id) + '/devices/availabilities');
|
||||
|
||||
if (Array.isArray(organization_devices) && organization_devices.length > 0) {
|
||||
for (j in organization_devices) {
|
||||
organization_devices[j].organizationId = organizations[i].id;
|
||||
organization_devices[j].organizationName = organizations[i].name;
|
||||
if (!organization_devices[j].name) {
|
||||
organization_devices[j].name = organization_devices[j].serial;
|
||||
}
|
||||
devices.push(organization_devices[j]);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
error_msg += organizations[i].name + " organization's devices retrieval error: " + error + '\n';
|
||||
}
|
||||
} else {
|
||||
error_msg += 'There is no ID or organization name in the API response.';
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
error_msg += 'Organizations data retrieval error: ' + error;
|
||||
}
|
||||
|
||||
return JSON.stringify({
|
||||
organizations: organizations,
|
||||
devices: devices,
|
||||
error: error_msg.toString()
|
||||
});
|
||||
description: 'Item for gathering all the organizations and devices from Meraki API.'
|
||||
timeout: '{$MERAKI.DATA.TIMEOUT}'
|
||||
parameters:
|
||||
- name: httpproxy
|
||||
value: '{$MERAKI.HTTP_PROXY}'
|
||||
- name: tls_verify
|
||||
value: '{$HTTP.TLS.VERIFY:"Cisco Meraki dashboard"}'
|
||||
- name: token
|
||||
value: '{$MERAKI.TOKEN}'
|
||||
- name: url
|
||||
value: '{$MERAKI.API.URL}'
|
||||
tags:
|
||||
- tag: component
|
||||
value: raw
|
||||
- uuid: 6fdd764d820341e7bd2a24f42802c58a
|
||||
name: 'Data item errors'
|
||||
type: DEPENDENT
|
||||
key: meraki.get.data.errors
|
||||
delay: '0'
|
||||
value_type: TEXT
|
||||
trends: '0'
|
||||
description: 'Item for gathering all the data item errors.'
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- $.error
|
||||
- type: DISCARD_UNCHANGED_HEARTBEAT
|
||||
parameters:
|
||||
- 1h
|
||||
master_item:
|
||||
key: meraki.get.data
|
||||
tags:
|
||||
- tag: component
|
||||
value: error
|
||||
triggers:
|
||||
- uuid: 2bf9355f548e4e9b9b8581fb43f175fe
|
||||
expression: 'length(last(/Cisco Meraki dashboard by HTTP/meraki.get.data.errors))>0'
|
||||
name: 'Meraki: There are errors in ''Get data'' metric'
|
||||
priority: WARNING
|
||||
tags:
|
||||
- tag: scope
|
||||
value: availability
|
||||
discovery_rules:
|
||||
- uuid: 6488b49e692e4fe8b6a1c57f56b6ba7d
|
||||
name: 'Devices discovery'
|
||||
type: DEPENDENT
|
||||
key: meraki.devices.discovery
|
||||
delay: '0'
|
||||
filter:
|
||||
evaltype: AND
|
||||
conditions:
|
||||
- macro: '{#NAME}'
|
||||
value: '{$MERAKI.DEVICE.NAME.MATCHES}'
|
||||
formulaid: A
|
||||
- macro: '{#NAME}'
|
||||
value: '{$MERAKI.DEVICE.NAME.NOT_MATCHES}'
|
||||
operator: NOT_MATCHES_REGEX
|
||||
formulaid: B
|
||||
- macro: '{#STATUS}'
|
||||
value: '{$MERAKI.DEVICE.STATUS.MATCHES}'
|
||||
formulaid: C
|
||||
- macro: '{#STATUS}'
|
||||
value: '{$MERAKI.DEVICE.STATUS.NOT_MATCHES}'
|
||||
operator: NOT_MATCHES_REGEX
|
||||
formulaid: D
|
||||
host_prototypes:
|
||||
- uuid: 86d599f384d94b368508a170911213ec
|
||||
host: '{#SERIAL}'
|
||||
name: '[{#SERIAL}] [{#PRODUCT_TYPE}] {#NAME}'
|
||||
group_links:
|
||||
- group:
|
||||
name: Applications
|
||||
templates:
|
||||
- name: 'Cisco Meraki device by HTTP'
|
||||
macros:
|
||||
- macro: '{$MAC}'
|
||||
value: '{#MAC}'
|
||||
description: 'MAC address of the device.'
|
||||
- macro: '{$NETWORK.ID}'
|
||||
value: '{#NETWORK.ID}'
|
||||
description: 'Network ID of the device.'
|
||||
- macro: '{$ORGANIZATION_ID}'
|
||||
value: '{#ORGANIZATION_ID}'
|
||||
description: 'Organization ID of the device.'
|
||||
- macro: '{$SERIAL}'
|
||||
value: '{#SERIAL}'
|
||||
description: 'Serial number of the device.'
|
||||
tags:
|
||||
- tag: organization
|
||||
value: '{#ORGANIZATION_NAME}'
|
||||
- tag: serial-number
|
||||
value: '{#SERIAL}'
|
||||
- tag: type
|
||||
value: '{#PRODUCT_TYPE}'
|
||||
master_item:
|
||||
key: meraki.get.data
|
||||
lld_macro_paths:
|
||||
- lld_macro: '{#MAC}'
|
||||
path: $.mac
|
||||
- lld_macro: '{#NAME}'
|
||||
path: $.name
|
||||
- lld_macro: '{#NETWORK.ID}'
|
||||
path: $.network.id
|
||||
- lld_macro: '{#ORGANIZATION_ID}'
|
||||
path: $.organizationId
|
||||
- lld_macro: '{#ORGANIZATION_NAME}'
|
||||
path: $.organizationName
|
||||
- lld_macro: '{#PRODUCT_TYPE}'
|
||||
path: $.productType
|
||||
- lld_macro: '{#SERIAL}'
|
||||
path: $.serial
|
||||
- lld_macro: '{#STATUS}'
|
||||
path: $.status
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- $.devices
|
||||
- uuid: 30f38d19659646009ca436d48f9598b0
|
||||
name: 'Organizations discovery'
|
||||
type: DEPENDENT
|
||||
key: meraki.organization.discovery
|
||||
delay: '0'
|
||||
filter:
|
||||
evaltype: AND
|
||||
conditions:
|
||||
- macro: '{#NAME}'
|
||||
value: '{$MERAKI.ORGANIZATION.NAME.MATCHES}'
|
||||
formulaid: A
|
||||
- macro: '{#NAME}'
|
||||
value: '{$MERAKI.ORGANIZATION.NAME.NOT_MATCHES}'
|
||||
operator: NOT_MATCHES_REGEX
|
||||
formulaid: B
|
||||
host_prototypes:
|
||||
- uuid: 59cd2e995b814d7e9f8411dbc7420c76
|
||||
host: 'meraki-organization-{#ID}'
|
||||
name: '[{#REGION}] {#NAME}'
|
||||
group_links:
|
||||
- group:
|
||||
name: Applications
|
||||
group_prototypes:
|
||||
- name: '{#REGION}'
|
||||
templates:
|
||||
- name: 'Cisco Meraki organization by HTTP'
|
||||
macros:
|
||||
- macro: '{$ID}'
|
||||
value: '{#ID}'
|
||||
description: 'ID of the organization.'
|
||||
master_item:
|
||||
key: meraki.get.data
|
||||
lld_macro_paths:
|
||||
- lld_macro: '{#ID}'
|
||||
path: $.id
|
||||
- lld_macro: '{#NAME}'
|
||||
path: $.name
|
||||
- lld_macro: '{#REGION}'
|
||||
path: $.cloud.region.name
|
||||
- lld_macro: '{#URL}'
|
||||
path: $.url
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- $.organizations
|
||||
tags:
|
||||
- tag: class
|
||||
value: network
|
||||
- tag: target
|
||||
value: cisco-meraki-dashboard
|
||||
macros:
|
||||
- macro: '{$HTTP.TLS.VERIFY}'
|
||||
value: full
|
||||
description: 'TLS certificate verification for script items: "none" - disabled, "peer" - verify the certificate chain and expiration, "full" - full verification. Any other value enables full verification. To override the setting for this template only, define the macro with the context "Cisco Meraki dashboard", e.g. {$HTTP.TLS.VERIFY:"Cisco Meraki dashboard"}.'
|
||||
- macro: '{$MERAKI.API.URL}'
|
||||
value: api.meraki.com/api/v1
|
||||
description: 'Cisco Meraki dashboard API URL, e.g., api.meraki.com/api/v1'
|
||||
- macro: '{$MERAKI.DATA.TIMEOUT}'
|
||||
value: '60'
|
||||
description: 'Response timeout for an API.'
|
||||
- macro: '{$MERAKI.DEVICE.NAME.MATCHES}'
|
||||
value: .+
|
||||
description: 'This macro is used in devices discovery. Can be overridden on the host or linked template level.'
|
||||
- macro: '{$MERAKI.DEVICE.NAME.NOT_MATCHES}'
|
||||
value: CHANGE_IF_NEEDED
|
||||
description: 'This macro is used in devices discovery. Can be overridden on the host or linked template level.'
|
||||
- macro: '{$MERAKI.DEVICE.STATUS.MATCHES}'
|
||||
value: '.*'
|
||||
description: 'This macro is used in devices discovery. Can be overridden on the host or linked template level.'
|
||||
- macro: '{$MERAKI.DEVICE.STATUS.NOT_MATCHES}'
|
||||
value: CHANGE_IF_NEEDED
|
||||
description: 'This macro is used in devices discovery. Can be overridden on the host or linked template level.'
|
||||
- macro: '{$MERAKI.HTTP_PROXY}'
|
||||
description: 'HTTP proxy for API requests. You can specify it using the format [protocol://][username[:password]@]proxy.example.com[:port]. See documentation at https://www.zabbix.com/documentation/7.0/manual/config/items/itemtypes/http'
|
||||
- macro: '{$MERAKI.ORGANIZATION.NAME.MATCHES}'
|
||||
value: .+
|
||||
description: 'This macro is used in organizations discovery. Can be overridden on the host or linked template level.'
|
||||
- macro: '{$MERAKI.ORGANIZATION.NAME.NOT_MATCHES}'
|
||||
value: CHANGE_IF_NEEDED
|
||||
description: 'This macro is used in organizations discovery. Can be overridden on the host or linked template level.'
|
||||
- macro: '{$MERAKI.TOKEN}'
|
||||
type: SECRET_TEXT
|
||||
description: 'Cisco Meraki dashboard API token.'
|
||||
Reference in New Issue
Block a user