Files
templates-default/Cisco_SD-WAN_by_HTTP.yaml
T

678 lines
26 KiB
YAML

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: e5cf4e7ac41a470b99e4262d1c5ee104
template: 'Cisco SD-WAN by HTTP'
name: 'Cisco SD-WAN by HTTP'
description: |
Discover Cisco SD-WAN devices by HTTP with script item usage.
Setup:
1. Put your username and password from Cisco SD-WAN vManage into {$SDWAN.API.USERNAME} and {$SDWAN.API.PASSWORD} macros.
2. Set your Cisco SD-WAN vManage URL as {$SDWAN.API.URL} macro value.
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-2
groups:
- name: Templates/Applications
- name: 'Templates/Network devices'
items:
- uuid: efc5456a02d04ade93cd54b145ebc24d
name: 'Authentication item errors'
type: DEPENDENT
key: sd_wan.auth.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: sd_wan.authentication
tags:
- tag: component
value: error
triggers:
- uuid: 9f98b660a10a4891910b0e3b42f90403
expression: 'length(last(/Cisco SD-WAN by HTTP/sd_wan.auth.errors))>0'
name: 'Cisco SD-WAN: Authentication has failed'
priority: AVERAGE
tags:
- tag: scope
value: availability
- uuid: 5aa5a643a3cf42148454507da22aeb17
name: Authentication
type: SCRIPT
key: sd_wan.authentication
delay: '{$SDWAN.AUTH.FREQUENCY}'
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),
tls = new CTlsConfig(params.tls_verify),
request = new HttpRequest(tls.options),
cookies = [],
token = "",
error_msg = "";
function authenticate(url) {
tls.checkURL(url);
var payload = 'j_username=' + encodeURIComponent(params.username)
+ '&j_password=' + encodeURIComponent(params.password);
request.addHeader('Content-Type', 'application/x-www-form-urlencoded');
response = request.post(url, payload);
Zabbix.log(4, '[ SD-WAN API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
if (request.getStatus() !== 200) {
throw 'Failed to receive data: invalid response status code.';
}
if (response !== null && response != "") {
throw 'Authentication failed.';
}
var headers = request.getHeaders();
for (key in headers) {
if (key.toLowerCase() == 'set-cookie') {
var entries = headers[key].split(',');
for (idx in entries) {
var value = entries[idx].split(';')[0];
cookies.push(value);
}
}
}
};
function getToken(url) {
tls.checkURL(url);
response = request.get(url);
Zabbix.log(4, '[ SD-WAN API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
if (request.getStatus() !== 200) {
throw 'Failed to receive data: invalid response status code.';
}
var headers = request.getHeaders();
for (key in headers) {
if (key.toLowerCase() == 'content-type' && headers[key] != 'application/json') {
throw 'Something went wrong while getting the authentication token. Check debug log for more information.';
}
}
return response;
};
try {
['username', 'password', 'url'].forEach(function (field) {
var macro = '{$SDWAN.API.' + field.toUpperCase() + '}';
if (params[field] === macro || params[field] === '') {
throw 'Please change ' + macro + ' macro to the proper value.';
}
if (typeof params[field] === 'undefined') {
throw 'Please set \'' + field + '\' script input parameter to ' + macro + ' macro value.';
}
});
if (params.url.indexOf('http://') === -1 && params.url.indexOf('https://') === -1) {
params.url = 'https://' + params.url;
}
if (!params.url.endsWith('/')) {
params.url += '/';
}
if (typeof params.http_proxy !== 'undefined' && params.http_proxy !== '{' + '$SDWAN.HTTP_PROXY}' && params.http_proxy !== '') {
request.setProxy(params.http_proxy);
}
authenticate(params.url + 'j_security_check');
token = getToken(params.url + 'dataservice/client/token');
} catch (err) {
error_msg = err;
};
return JSON.stringify({
'cookie': cookies.join('; '),
'token': token,
'error': error_msg.toString()
});
description: |
Cisco SD-WAN authentication with service account parameters and temporary-generated token usage.
Returns an authentication token and session id; it is required only once and is used for all dependent script items.
A session will expire after 30 minutes of inactivity or after 24 hours, which is the total lifespan of a session.
Check the template documentation for the details.
timeout: '{$SDWAN.DATA.TIMEOUT}'
parameters:
- name: http_proxy
value: '{$SDWAN.HTTP_PROXY}'
- name: password
value: '{$SDWAN.API.PASSWORD}'
- name: tls_verify
value: '{$HTTP.TLS.VERIFY:"Cisco SD-WAN"}'
- name: url
value: '{$SDWAN.API.URL}'
- name: username
value: '{$SDWAN.API.USERNAME}'
tags:
- tag: component
value: raw
- uuid: bbb2713e2e174c558315de8b2fd55f0f
name: 'Get devices'
type: DEPENDENT
key: sd_wan.get.devices
delay: '0'
history: '0'
value_type: TEXT
trends: '0'
description: 'Item for gathering all devices from Cisco SD-WAN API.'
preprocessing:
- type: JAVASCRIPT
parameters:
- |
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;
};
}
try {
var creds = JSON.parse(value);
}
catch (error) {
throw 'Failed to parse authentication data from input value.';
}
var tls = new CTlsConfig('{{$HTTP.TLS.VERIFY:"Cisco SD-WAN"}.regsub("^(none|peer|full)$", "\1")}'),
request = new HttpRequest(tls.options),
devices = [],
error_msg = "",
url = "{$SDWAN.API.URL}",
http_proxy = "{$SDWAN.HTTP_PROXY}";
function getHttpData(url, token, cookie) {
tls.checkURL(url);
request.addHeader('Cookie: ' + cookie);
request.addHeader('X-XSRF-TOKEN: ' + token);
response = request.get(url);
Zabbix.log(4, '[ SD-WAN API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
if (request.getStatus() !== 200) {
throw 'Failed to receive data: invalid response status code.';
}
if (response !== null) {
try {
response = JSON.parse(response);
}
catch (error) {
throw 'Failed to parse response received from SD-WAN API. Check debug log for more information.';
}
}
if (typeof response !== 'object' || response === null) {
throw 'Cannot process response data: received data is not an object.';
}
return response;
};
try {
['token', 'cookie'].forEach(function (field) {
if (creds[field] === null || creds[field] == "" || typeof creds[field] === 'undefined') {
throw 'Unexpected token value has been received'
+ ((typeof creds.error !== 'undefined' && creds.error != "") ? ': ' + creds.error : '');
}
});
if (url === '{' + '$SDWAN.API.URL}') {
throw 'Please change {' + '$SDWAN.API.URL} macro to the proper value.';
}
if (url.indexOf('http://') === -1 && url.indexOf('https://') === -1) {
url = 'https://' + url;
}
if (!url.endsWith('/')) {
url += '/';
}
if (http_proxy !== '{' + '$SDWAN.HTTP_PROXY}' && http_proxy !== '') {
request.setProxy(http_proxy);
}
devices = getHttpData(
url + 'dataservice/device',
creds.token,
creds.cookie
);
if (Array.isArray(devices.data)) {
devices = devices.data;
}
else {
throw 'Failed to parse response received from SD-WAN API. Check debug log for more information.';
}
} catch (err) {
error_msg = err;
};
return JSON.stringify({
'devices': devices.map(function (device) {
obj = {
'name': device['host-name'],
'token': creds.token,
'cookie': creds.cookie,
'id': device['deviceId'],
'uuid': device['uuid'],
'type': device['device-type'],
'model': device['device-model'],
'ip': device['system-ip'],
'int_ip': device['local-system-ip'],
'cert_valid': device['certificate-validity']
};
return obj;
}),
'error': error_msg.toString()
});
master_item:
key: sd_wan.authentication
tags:
- tag: component
value: raw
- uuid: 172dd697ad7b4b5d907b8d30faef7c52
name: 'Get devices item errors'
type: DEPENDENT
key: sd_wan.get.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: sd_wan.get.devices
tags:
- tag: component
value: error
triggers:
- uuid: 9cfcfbb6b6264c19a831a71cc47483a9
expression: 'length(last(/Cisco SD-WAN by HTTP/sd_wan.get.devices.errors))>0'
name: 'Cisco SD-WAN: There are errors in the ''Get devices'' metric'
priority: WARNING
tags:
- tag: scope
value: availability
- uuid: eb1ffb2430c8450981f86174ac71456e
name: 'Invalid certificates'
type: DEPENDENT
key: sd_wan.invalid_certificates
delay: '0'
description: 'Number of invalid certificates.'
preprocessing:
- type: JSONPATH
parameters:
- '$.devices[?(@.cert_valid != "Valid")].length()'
master_item:
key: sd_wan.get.devices
tags:
- tag: component
value: system
- uuid: 6ad73678b22346849ce5df9656e6edae
name: 'Total devices'
type: DEPENDENT
key: sd_wan.total.devices
delay: '0'
description: 'The total number of all devices.'
preprocessing:
- type: JSONPATH
parameters:
- $.devices.length()
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
key: sd_wan.get.devices
tags:
- tag: component
value: system
- uuid: aee4253ce4e143ddad3d7776ebe72055
name: 'Number of vBond devices'
type: DEPENDENT
key: sd_wan.vbond.devices
delay: '0'
description: 'The total number of vBond devices.'
preprocessing:
- type: JSONPATH
parameters:
- '$.devices[?(@.type == "vbond")].length()'
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
key: sd_wan.get.devices
tags:
- tag: component
value: system
- uuid: 8e0b166d7cac435bb74fba811c5881af
name: 'Number of vEdge devices'
type: DEPENDENT
key: sd_wan.vedge.devices
delay: '0'
description: 'The total number of vEdge devices.'
preprocessing:
- type: JSONPATH
parameters:
- '$.devices[?(@.type == "vedge")].length()'
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
key: sd_wan.get.devices
tags:
- tag: component
value: system
- uuid: e419f8b060af44b0ad6f52d5613b0973
name: 'Number of vManage devices'
type: DEPENDENT
key: sd_wan.vmanage.devices
delay: '0'
description: 'The total number of vManage devices.'
preprocessing:
- type: JSONPATH
parameters:
- '$.devices[?(@.type == "vmanage")].length()'
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
key: sd_wan.get.devices
tags:
- tag: component
value: system
- uuid: 385cb04360ea4d34b2ae04c6879ec8fa
name: 'Number of vSmart devices'
type: DEPENDENT
key: sd_wan.vsmart.devices
delay: '0'
description: 'The total number of vSmart devices.'
preprocessing:
- type: JSONPATH
parameters:
- '$.devices[?(@.type == "vsmart")].length()'
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
master_item:
key: sd_wan.get.devices
tags:
- tag: component
value: system
discovery_rules:
- uuid: 2e445f8991f842e09fc206ed3e392038
name: 'Devices discovery'
type: DEPENDENT
key: sd_wan.devices.discovery
delay: '0'
filter:
evaltype: AND
conditions:
- macro: '{#NAME}'
value: '{$SDWAN.DEVICE.NAME.MATCHES}'
formulaid: A
- macro: '{#NAME}'
value: '{$SDWAN.DEVICE.NAME.NOT_MATCHES}'
operator: NOT_MATCHES_REGEX
formulaid: B
description: 'Discovering devices from Cisco SD-WAN API.'
host_prototypes:
- uuid: 8c53a2dded4a47cba1eb3398aff888d7
host: '{#UUID}'
name: '[{#TYPE}] {#NAME}'
inventory_mode: AUTOMATIC
group_links:
- group:
name: Applications
group_prototypes:
- name: 'Cisco SD-WAN/{#TYPE}'
templates:
- name: 'Cisco SD-WAN device by HTTP'
macros:
- macro: '{$SDWAN.AUTH.SESSION}'
value: '{#COOKIE}'
description: 'Cisco SD-WAN authentication session.'
- macro: '{$SDWAN.AUTH.TOKEN}'
value: '{#TOKEN}'
description: 'Cisco SD-WAN authentication token.'
- macro: '{$SDWAN.DEVICE_ID}'
value: '{#ID}'
description: 'ID of the device.'
tags:
- tag: model
value: '{#MODEL}'
custom_interfaces: 'YES'
interfaces:
- default: 'NO'
ip: '{#INT.IP}'
dns: internal.ip
- ip: '{#IP}'
dns: external.ip
master_item:
key: sd_wan.get.devices
lld_macro_paths:
- lld_macro: '{#COOKIE}'
path: $.cookie
- lld_macro: '{#ID}'
path: $.id
- lld_macro: '{#INT.IP}'
path: $.int_ip
- lld_macro: '{#IP}'
path: $.ip
- lld_macro: '{#MODEL}'
path: $.model
- lld_macro: '{#NAME}'
path: $.name
- lld_macro: '{#TOKEN}'
path: $.token
- lld_macro: '{#TYPE}'
path: $.type
- lld_macro: '{#UUID}'
path: $.uuid
preprocessing:
- type: JSONPATH
parameters:
- $.devices
tags:
- tag: class
value: network
- tag: target
value: cisco-sdwan-monitor
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 SD-WAN", e.g. {$HTTP.TLS.VERIFY:"Cisco SD-WAN"}.'
- macro: '{$SDWAN.API.PASSWORD}'
type: SECRET_TEXT
description: 'Cisco SD-WAN Monitor API password.'
- macro: '{$SDWAN.API.URL}'
description: 'Cisco SD-WAN Monitor API URL.'
- macro: '{$SDWAN.API.USERNAME}'
type: SECRET_TEXT
description: 'Cisco SD-WAN Monitor API username.'
- macro: '{$SDWAN.AUTH.FREQUENCY}'
value: 1h
description: 'The update interval for the Cisco SD-WAN Authentication item, which also equals the access token regeneration request frequency. Check the template documentation notes carefully for more details.'
- macro: '{$SDWAN.DATA.TIMEOUT}'
value: 15s
description: 'A response timeout for an API.'
- macro: '{$SDWAN.DEVICE.NAME.MATCHES}'
value: '.*'
description: 'This macro is used in device discovery. Can be overridden on the host or linked template level.'
- macro: '{$SDWAN.DEVICE.NAME.NOT_MATCHES}'
value: CHANGE_IF_NEEDED
description: 'This macro is used in device discovery. Can be overridden on the host or linked template level.'
- macro: '{$SDWAN.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'
dashboards:
- uuid: 63a5053a13114e90b104d189bea96254
name: 'SD-WAN: Overview'
pages:
- name: Main
widgets:
- type: item
name: 'Total devices'
width: '36'
height: '4'
fields:
- type: ITEM
name: itemid.0
value:
host: 'Cisco SD-WAN by HTTP'
key: sd_wan.total.devices
- type: INTEGER
name: show.0
value: '2'
- type: item
name: 'vManage devices'
'y': '4'
width: '36'
height: '4'
fields:
- type: ITEM
name: itemid.0
value:
host: 'Cisco SD-WAN by HTTP'
key: sd_wan.vmanage.devices
- type: INTEGER
name: show.0
value: '2'
- type: item
name: 'vSmart devices'
'y': '8'
width: '36'
height: '4'
fields:
- type: ITEM
name: itemid.0
value:
host: 'Cisco SD-WAN by HTTP'
key: sd_wan.vsmart.devices
- type: INTEGER
name: show.0
value: '2'
- type: item
name: 'Invalid certificates'
x: '36'
width: '36'
height: '4'
fields:
- type: ITEM
name: itemid.0
value:
host: 'Cisco SD-WAN by HTTP'
key: sd_wan.invalid_certificates
- type: INTEGER
name: show.0
value: '2'
- type: item
name: 'vBond devices'
x: '36'
'y': '4'
width: '36'
height: '4'
fields:
- type: ITEM
name: itemid.0
value:
host: 'Cisco SD-WAN by HTTP'
key: sd_wan.vbond.devices
- type: INTEGER
name: show.0
value: '2'
- type: item
name: 'vEdge devices'
x: '36'
'y': '8'
width: '36'
height: '4'
fields:
- type: ITEM
name: itemid.0
value:
host: 'Cisco SD-WAN by HTTP'
key: sd_wan.vedge.devices
- type: INTEGER
name: show.0
value: '2'