Backup de templates Zabbix 7.0.31
This commit is contained in:
@@ -0,0 +1,493 @@
|
||||
zabbix_export:
|
||||
version: '7.0'
|
||||
template_groups:
|
||||
- uuid: 36bff6c29af64692839d077febfc7079
|
||||
name: 'Templates/Network devices'
|
||||
host_groups:
|
||||
- uuid: f2481361f99448eea617b7b1d4765566
|
||||
name: 'Discovered hosts'
|
||||
templates:
|
||||
- uuid: f552ead096ff4ebb8e4cc44c437e1f2f
|
||||
template: 'Cradlepoint NCM v2 by HTTP'
|
||||
name: 'Cradlepoint NCM v2 by HTTP'
|
||||
description: |
|
||||
Discover Cradlepoint devices by HTTP with script item usage.
|
||||
|
||||
Setup:
|
||||
1. Put your "X-ECM-API-ID" and "X-ECM-API-KEY" key values from NetCloud Manager into {$CP.ECM.API.ID} and {$CP.ECM.API.KEY} macros.
|
||||
2. Put your "X-CP-API-ID" and "X-CP-API-KEY" key values from NetCloud Manager into {$CP.API.ID} and {$CP.API.KEY} macros.
|
||||
|
||||
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-1
|
||||
groups:
|
||||
- name: 'Templates/Network devices'
|
||||
items:
|
||||
- uuid: 6afb34d9e07d4146835989723804dbcb
|
||||
name: 'Get devices item errors'
|
||||
type: DEPENDENT
|
||||
key: cradlepoint.devices.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: cradlepoint.devices.get
|
||||
tags:
|
||||
- tag: component
|
||||
value: error
|
||||
triggers:
|
||||
- uuid: 597abc2d2b324a29b1be39e8087a4005
|
||||
expression: 'length(last(/Cradlepoint NCM v2 by HTTP/cradlepoint.devices.errors))>0'
|
||||
name: 'Cradlepoint: There are errors in the ''Get devices'' metric'
|
||||
priority: WARNING
|
||||
tags:
|
||||
- tag: scope
|
||||
value: availability
|
||||
- uuid: 3a3aed7ebf514349822f747f87daf95b
|
||||
name: 'Get devices'
|
||||
type: SCRIPT
|
||||
key: cradlepoint.devices.get
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function getHttpData(url, params, pagination_required) {
|
||||
var tls = new CTlsConfig(params.tls_verify),
|
||||
request = new HttpRequest(tls.options),
|
||||
response,
|
||||
data;
|
||||
|
||||
tls.checkURL(url);
|
||||
|
||||
if (pagination_required) {
|
||||
data = [];
|
||||
}
|
||||
|
||||
request.addHeader('Content-Type: application/json');
|
||||
request.addHeader('X-CP-API-ID: ' + params.cp_api_id);
|
||||
request.addHeader('X-CP-API-KEY: ' + params.cp_api_key);
|
||||
request.addHeader('X-ECM-API-ID: ' + params.ecm_api_id);
|
||||
request.addHeader('X-ECM-API-KEY: ' + params.ecm_api_key);
|
||||
|
||||
if (typeof params.http_proxy !== 'undefined' && params.http_proxy !== '{' + '$NCM.HTTP_PROXY}' && params.http_proxy !== '') {
|
||||
request.setProxy(params.http_proxy);
|
||||
Zabbix.log(4, '[ NetCloud Manager API v2 ] Using HTTP proxy: ' + params.http_proxy);
|
||||
}
|
||||
|
||||
while (url) {
|
||||
Zabbix.log(4, '[ NetCloud Manager API v2 ] Sending request: ' + url);
|
||||
|
||||
response = request.get(url);
|
||||
|
||||
Zabbix.log(4, '[ NetCloud Manager API v2 ] Received response with status code ' + request.getStatus() + ': ' + response);
|
||||
|
||||
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
||||
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
||||
}
|
||||
|
||||
try {
|
||||
response = JSON.parse(response);
|
||||
}
|
||||
catch (error) {
|
||||
throw 'Failed to parse response received from NetCloud Manager API v2. Check debug log for more information.';
|
||||
}
|
||||
|
||||
if (typeof response !== 'object' || response === null) {
|
||||
throw 'Cannot process response data: received data is not an object.';
|
||||
}
|
||||
|
||||
if (pagination_required) {
|
||||
if (typeof response.meta === 'undefined' || typeof response.data === 'undefined') {
|
||||
throw 'Cannot process response data: received unexpected object.';
|
||||
}
|
||||
|
||||
data = data.concat(response.data);
|
||||
|
||||
if (typeof response.meta.next !== 'undefined' && response.meta.next !== null) {
|
||||
url = response.meta.next;
|
||||
}
|
||||
else {
|
||||
url = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
data = response;
|
||||
url = '';
|
||||
}
|
||||
}
|
||||
|
||||
delete request;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var params = JSON.parse(value),
|
||||
result = { "data": [], "error": "" },
|
||||
error_msg = "";
|
||||
|
||||
var keysList = ['id', 'device_type', 'ipv4_address', 'name', 'group', 'description'];
|
||||
|
||||
try {
|
||||
['cp_api_id', 'cp_api_key', 'ecm_api_id', 'ecm_api_key', 'api_url'].forEach(function (key) {
|
||||
var macro = '{$NCM.' + key.replace('_', '.').toUpperCase() + '}';
|
||||
if (params[key] === macro || params[key] === '') {
|
||||
throw 'Please change ' + macro + ' macro to the proper value.';
|
||||
}
|
||||
if (typeof params[key] === 'undefined') {
|
||||
throw 'Please set \'' + key + '\' script input parameter to ' + macro + ' macro value.';
|
||||
}
|
||||
});
|
||||
|
||||
if (params.api_url.indexOf('http://') === -1 && params.api_url.indexOf('https://') === -1) {
|
||||
params.api_url = 'https://' + params.api_url;
|
||||
}
|
||||
|
||||
if (!params.api_url.endsWith('/')) {
|
||||
params.api_url += '/';
|
||||
}
|
||||
|
||||
var devices = getHttpData(params.api_url + 'routers/?fields=' + keysList.join() +
|
||||
'&limit=' + encodeURIComponent('{$NCM.RESP.DATA.LIMIT:"routers"}'), params, true);
|
||||
|
||||
if (Array.isArray(devices)) {
|
||||
result["data"] = devices;
|
||||
}
|
||||
else {
|
||||
throw 'Failed to parse response received from NetCloud Manager API v2. Check debug log for more information.';
|
||||
}
|
||||
|
||||
if (keysList.indexOf('group') !== -1) {
|
||||
var groups = getHttpData(params.api_url + 'groups/?limit=' + encodeURIComponent('{$NCM.RESP.DATA.LIMIT:"groups"}'), params, true);
|
||||
|
||||
if (!Array.isArray(groups)) {
|
||||
throw 'Failed to parse response received from NetCloud Manager API v2. Check debug log for more information.';
|
||||
}
|
||||
|
||||
result["data"].map(function (device) {
|
||||
groups.forEach(function (group) {
|
||||
if (device.group == null) {
|
||||
device.group = {"name": "Undefined"};
|
||||
return
|
||||
}
|
||||
if (typeof device.group == "string" && device.group.endsWith(group.id+'/')) {
|
||||
device.group = group.name;
|
||||
}
|
||||
});
|
||||
return device;
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
error_msg = error.toString();
|
||||
error_msg += (error_msg.endsWith('.')) ? '' : '.';
|
||||
Zabbix.log(3, '[ NetCloud Manager API v2 ] ERROR: ' + error_msg);
|
||||
};
|
||||
|
||||
result.error = error_msg;
|
||||
|
||||
return JSON.stringify(result);
|
||||
description: 'Item for gathering all devices from NetCloud Manager API.'
|
||||
timeout: '{$NCM.DATA.TIMEOUT}'
|
||||
parameters:
|
||||
- name: api_url
|
||||
value: '{$NCM.API.URL}'
|
||||
- name: cp_api_id
|
||||
value: '{$NCM.CP.API.ID}'
|
||||
- name: cp_api_key
|
||||
value: '{$NCM.CP.API.KEY}'
|
||||
- name: ecm_api_id
|
||||
value: '{$NCM.ECM.API.ID}'
|
||||
- name: ecm_api_key
|
||||
value: '{$NCM.ECM.API.KEY}'
|
||||
- name: http_proxy
|
||||
value: '{$NCM.HTTP_PROXY}'
|
||||
- name: tls_verify
|
||||
value: '{$HTTP.TLS.VERIFY:"Cradlepoint NCM v2"}'
|
||||
tags:
|
||||
- tag: component
|
||||
value: raw
|
||||
- uuid: bfbe3988a57b4f7d8212a2e033b43292
|
||||
name: 'Devices required reboot'
|
||||
type: DEPENDENT
|
||||
key: cradlepoint.devices.reboot_required
|
||||
delay: '0'
|
||||
description: 'Number of devices required reboot.'
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- '$.data[?(@.reboot_required == ''true'')].length()'
|
||||
master_item:
|
||||
key: cradlepoint.devices.get
|
||||
tags:
|
||||
- tag: component
|
||||
value: system
|
||||
triggers:
|
||||
- uuid: d1defc9c540043edbb31c17280129d11
|
||||
expression: '{$NCM.DEVICES.REBOOT.TH}<>-1 and length(last(/Cradlepoint NCM v2 by HTTP/cradlepoint.devices.reboot_required))>{$NCM.DEVICES.REBOOT.TH}'
|
||||
name: 'Cradlepoint: More than {$NCM.DEVICES.REBOOT.TH} devices required reboot'
|
||||
priority: INFO
|
||||
tags:
|
||||
- tag: scope
|
||||
value: notice
|
||||
- uuid: 581006b29fab4e93bbf394d28200bde8
|
||||
name: 'Total devices'
|
||||
type: DEPENDENT
|
||||
key: cradlepoint.devices.total
|
||||
delay: '0'
|
||||
description: 'The total number of all devices.'
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- $.data.length()
|
||||
master_item:
|
||||
key: cradlepoint.devices.get
|
||||
tags:
|
||||
- tag: component
|
||||
value: system
|
||||
- uuid: b74b036314ee40d4b8810fc96789b337
|
||||
name: 'Devices with pending upgrade'
|
||||
type: DEPENDENT
|
||||
key: cradlepoint.devices.upgrade_pending
|
||||
delay: '0'
|
||||
description: 'Number of devices with pending upgrade.'
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- '$.data[?(@.upgrade_pending == ''true'')].length()'
|
||||
master_item:
|
||||
key: cradlepoint.devices.get
|
||||
tags:
|
||||
- tag: component
|
||||
value: system
|
||||
triggers:
|
||||
- uuid: 70f42ff8c8014fb987d00a0ec426547b
|
||||
expression: '{$NCM.DEVICES.UPGRADE.TH}<>-1 and length(last(/Cradlepoint NCM v2 by HTTP/cradlepoint.devices.upgrade_pending))>{$NCM.DEVICES.UPGRADE.TH}'
|
||||
name: 'Cradlepoint: More than {$NCM.DEVICES.UPGRADE.TH} devices awaiting upgrade'
|
||||
priority: INFO
|
||||
tags:
|
||||
- tag: scope
|
||||
value: notice
|
||||
discovery_rules:
|
||||
- uuid: e4609c621e6848ecab825d0bf59776b7
|
||||
name: 'Devices discovery'
|
||||
type: DEPENDENT
|
||||
key: cradlepoint.devices.discovery
|
||||
delay: '0'
|
||||
filter:
|
||||
evaltype: AND
|
||||
conditions:
|
||||
- macro: '{#NAME}'
|
||||
value: '{$NCM.DEVICE.NAME.MATCHES}'
|
||||
formulaid: A
|
||||
- macro: '{#NAME}'
|
||||
value: '{$NCM.DEVICE.NAME.NOT_MATCHES}'
|
||||
operator: NOT_MATCHES_REGEX
|
||||
formulaid: B
|
||||
description: 'Discovering devices from NetCloud Manager API.'
|
||||
host_prototypes:
|
||||
- uuid: 0013a0572be54dfd8195753302b9ddfa
|
||||
host: '{#TYPE}_{#ID}'
|
||||
name: '{#NAME}'
|
||||
inventory_mode: AUTOMATIC
|
||||
group_links:
|
||||
- group:
|
||||
name: 'Discovered hosts'
|
||||
group_prototypes:
|
||||
- name: 'Cradlepoint/{#GROUP}'
|
||||
templates:
|
||||
- name: 'Cradlepoint NCM v2 device by HTTP'
|
||||
macros:
|
||||
- macro: '{$NCM.DEVICE.ID}'
|
||||
value: '{#ID}'
|
||||
description: 'ID of the device.'
|
||||
tags:
|
||||
- tag: device
|
||||
value: '{#TYPE}'
|
||||
master_item:
|
||||
key: cradlepoint.devices.get
|
||||
lld_macro_paths:
|
||||
- lld_macro: '{#DESCR}'
|
||||
path: $.description
|
||||
- lld_macro: '{#GROUP}'
|
||||
path: $.group
|
||||
- lld_macro: '{#ID}'
|
||||
path: $.id
|
||||
- lld_macro: '{#IP}'
|
||||
path: $.ipv4_address
|
||||
- lld_macro: '{#NAME}'
|
||||
path: $.name
|
||||
- lld_macro: '{#TYPE}'
|
||||
path: $.device_type
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- $.data
|
||||
tags:
|
||||
- tag: class
|
||||
value: network
|
||||
- tag: subclass
|
||||
value: modem
|
||||
- tag: target
|
||||
value: cradlepoint
|
||||
- tag: target
|
||||
value: netcloud
|
||||
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 "Cradlepoint NCM v2", e.g. {$HTTP.TLS.VERIFY:"Cradlepoint NCM v2"}.'
|
||||
- macro: '{$NCM.API.URL}'
|
||||
value: 'https://www.cradlepointecm.com/api/v2/'
|
||||
description: 'NetCloud Manager API URL.'
|
||||
- macro: '{$NCM.CP.API.ID}'
|
||||
type: SECRET_TEXT
|
||||
description: 'NetCloud Manager `X-CP-API-ID`.'
|
||||
- macro: '{$NCM.CP.API.KEY}'
|
||||
type: SECRET_TEXT
|
||||
description: 'NetCloud Manager `X-CP-API-KEY`.'
|
||||
- macro: '{$NCM.DATA.TIMEOUT}'
|
||||
value: 15s
|
||||
description: 'The response timeout for the API.'
|
||||
- macro: '{$NCM.DEVICE.NAME.MATCHES}'
|
||||
value: '.*'
|
||||
description: 'A regular expression to filter devices by name. Only devices with names matching this regex will be monitored.'
|
||||
- macro: '{$NCM.DEVICE.NAME.NOT_MATCHES}'
|
||||
value: CHANGE_IF_NEEDED
|
||||
description: 'Regular expression to filter devices by name. Devices with names matching this regex will be excluded from monitoring.'
|
||||
- macro: '{$NCM.DEVICES.REBOOT.TH}'
|
||||
value: '5'
|
||||
description: 'The maximum number of devices requiring a reboot before the trigger fires. The trigger can be disabled by setting the value to `-1`.'
|
||||
- macro: '{$NCM.DEVICES.UPGRADE.TH}'
|
||||
value: '5'
|
||||
description: 'The maximum number of devices with a pending upgrade before the trigger fires. The trigger can be disabled by setting the value to `-1`.'
|
||||
- macro: '{$NCM.ECM.API.ID}'
|
||||
type: SECRET_TEXT
|
||||
description: 'NetCloud Manager `X-ECM-API-ID`.'
|
||||
- macro: '{$NCM.ECM.API.KEY}'
|
||||
type: SECRET_TEXT
|
||||
description: 'NetCloud Manager `X-ECM-API-KEY`.'
|
||||
- macro: '{$NCM.HTTP_PROXY}'
|
||||
description: 'HTTP proxy for API requests. You can specify it using the format [protocol://][username[:password]@]proxy.example.com[:port]. See the documentation at https://www.zabbix.com/documentation/7.0/manual/config/items/itemtypes/http'
|
||||
- macro: '{$NCM.RESP.DATA.LIMIT}'
|
||||
value: '500'
|
||||
description: 'The number of records returned by the API. Max value is `500`.'
|
||||
dashboards:
|
||||
- uuid: ed371a522c6d4bd4907fd5697c9904d3
|
||||
name: General
|
||||
pages:
|
||||
- name: Overview
|
||||
widgets:
|
||||
- type: item
|
||||
name: 'Total devices'
|
||||
width: '24'
|
||||
height: '3'
|
||||
fields:
|
||||
- type: INTEGER
|
||||
name: decimal_places
|
||||
value: '0'
|
||||
- type: ITEM
|
||||
name: itemid.0
|
||||
value:
|
||||
host: 'Cradlepoint NCM v2 by HTTP'
|
||||
key: cradlepoint.devices.total
|
||||
- type: INTEGER
|
||||
name: show.0
|
||||
value: '2'
|
||||
- type: problems
|
||||
name: Problems
|
||||
'y': '3'
|
||||
width: '72'
|
||||
height: '6'
|
||||
- type: item
|
||||
name: 'Devices required reboot'
|
||||
x: '24'
|
||||
width: '24'
|
||||
height: '3'
|
||||
fields:
|
||||
- type: INTEGER
|
||||
name: decimal_places
|
||||
value: '0'
|
||||
- type: ITEM
|
||||
name: itemid.0
|
||||
value:
|
||||
host: 'Cradlepoint NCM v2 by HTTP'
|
||||
key: cradlepoint.devices.reboot_required
|
||||
- type: INTEGER
|
||||
name: show.0
|
||||
value: '2'
|
||||
- type: item
|
||||
name: 'Devices with pending upgrade'
|
||||
x: '48'
|
||||
width: '24'
|
||||
height: '3'
|
||||
fields:
|
||||
- type: INTEGER
|
||||
name: decimal_places
|
||||
value: '0'
|
||||
- type: ITEM
|
||||
name: itemid.0
|
||||
value:
|
||||
host: 'Cradlepoint NCM v2 by HTTP'
|
||||
key: cradlepoint.devices.upgrade_pending
|
||||
- type: INTEGER
|
||||
name: show.0
|
||||
value: '2'
|
||||
graphs:
|
||||
- uuid: 57bdf098cf7c4d8388e85ec5fd65793d
|
||||
name: 'Devices required reboot'
|
||||
ymin_type_1: FIXED
|
||||
graph_items:
|
||||
- color: 199C0D
|
||||
item:
|
||||
host: 'Cradlepoint NCM v2 by HTTP'
|
||||
key: cradlepoint.devices.reboot_required
|
||||
- uuid: a4b7e2626afb4e11a9001851a86ce8a0
|
||||
name: 'Devices with pending upgrade'
|
||||
ymin_type_1: FIXED
|
||||
graph_items:
|
||||
- color: 199C0D
|
||||
item:
|
||||
host: 'Cradlepoint NCM v2 by HTTP'
|
||||
key: cradlepoint.devices.upgrade_pending
|
||||
- uuid: b6e662a0f1714ad0ba1bd7a5ca2e2405
|
||||
name: 'Total devices'
|
||||
ymin_type_1: FIXED
|
||||
graph_items:
|
||||
- color: 199C0D
|
||||
item:
|
||||
host: 'Cradlepoint NCM v2 by HTTP'
|
||||
key: cradlepoint.devices.total
|
||||
Reference in New Issue
Block a user