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-0
      groups:
        - name: Templates/Applications
        - name: 'Templates/Network devices'
      items:
        - uuid: efc5456a02d04ade93cd54b145ebc24d
          name: 'Authentication item errors'
          type: DEPENDENT
          key: sd_wan.auth.errors
          value_type: TEXT
          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: '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
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	cookies = [],
            	token = "",
            	error_msg = "";
            
            function authenticate(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) {
            	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: 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
          history: '0'
          value_type: TEXT
          description: 'Item for gathering all devices from Cisco SD-WAN API.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  try {
                  	var creds = JSON.parse(value);
                  }
                  catch (error) {
                  	throw 'Failed to parse authentication data from input value.';
                  }
                  
                  var request = new HttpRequest(),
                  	devices = [],
                  	error_msg = "",
                  	url = "{$SDWAN.API.URL}",
                  	http_proxy = "{$SDWAN.HTTP_PROXY}";
                  
                  function getHttpData(url, token, cookie) {
                  	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
          value_type: TEXT
          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: '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
          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
          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
          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
          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
          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
          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
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$SDWAN.DEVICE.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$SDWAN.DEVICE.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          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: '{$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'
    - uuid: e1e25df663204b099f2597caf89a0678
      template: 'Cisco SD-WAN device by HTTP'
      name: 'Cisco SD-WAN device by HTTP'
      description: |
        Get Cisco SD-WAN devices monitoring with script item usage to perform HTTP requests to Cisco SD-WAN API.
        This template will be automatically connected to discovered entities with all required parameters pre-defined.
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Applications
        - name: 'Templates/Network devices'
      items:
        - uuid: e72b66fe978e4495b07c95216ee2fb30
          name: 'Operating system architecture'
          type: DEPENDENT
          key: sd_wan.device.arch
          value_type: CHAR
          description: 'The architecture of the operating system.'
          inventory_link: OS_SHORT
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.platform
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: os
        - uuid: a9565657b94b4bd5b4e82692ab3f0f9a
          name: 'Certificate validity'
          type: DEPENDENT
          key: sd_wan.device.certificate_validity
          description: 'Validity status of the device certificate.'
          valuemap:
            name: 'Validity status'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["certificate-validity"]'
              error_handler: CUSTOM_VALUE
              error_handler_params: Unknown
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'Valid',
                  	'Invalid',
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: certificate
          triggers:
            - uuid: 8a35b69998bd4819b3f9677fd4367d59
              expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.certificate_validity)=1'
              name: 'Device certificate is invalid'
              priority: WARNING
              tags:
                - tag: scope
                  value: security
        - uuid: 8a30d4aef9c54c15a56a34ddc0f277d5
          name: 'Control connections'
          type: DEPENDENT
          key: sd_wan.device.control_conn
          description: 'The number of control connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.controlConnections
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
            - type: MATCHES_REGEX
              parameters:
                - '^[0-9]+$'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: network
        - uuid: e8185c1ab7924a378dd4a0368b2bc96d
          name: 'Load average (1m avg)'
          type: DEPENDENT
          key: 'sd_wan.device.cpu.load[avg1]'
          value_type: FLOAT
          description: 'The average number of processes being or waiting executed over past 1 minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.min1_avg
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: cpu
        - uuid: 8e1b51fcdb9c49028adfe41d8e4cd07f
          name: 'Load average (5m avg)'
          type: DEPENDENT
          key: 'sd_wan.device.cpu.load[avg5]'
          value_type: FLOAT
          description: 'The average number of processes being or waiting executed over past 5 minutes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.min5_avg
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: cpu
        - uuid: e9b2cedafb0a4dde83c3f8e3ec658d9e
          name: 'Load average (15m avg)'
          type: DEPENDENT
          key: 'sd_wan.device.cpu.load[avg15]'
          value_type: FLOAT
          description: 'The average number of processes being or waiting executed over past 15 minutes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.min15_avg
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: cpu
        - uuid: 193a05a570744296b12927cdd7d5c80a
          name: 'Number of CPUs'
          type: DEPENDENT
          key: sd_wan.device.cpu.num
          description: 'The total number of CPU.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total_cpu_count
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: system
        - uuid: cbdaee2fc07f4fe9941bb9e1c1b25693
          name: 'CPU utilization'
          type: DEPENDENT
          key: sd_wan.device.cpu.util
          value_type: FLOAT
          units: '%'
          description: 'CPU utilization, expressed in %.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return (100 - value);'
          master_item:
            key: 'sd_wan.device.cpu.util[idle]'
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 58cedf1e3f2e42a8a58d270ca0c385a8
              expression: 'min(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.util,5m)>{$SDWAN.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              event_name: 'High CPU utilization (over {$SDWAN.CPU.UTIL.CRIT}% for 5m)'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'CPU utilization is too high. The system might be slow to respond.'
              dependencies:
                - name: 'Load average is too high'
                  expression: |
                    min(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.load[avg1],5m)/last(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.num)>{$SDWAN.LA.PER.CPU.MAX.WARN}
                    and last(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.load[avg5])>0
                    and last(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.load[avg15])>0
              tags:
                - tag: scope
                  value: performance
        - uuid: d87ecb03ca2b48efb7a47ddde260b497
          name: 'CPU idle time'
          type: DEPENDENT
          key: 'sd_wan.device.cpu.util[idle]'
          value_type: FLOAT
          units: '%'
          description: 'The time the CPU has spent doing nothing.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.cpu_idle
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: cpu
        - uuid: 3f82fb93e5d74aeaa656f23fd9647a27
          name: 'CPU system time'
          type: DEPENDENT
          key: 'sd_wan.device.cpu.util[system]'
          value_type: FLOAT
          units: '%'
          description: 'The time the CPU has spent running the kernel and its processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.cpu_system
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: cpu
        - uuid: 4f7d0c18da724f888b3f6e82f4becd7a
          name: 'CPU user time'
          type: DEPENDENT
          key: 'sd_wan.device.cpu.util[user]'
          value_type: FLOAT
          units: '%'
          description: 'The time the CPU has spent running users'' processes that are not niced.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.cpu_user
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: cpu
        - uuid: ce17521dd90a442d86270a11e3931338
          name: 'System name'
          type: DEPENDENT
          key: sd_wan.device.hostname
          value_type: CHAR
          description: 'The system host name.'
          inventory_link: NAME
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["host-name"]'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 8658639567ed4eb5964b4543c5b3debe
              expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.hostname,#1)<>last(/Cisco SD-WAN device by HTTP/sd_wan.device.hostname,#2) and length(last(/Cisco SD-WAN device by HTTP/sd_wan.device.hostname))>0'
              name: 'System name has changed'
              event_name: 'System name has changed (new name: {ITEM.VALUE})'
              priority: INFO
              description: 'System name has changed. Ack to close.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: dfdd804076df4050963a5270501dc759
          name: 'Available memory'
          type: DEPENDENT
          key: sd_wan.device.memory.avail
          units: B
          description: 'The amount of physical memory (in bytes) immediately available for the allocation to a process or for a system use in the device.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mem_free
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: memory
        - uuid: 0ad610d976644766b8997311c72c0d7c
          name: 'Memory (buffers)'
          type: DEPENDENT
          key: sd_wan.device.memory.buffers
          units: B
          description: 'The amount of physical memory (in bytes) used by the kernel buffers.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mem_buffers
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: memory
        - uuid: e344c9575c954e9584074e6cd161349b
          name: 'Memory (cached)'
          type: DEPENDENT
          key: sd_wan.device.memory.cached
          units: B
          description: 'The amount of physical memory (in bytes) used by the page cache and slabs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mem_cached
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: memory
        - uuid: 90566bdf0458468e8607dd05a53efb4c
          name: 'Total memory'
          type: DEPENDENT
          key: sd_wan.device.memory.total
          units: B
          description: 'Total memory, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mem_total
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: memory
        - uuid: 80ae65af0a4c42ffb5a5b6b5179e85fc
          name: 'Used memory'
          type: DEPENDENT
          key: sd_wan.device.memory.used
          units: B
          description: 'The amount of physical memory (in bytes) used by applications on the device.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mem_used
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: memory
        - uuid: 8b8551ab8a8c4586b2a1bc02bcc7ca60
          name: 'Memory utilization'
          type: CALCULATED
          key: sd_wan.device.memory.util
          value_type: FLOAT
          units: '%'
          params: 'last(//sd_wan.device.memory.used)/last(//sd_wan.device.memory.total)*100'
          description: 'Calculated percentage of the memory used, in %.'
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 0f30b8dc5ebc44ea98a860b159501f99
              expression: 'min(/Cisco SD-WAN device by HTTP/sd_wan.device.memory.util,5m)>{$SDWAN.MEMORY.UTIL.MAX}'
              name: 'High memory utilization'
              event_name: 'High memory utilization (>{$SDWAN.MEMORY.UTIL.MAX}% for 5m)'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The system is running out of free memory.'
              dependencies:
                - name: 'Lack of available memory'
                  expression: 'max(/Cisco SD-WAN device by HTTP/sd_wan.device.memory.avail,5m)<{$SDWAN.MEMORY.AVAILABLE.MIN} and last(/Cisco SD-WAN device by HTTP/sd_wan.device.memory.total)>0'
              tags:
                - tag: scope
                  value: capacity
                - tag: scope
                  value: performance
        - uuid: 840c5d843f4f4def865a8043396a21f5
          name: 'Model name'
          type: DEPENDENT
          key: sd_wan.device.model
          value_type: CHAR
          description: 'The model name of the device.'
          inventory_link: MODEL
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["device-model"]'
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: system
        - uuid: 809418dac3be4dd7b8cf3024388b1a11
          name: 'Operating system'
          type: DEPENDENT
          key: sd_wan.device.os
          value_type: CHAR
          description: 'The device operating system.'
          inventory_link: OS
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["device-os"]'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: os
          triggers:
            - uuid: b2c78cb56f7f40cfa8844f3f51293538
              expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.os,#1)<>last(/Cisco SD-WAN device by HTTP/sd_wan.device.os,#2) and length(last(/Cisco SD-WAN device by HTTP/sd_wan.device.os))>0'
              name: 'Operating system description has changed'
              priority: INFO
              description: 'Operating system description has changed. Possible reasons that system has been updated or replaced. Ack to close.'
              manual_close: 'YES'
              dependencies:
                - name: 'Device has been replaced'
                  expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.serialnumber,#1)<>last(/Cisco SD-WAN device by HTTP/sd_wan.device.serialnumber,#2) and length(last(/Cisco SD-WAN device by HTTP/sd_wan.device.serialnumber))>0'
              tags:
                - tag: scope
                  value: notice
        - uuid: 5e9d4d61e72e4755a242f36bcf93b534
          name: 'Number of processes'
          type: DEPENDENT
          key: sd_wan.device.proc.num
          description: 'The total number of processes in any state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.procs
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: system
        - uuid: 60381f3d5e914ce4b281d65c212c44b6
          name: 'Device reachability'
          type: DEPENDENT
          key: sd_wan.device.reachability
          description: 'Reachability to the vManager and/or the entire network.'
          valuemap:
            name: 'Reachability status'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.reachability
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'reachable',
                  	'unreachable',
                  	'auth-failed',
                  	'staging'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: d35babbd678f44c3a570fc9a896c58dc
              expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.reachability)<>0'
              name: 'Device is not reachable'
              opdata: 'Current status: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'Device is not reachable to the vManager and/or the entire network.'
              tags:
                - tag: scope
                  value: availability
        - uuid: f1cc4c623c754d17881f9217466ec21d
          name: 'Device role'
          type: DEPENDENT
          key: sd_wan.device.role
          value_type: CHAR
          description: 'The device role in the network.'
          valuemap:
            name: Unknown
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.device_role
              error_handler: CUSTOM_VALUE
              error_handler_params: '-1'
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: system
        - uuid: d665ec254da44501bf7be0b78156b01f
          name: 'Serial Number'
          type: DEPENDENT
          key: sd_wan.device.serialnumber
          value_type: CHAR
          description: 'The device serial number.'
          inventory_link: SERIALNO_A
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["board-serial"]'
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: a6ad77fe04684d1fa90fac2164519b31
              expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.serialnumber,#1)<>last(/Cisco SD-WAN device by HTTP/sd_wan.device.serialnumber,#2) and length(last(/Cisco SD-WAN device by HTTP/sd_wan.device.serialnumber))>0'
              name: 'Device has been replaced'
              event_name: 'Device has been replaced (new serial number received)'
              priority: INFO
              description: 'Device serial number has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 19bc5d63eb424ecab4d8b1291191d0cd
          name: 'Device state'
          type: DEPENDENT
          key: sd_wan.device.state
          description: 'The device current state.'
          valuemap:
            name: 'Device state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.state
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'green',
                  	'yellow',
                  	'red'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: health
        - uuid: bae48575c12941e38346df2ae00374ec
          name: 'Device state description'
          type: DEPENDENT
          key: sd_wan.device.state_descr
          value_type: CHAR
          description: 'The description of the device current state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.state_description
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: health
        - uuid: c1ada0df07b94b1daf3881fac4c9a8d3
          name: 'System uptime'
          type: DEPENDENT
          key: sd_wan.device.uptime
          units: uptime
          description: 'The system uptime is calculated on the basis of boot time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["uptime-date"]'
            - type: JAVASCRIPT
              parameters:
                - 'return (Math.floor(Date.now()/1000)-Math.floor(Number(value)/1000));'
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 08ac00695a6c4e2a80dc9cb16d85de43
              expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.uptime)<10m'
              name: 'Device has been restarted'
              event_name: '{HOST.NAME} has been restarted (uptime < 10m)'
              priority: INFO
              description: 'The host uptime is less than 10 minutes'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 818ad0a67ba749619e03a746e9489404
          name: Version
          type: DEPENDENT
          key: sd_wan.device.version
          value_type: CHAR
          description: 'The version of the device software.'
          inventory_link: SOFTWARE_FULL
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.version
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: system
        - uuid: 7a4cc11f131e4f7f9511ac19dbfb82f4
          name: 'Get device data'
          type: SCRIPT
          key: sd_wan.get.device
          history: '0'
          value_type: TEXT
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	device_info = {},
            	error_msg = "";
            
            function getHttpData(url, token, cookie) {
            	request.addHeader('Cookie: ' + cookie);
            	request.addHeader('X-XSRF-TOKEN: ' + token);
            	response = request.get(url);
            	Zabbix.log(4, '[ Cisco SD-WAN ] [ ' + 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 Cisco 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 {
            	['auth.token', 'auth.cookie', 'api.url', 'device_id'].forEach(function (field) {
            		var macro = '{$SDWAN.' + field.toUpperCase() + '}';
            		var key = field.split('.').slice(-1);
            		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.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);
            	}
            
            	device_info = getHttpData(
            		params.url + 'dataservice/device?deviceId=' + encodeURIComponent(params.device_id),
            		params.token,
            		params.cookie
            	);
            
            	if (Array.isArray(device_info.data) && device_info.data.length > 0) {
            		device_info = device_info.data[0];
            	}
            	else {
            		throw 'Failed to parse response received from Cisco SD-WAN API. Check debug log for more information.';
            	}
            
            	var system_info = getHttpData(
            		params.url + 'dataservice/device/system/status?deviceId=' + params.device_id,
            		params.token,
            		params.cookie
            	);
            
            	if (Array.isArray(system_info.data) && system_info.data.length > 0) {
            		device_info = Object.assign(device_info, system_info.data[0]);
            	}
            	else {
            		throw 'Failed to parse response received from Cisco SD-WAN API. Check debug log for more information.';
            	}
            } catch (error) {
            	error_msg = error.toString();
            	error_msg += (error_msg.endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Cisco SD-WAN ] ERROR: ' + error_msg);
            };
            
            device_info.error = error_msg;
            
            return JSON.stringify(device_info);
          description: 'Item for gathering device data from Cisco SD-WAN API.'
          timeout: '{$SDWAN.DATA.TIMEOUT}'
          parameters:
            - name: cookie
              value: '{$SDWAN.AUTH.SESSION}'
            - name: device_id
              value: '{$SDWAN.DEVICE_ID}'
            - name: http_proxy
              value: '{$SDWAN.HTTP_PROXY}'
            - name: token
              value: '{$SDWAN.AUTH.TOKEN}'
            - name: url
              value: '{$SDWAN.API.URL}'
          tags:
            - tag: component
              value: raw
        - uuid: dfef0a5aa8054effaab44fb04df20778
          name: 'Device data item errors'
          type: DEPENDENT
          key: sd_wan.get.device.errors
          value_type: TEXT
          description: 'Item for gathering errors of the device item.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: sd_wan.get.device
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: 7e9b6cee9ddd47428d01d1a8cadb28fc
              expression: 'length(last(/Cisco SD-WAN device by HTTP/sd_wan.get.device.errors))>0'
              name: 'There are errors in the ''Get device data'' metric'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
        - uuid: 694fb02640314fcab6cb2352fe4378ea
          name: 'Get interfaces data'
          type: SCRIPT
          key: sd_wan.get.interfaces
          history: '0'
          value_type: TEXT
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	result = { "data": [], "error": "" },
            	error_msg = "";
            
            function getHttpData(url, token, cookie) {
            	request.addHeader('Cookie: ' + cookie);
            	request.addHeader('X-XSRF-TOKEN: ' + token);
            	response = request.get(url);
            	Zabbix.log(4, '[ Cisco SD-WAN ] [ ' + 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 Cisco 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 {
            	['auth.token', 'auth.cookie', 'api.url', 'device_id'].forEach(function (field) {
            		var macro = '{$SDWAN.' + field.toUpperCase() + '}';
            		var key = field.split('.').slice(-1);
            		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.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);
            	}
            
            	var interface_list = getHttpData(
            		params.url + 'dataservice/device/interface?deviceId=' + encodeURIComponent(params.device_id),
            		params.token,
            		params.cookie
            	);
            
            	if (Array.isArray(interface_list.data) && interface_list.data.length > 0) {
            		var interfaces = {};
            		interface_list.data.forEach(function (if_item) {
            			var if_key = if_item['vdevice-name'] + '_' + if_item.ifname + '_' + if_item.ifindex;
            			interfaces[if_key] = (typeof interfaces[if_key] !== 'undefined') ? interfaces[if_key] : {};
            			if (typeof if_item['af-type'] !== 'undefined') {
            				if (if_item['af-type'].includes('ipv6')) {
            					Object.keys(if_item).sort().forEach(function (key) {
            						if (key.match(/([tr]x-)/g)) {
            							interfaces[if_key]['ipv6-' + key] = if_item[key];
            						}
            					});
            				}
            				else {
            					interfaces[if_key] = if_item;
            				}
            			}
            			else {
            				interfaces[if_key] = if_item;
            			}
            		});
            		Object.keys(interfaces).forEach(function (key) {
            			result.data.push(interfaces[key]);
            		});
            	}
            	else {
            		throw 'Failed to parse response received from Cisco SD-WAN API. Check debug log for more information.';
            	}
            } catch (error) {
            	error_msg = error.toString();
            	error_msg += (error_msg.endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Cisco SD-WAN ] ERROR: ' + error_msg);
            };
            
            result.error = error_msg;
            
            return JSON.stringify(result);
          description: 'Item for gathering device interfaces from Cisco SD-WAN API.'
          timeout: '{$SDWAN.DATA.TIMEOUT}'
          parameters:
            - name: cookie
              value: '{$SDWAN.AUTH.SESSION}'
            - name: device_id
              value: '{$SDWAN.DEVICE_ID}'
            - name: http_proxy
              value: '{$SDWAN.HTTP_PROXY}'
            - name: token
              value: '{$SDWAN.AUTH.TOKEN}'
            - name: url
              value: '{$SDWAN.API.URL}'
          tags:
            - tag: component
              value: raw
        - uuid: 0a1427fdcaaf44a3a389a68c781497ef
          name: 'Device interfaces item errors'
          type: DEPENDENT
          key: sd_wan.get.interfaces.errors
          value_type: TEXT
          description: 'Item for gathering errors of the device interfaces.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: sd_wan.get.interfaces
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: 03772a571b5c417297b11a612b48cb81
              expression: 'length(last(/Cisco SD-WAN device by HTTP/sd_wan.get.interfaces.errors))>0'
              name: 'There are errors in the ''Get interfaces data'' metric'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
        - uuid: d9ae4a103ae74932a57ad495f2829b62
          name: 'Get routes data'
          type: SCRIPT
          key: sd_wan.get.routes
          delay: '{$SDWAN.ROUTES.FREQUENCY}'
          history: '0'
          value_type: TEXT
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	result = { "data": [], "error": "" },
            	error_msg = "";
            
            function getHttpData(url, data, token, cookie) {
            	request.addHeader('Cookie: ' + cookie);
            	request.addHeader('Content-Type: application/json');
            	request.addHeader('X-XSRF-TOKEN: ' + token);
            
            	if (typeof data !== 'undefined') {
            		data = JSON.stringify(data);
            	}
            
            	response = request.post(url, data);
            	Zabbix.log(4, '[ Cisco SD-WAN ] [ ' + 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 Cisco 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 {
            	['auth.token', 'auth.cookie', 'api.url', 'device_id'].forEach(function (field) {
            		var macro = '{$SDWAN.' + field.toUpperCase() + '}';
            		var key = field.split('.').slice(-1);
            		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.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);
            	}
            
            	if (!params.interval.endsWith('h')) {
            		throw 'The value of {' + '$SDWAN.ROUTES.INTERVAL} must be expressed in hours.';
            	}
            	else {
            		try {
            			params.interval = Number(params.interval.replace('h', ''));
            		}
            		catch (error) {
            			throw 'Please change {' + '$SDWAN.ROUTES.INTERVAL} macro to the proper value.';
            		}
            	}
            
            	var req_data = {
            		"query": {
            			"condition": "AND",
            			"rules": [
            				{
            					"value": [
            						String(params.interval)
            					],
            					"field": "entry_time",
            					"type": "date",
            					"operator": "last_n_hours"
            				},
            				{
            					"value": [
            						params.device_id
            					],
            					"field": "vdevice_name",
            					"type": "string",
            					"operator": "in"
            				}
            			]
            		},
            		"aggregation": {
            			"field": [
            				{
            					"property": "local_color",
            					"order": "asc",
            					"sequence": 1
            				},
            				{
            					"property": "remote_color",
            					"order": "asc",
            					"sequence": 1
            				}
            			],
            			"metrics": [
            				{
            					"property": "loss_percentage",
            					"type": "avg"
            				},
            				{
            					"property": "latency",
            					"type": "avg"
            				},
            				{
            					"property": "jitter",
            					"type": "avg"
            				}
            			]
            		}
            	};
            
            	var routes = getHttpData(
            		params.url + 'dataservice/statistics/approute/aggregation',
            		req_data,
            		params.token,
            		params.cookie
            	);
            
            	if (Array.isArray(routes.data)) {
            		result["data"] = routes.data;
            	}
            	else {
            		throw 'Failed to parse response received from Cisco SD-WAN API. Check debug log for more information.';
            	}
            } catch (error) {
            	error_msg = error.toString();
            	error_msg += (error_msg.endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Cisco SD-WAN ] ERROR: ' + error_msg);
            };
            
            result.error = error_msg;
            
            return JSON.stringify(result);
          description: 'Item for gathering device routes from Cisco SD-WAN API.'
          timeout: '{$SDWAN.DATA.TIMEOUT}'
          parameters:
            - name: cookie
              value: '{$SDWAN.AUTH.SESSION}'
            - name: device_id
              value: '{$SDWAN.DEVICE_ID}'
            - name: http_proxy
              value: '{$SDWAN.HTTP_PROXY}'
            - name: interval
              value: '{$SDWAN.ROUTES.FREQUENCY}'
            - name: token
              value: '{$SDWAN.AUTH.TOKEN}'
            - name: url
              value: '{$SDWAN.API.URL}'
          tags:
            - tag: component
              value: raw
        - uuid: e0a8bb6a05364e9ea0467dced14ac4a6
          name: 'Device routes item errors'
          type: DEPENDENT
          key: sd_wan.get.routes.errors
          value_type: TEXT
          description: 'Item for gathering errors of the device routes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: sd_wan.get.routes
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: edb75d50551643c999da9e93efd0ff1b
              expression: 'length(last(/Cisco SD-WAN device by HTTP/sd_wan.get.routes.errors))>0'
              name: 'There are errors in the ''Get routes data'' metric'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
      discovery_rules:
        - uuid: 2348adc088e343ccb51ab342c13a062e
          name: 'Mounted filesystem discovery'
          type: DEPENDENT
          key: sd_wan.fs.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#FSNAME}'
                value: '{$SDWAN.LLD.FILTER.FSNAME.MATCHES}'
              - macro: '{#FSNAME}'
                value: '{$SDWAN.LLD.FILTER.FSNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovering device filesystems from Cisco SD-WAN API.'
          item_prototypes:
            - uuid: efd5601dc80a4b93b3fae33922003cca
              name: '["{#FSNAME}"]: Available space'
              type: DEPENDENT
              key: 'sd_wan.device.fs.avail["{#FSNAME}"]'
              units: B
              description: 'The available size of the storage pool, in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.avail
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const sizes = ['K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
                      var multiplier = sizes.indexOf(value.slice(-1));
                      if (multiplier === -1) {
                      	return value;
                      }
                      return Number(value.slice(0, -1)) * 1024 * multiplier;
              master_item:
                key: 'sd_wan.device.fs.get_data["{#FSNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: filesystem
                  value: '{#FSNAME}'
            - uuid: 33664690bcde41279432e6a83ae376d1
              name: '["{#FSNAME}"]: Get data'
              type: DEPENDENT
              key: 'sd_wan.device.fs.get_data["{#FSNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Item for gathering data for the {#FSNAME} filesystem.'
              preprocessing:
                - type: JAVASCRIPT
                  parameters:
                    - |
                      var input = JSON.parse(value),
                      	output = {};
                      
                      Object.keys(input).sort().forEach(function (key) {
                      	var re = new RegExp("^{#FSKEY}[-_]");
                      	if (key.match(re)) {
                      		output[key.replace(re, '')] = input[key];
                      	}
                      });
                      
                      return JSON.stringify(output);
              master_item:
                key: sd_wan.get.device
              tags:
                - tag: component
                  value: raw
                - tag: filesystem
                  value: '{#FSNAME}'
            - uuid: 1ce9413041f84ac9b7e44d05a62566d1
              name: '["{#FSNAME}"]: Space utilization'
              type: DEPENDENT
              key: 'sd_wan.device.fs.pused["{#FSNAME}"]'
              value_type: FLOAT
              units: '%'
              description: 'Space utilization, expressed in %.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.use
              master_item:
                key: 'sd_wan.device.fs.get_data["{#FSNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: filesystem
                  value: '{#FSNAME}'
              trigger_prototypes:
                - uuid: 22a27b82289c4904ba64cd6c8c33450d
                  expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.fs.pused["{#FSNAME}"])>{$SDWAN.FS.PUSED.MAX.CRIT:"{#FSNAME}"}'
                  name: '["{#FSNAME}"]: Disk space is critically low'
                  event_name: '["{#FSNAME}"]: Disk space is critically low (used > {$SDWAN.FS.PUSED.MAX.CRIT:"{#FSNAME}"}%)'
                  opdata: 'Space used: {ITEM.LASTVALUE1}'
                  priority: AVERAGE
                  description: 'Utilization of the space is above {$VFS.FS.PUSED.MAX.CRIT:"{{FSNAME}}"}'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
                    - tag: scope
                      value: capacity
                - uuid: ff996c4f86ae4162b4b054e5c5e9b3ee
                  expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.fs.pused["{#FSNAME}"])>{$SDWAN.FS.PUSED.MAX.WARN:"{#FSNAME}"}'
                  name: '["{#FSNAME}"]: Disk space is low'
                  event_name: '["{#FSNAME}"]: Disk space is low (used > {$SDWAN.FS.PUSED.MAX.WARN:"{#FSNAME}"}%)'
                  opdata: 'Space used: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'Utilization of the space is above {$VFS.FS.PUSED.MAX.CRIT:"{{FSNAME}}"}'
                  manual_close: 'YES'
                  dependencies:
                    - name: '["{#FSNAME}"]: Disk space is critically low'
                      expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.fs.pused["{#FSNAME}"])>{$SDWAN.FS.PUSED.MAX.CRIT:"{#FSNAME}"}'
                  tags:
                    - tag: scope
                      value: availability
                    - tag: scope
                      value: capacity
            - uuid: ae724b1dd35f46e6bb492daf4729544a
              name: '["{#FSNAME}"]: Total space'
              type: DEPENDENT
              key: 'sd_wan.device.fs.total["{#FSNAME}"]'
              units: B
              description: 'The size of the storage pool, in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.size
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const sizes = ['K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
                      var multiplier = sizes.indexOf(value.slice(-1));
                      if (multiplier === -1) {
                      	return value;
                      }
                      return Number(value.slice(0, -1)) * 1024 * multiplier;
              master_item:
                key: 'sd_wan.device.fs.get_data["{#FSNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: filesystem
                  value: '{#FSNAME}'
            - uuid: eeeef8b9090f4c28950ed9735cc97016
              name: '["{#FSNAME}"]: Used space'
              type: DEPENDENT
              key: 'sd_wan.device.fs.used["{#FSNAME}"]'
              units: B
              description: 'The used size of the dataset, in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.used
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const sizes = ['K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
                      var multiplier = sizes.indexOf(value.slice(-1));
                      if (multiplier === -1) {
                      	return value;
                      }
                      return Number(value.slice(0, -1)) * 1024 * multiplier;
              master_item:
                key: 'sd_wan.device.fs.get_data["{#FSNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: filesystem
                  value: '{#FSNAME}'
          graph_prototypes:
            - uuid: aa107bd964b34bd69610aee0918e49f7
              name: '["{#FSNAME}"]: Disk space usage'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.fs.total["{#FSNAME}"]'
                - sortorder: '1'
                  drawtype: BOLD_LINE
                  color: F63100
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.fs.used["{#FSNAME}"]'
          master_item:
            key: sd_wan.get.device
          lld_macro_paths:
            - lld_macro: '{#FSKEY}'
              path: $.key
            - lld_macro: '{#FSNAME}'
              path: $.mount
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var input = JSON.parse(value),
                  	output = [];
                  
                  Object.keys(input).sort().forEach(function (key) {
                  	if (key.match(/(disk[-_]mount)/g)) {
                  		output.push(
                  			{
                  				'mount': input[key],
                  				'key': key.replace(/[-_]mount/, '')
                  			}
                  		);
                  	}
                  });
                  
                  return JSON.stringify(output);
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: 6be4e405fd7c48d5beca62ca7eadbdf3
          name: 'Network interfaces discovery'
          type: DEPENDENT
          key: sd_wan.interfaces.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#IFNAME}'
                value: '{$SDWAN.LLD.FILTER.IFNAME.MATCHES}'
              - macro: '{#IFNAME}'
                value: '{$SDWAN.LLD.FILTER.IFNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovering device interfaces from Cisco SD-WAN API.'
          item_prototypes:
            - uuid: 032884d082d54cd2bca2a0cf747e91ee
              name: 'Interface ["{#IFNAME}"]: Admin status'
              type: DEPENDENT
              key: 'sd_wan.device.if.adm.status["{#IFKEY}"]'
              description: 'Current admin status of the interface.'
              valuemap:
                name: 'Admin status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["if-admin-status"]'
                - type: JAVASCRIPT
                  parameters:
                    - |
                      var idx = [
                      	'if-state-up',
                      	'if-state-down'
                      ].indexOf(value);
                      var idx = idx !== -1 ? idx : [
                      	'Up',
                      	'Down',
                      ].indexOf(value);
                      return idx !== -1 ? idx : 10;
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: b5ffafcd8d5c4072bf01311d95bbd2db
              name: 'Interface ["{#IFNAME}"]: Get data'
              type: DEPENDENT
              key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              history: '0'
              value_type: TEXT
              description: 'Item for gathering data for the {#IFNAME} interface.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.data[?(@["vdevice-dataKey"] == "{#IFKEY}")].first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: sd_wan.get.interfaces
              tags:
                - tag: component
                  value: raw
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 52a6b09a0a9a4849b4b8c6d209227641
              name: 'Interface ["{#IFNAME}"]: Inbound packets discarded'
              type: DEPENDENT
              key: 'sd_wan.device.if.in.discards["{#IFKEY}"]'
              description: 'The number of inbound packets that were chosen to be discarded.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["rx-drops"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 3f65667d53bd449994fb89ab3f2e0f16
              name: 'Interface ["{#IFNAME}"]: Inbound packets with errors'
              type: DEPENDENT
              key: 'sd_wan.device.if.in.errors["{#IFKEY}"]'
              description: 'The number of inbound packets that were contain errors.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["rx-errors"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 800e9d7703664824a38c6b8c02278d76
              name: 'Interface ["{#IFNAME}"]: Inbound IPv6 packets discarded'
              type: DEPENDENT
              key: 'sd_wan.device.if.in.v6.discards["{#IFKEY}"]'
              value_type: FLOAT
              description: 'The number of inbound IPv6 packets that were chosen to be discarded.'
              valuemap:
                name: 'Not used'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["ipv6-rx-drops"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '-1'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: ad932748cce547bc8bbf2b54362cf5a0
              name: 'Interface ["{#IFNAME}"]: Inbound IPv6 packets with errors'
              type: DEPENDENT
              key: 'sd_wan.device.if.in.v6.errors["{#IFKEY}"]'
              value_type: FLOAT
              description: 'The number of inbound IPv4 packets that were contain errors.'
              valuemap:
                name: 'Not used'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["ipv6-rx-errors"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '-1'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: e4f94e0c8abe49d9b546acdbd01de6cb
              name: 'Interface ["{#IFNAME}"]: Bits received'
              type: DEPENDENT
              key: 'sd_wan.device.if.in["{#IFKEY}"]'
              units: bps
              description: 'The total number of octets received on the interface.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["rx-octets"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
                - type: MULTIPLIER
                  parameters:
                    - '8'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 813e0877c1ee43d3add120c22e1a30a7
              name: 'Interface ["{#IFNAME}"]: Outbound packets discarded'
              type: DEPENDENT
              key: 'sd_wan.device.if.out.discards["{#IFKEY}"]'
              description: 'The number of outbound packets that were chosen to be discarded.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["tx-drops"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: b353a80145074a17a154db7073734dd4
              name: 'Interface ["{#IFNAME}"]: Outbound packets with errors'
              type: DEPENDENT
              key: 'sd_wan.device.if.out.errors["{#IFKEY}"]'
              description: 'The number of outbound packets that were contain errors.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["tx-errors"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: d4beeb5a5b674652aaeff89ccd47548d
              name: 'Interface ["{#IFNAME}"]: Outbound IPv6 packets discarded'
              type: DEPENDENT
              key: 'sd_wan.device.if.out.v6.discards["{#IFKEY}"]'
              value_type: FLOAT
              description: 'The number of outbound IPv6 packets that were chosen to be discarded.'
              valuemap:
                name: 'Not used'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["ipv6-tx-drops"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '-1'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 61b554e479b545069d3e8bdca629e00d
              name: 'Interface ["{#IFNAME}"]: Outbound IPv6 packets with errors'
              type: DEPENDENT
              key: 'sd_wan.device.if.out.v6.errors["{#IFKEY}"]'
              value_type: FLOAT
              description: 'The number of outbound IPv6 packets that were contain errors.'
              valuemap:
                name: 'Not used'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["ipv6-tx-errors"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '-1'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 9b5d5fc0fea341f9beacf41ec9aff590
              name: 'Interface ["{#IFNAME}"]: Bits sent'
              type: DEPENDENT
              key: 'sd_wan.device.if.out["{#IFKEY}"]'
              units: bps
              description: 'The total number of octets transmitted out of the interface.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["tx-octets"]'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
                - type: MULTIPLIER
                  parameters:
                    - '8'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: ab89a67a34c74ae3acc1b4fb4c711b2f
              name: 'Interface ["{#IFNAME}"]: Speed'
              type: DEPENDENT
              key: 'sd_wan.device.if.speed["{#IFKEY}"]'
              units: bps
              description: 'Current bandwidth of the interface.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["speed-mbps"]'
                - type: MULTIPLIER
                  parameters:
                    - '1000000'
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: d1cda0afbdfa4342abcbe4a5f15a5950
              name: 'Interface ["{#IFNAME}"]: Operational status'
              type: DEPENDENT
              key: 'sd_wan.device.if.status["{#IFKEY}"]'
              description: 'Current operational status of the interface.'
              valuemap:
                name: 'Operational status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$["if-oper-status"]'
                - type: JAVASCRIPT
                  parameters:
                    - |
                      var idx = [
                      	'if-oper-state-ready',
                      	'if-oper-state-lower-layer-down',
                      	'if-oper-state-no-pass'
                      ].indexOf(value);
                      var idx = idx !== -1 ? idx : [
                      	'Up',
                      	'Down',
                      ].indexOf(value);
                      return idx !== -1 ? idx : 10;
              master_item:
                key: 'sd_wan.device.if.get_data["{#IFKEY}"]'
              tags:
                - tag: component
                  value: interface
                - tag: interface
                  value: '{#IFNAME}'
              trigger_prototypes:
                - uuid: cfd9e53fc4ff459ba9aa121b7feb5e7d
                  expression: '{$IFCONTROL:"{#IFNAME}"}=1 and last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])=1 and (last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"],#1)<>last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"],#2))'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])<>1 or {$IFCONTROL:"{#IFNAME}"}=0'
                  name: 'Interface ["{#IFNAME}"]: Link down'
                  opdata: 'Current state: {ITEM.LASTVALUE1}'
                  priority: AVERAGE
                  description: |
                    This trigger expression works as follows:
                    1. It can be triggered if the operational status is down.
                    2. `{$IFCONTROL:"{#IFNAME}"}=1` - a user can redefine context macro to value - 0. That marks this interface as not important. No new trigger will be fired if this interface is down.
                    3. `{TEMPLATE_NAME:METRIC.diff()}=1` - the trigger fires only if the operational status was up to (1) sometime before (so, it does not fire for the 'eternal off' interfaces).
                    
                    WARNING: If closed manually, it will not fire again on the next poll because of .diff.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
          trigger_prototypes:
            - uuid: 0c34bf81f8f64cb7b5eecd2f2c76e1b1
              expression: |
                change(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"])<0 and last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"])>0
                and
                last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])<>0
              recovery_mode: RECOVERY_EXPRESSION
              recovery_expression: |
                (change(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"])>0 and last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"],#2)>0) or
                last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])=0
              name: 'Interface ["{#IFNAME}"]: Ethernet has changed to lower speed than it was before'
              opdata: 'Current reported speed: {ITEM.LASTVALUE1}'
              priority: INFO
              description: 'This Ethernet connection has transitioned down from its known maximum speed. This might be a sign of autonegotiation issues. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              dependencies:
                - name: 'Interface ["{#IFNAME}"]: Link down'
                  expression: '{$IFCONTROL:"{#IFNAME}"}=1 and last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])=1 and (last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"],#1)<>last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"],#2))'
                  recovery_expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])<>1 or {$IFCONTROL:"{#IFNAME}"}=0'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 2ba01de4c85346f4af88d6882ea700e2
              expression: |
                (avg(/Cisco SD-WAN device by HTTP/sd_wan.device.if.in["{#IFKEY}"],15m)>({$SDWAN.IF.UTIL.MAX:"{#IFNAME}"}/100)*last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"]) or
                avg(/Cisco SD-WAN device by HTTP/sd_wan.device.if.out["{#IFKEY}"],15m)>({$SDWAN.IF.UTIL.MAX:"{#IFNAME}"}/100)*last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"])) and
                last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"])>0
              recovery_mode: RECOVERY_EXPRESSION
              recovery_expression: |
                avg(/Cisco SD-WAN device by HTTP/sd_wan.device.if.in["{#IFKEY}"],15m)<(({$SDWAN.IF.UTIL.MAX:"{#IFNAME}"}-3)/100)*last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"]) and
                avg(/Cisco SD-WAN device by HTTP/sd_wan.device.if.out["{#IFKEY}"],15m)<(({$SDWAN.IF.UTIL.MAX:"{#IFNAME}"}-3)/100)*last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.speed["{#IFKEY}"])
              name: 'Interface ["{#IFNAME}"]: High bandwidth usage'
              event_name: 'Interface ["{#IFNAME}"]: High bandwidth usage (>{$SDWAN.IF.UTIL.MAX:"{#IFNAME}"}%)'
              opdata: 'In: {ITEM.LASTVALUE1}, out: {ITEM.LASTVALUE3}, speed: {ITEM.LASTVALUE2}'
              priority: WARNING
              description: 'The network interface utilization is close to its estimated maximum bandwidth.'
              manual_close: 'YES'
              dependencies:
                - name: 'Interface ["{#IFNAME}"]: Link down'
                  expression: '{$IFCONTROL:"{#IFNAME}"}=1 and last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])=1 and (last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"],#1)<>last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"],#2))'
                  recovery_expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])<>1 or {$IFCONTROL:"{#IFNAME}"}=0'
              tags:
                - tag: scope
                  value: performance
            - uuid: 44d899ec07a549229eedaba42e76c76d
              expression: |
                min(/Cisco SD-WAN device by HTTP/sd_wan.device.if.in.errors["{#IFKEY}"],5m)>{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"} 
                or min(/Cisco SD-WAN device by HTTP/sd_wan.device.if.out.errors["{#IFKEY}"],5m)>{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"} 
                or min(/Cisco SD-WAN device by HTTP/sd_wan.device.if.in.v6.errors["{#IFKEY}"],5m)>{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"} 
                or min(/Cisco SD-WAN device by HTTP/sd_wan.device.if.out.v6.errors["{#IFKEY}"],5m)>{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"}
              recovery_mode: RECOVERY_EXPRESSION
              recovery_expression: |
                max(/Cisco SD-WAN device by HTTP/sd_wan.device.if.in.errors["{#IFKEY}"],5m)<{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"}*0.8 
                and max(/Cisco SD-WAN device by HTTP/sd_wan.device.if.out.errors["{#IFKEY}"],5m)<{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"}*0.8 
                and max(/Cisco SD-WAN device by HTTP/sd_wan.device.if.in.v6.errors["{#IFKEY}"],5m)<{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"}*0.8 
                and max(/Cisco SD-WAN device by HTTP/sd_wan.device.if.out.v6.errors["{#IFKEY}"],5m)<{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"}*0.8
              name: 'Interface ["{#IFNAME}"]: High error rate'
              event_name: 'Interface ["{#IFNAME}"]: High error rate (>{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"} for 5m)'
              opdata: 'errors in: {ITEM.LASTVALUE1}, errors out: {ITEM.LASTVALUE2}'
              priority: WARNING
              description: 'It recovers when it is below 80% of the `{$SDWAN.IF.ERRORS.WARN:"{#IFNAME}"}` threshold.'
              manual_close: 'YES'
              dependencies:
                - name: 'Interface ["{#IFNAME}"]: Link down'
                  expression: '{$IFCONTROL:"{#IFNAME}"}=1 and last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])=1 and (last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"],#1)<>last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"],#2))'
                  recovery_expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.if.status["{#IFKEY}"])<>1 or {$IFCONTROL:"{#IFNAME}"}=0'
              tags:
                - tag: scope
                  value: performance
          graph_prototypes:
            - uuid: 58a8bbf3bcef4d5b944b5d46f3248e86
              name: 'Interface ["{#IFNAME}"]: Network traffic'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.in["{#IFKEY}"]'
                - sortorder: '1'
                  drawtype: BOLD_LINE
                  color: F63100
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.out["{#IFKEY}"]'
                - sortorder: '2'
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.in.discards["{#IFKEY}"]'
                - sortorder: '3'
                  color: F7941D
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.out.discards["{#IFKEY}"]'
                - sortorder: '4'
                  color: FC6EA3
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.in.v6.discards["{#IFKEY}"]'
                - sortorder: '5'
                  color: 6C59DC
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.out.v6.discards["{#IFKEY}"]'
                - sortorder: '6'
                  color: C7A72D
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.in.errors["{#IFKEY}"]'
                - sortorder: '7'
                  color: BA2A5D
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.out.errors["{#IFKEY}"]'
                - sortorder: '8'
                  color: F230E0
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.in.v6.errors["{#IFKEY}"]'
                - sortorder: '9'
                  color: 5CCD18
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.device.if.out.v6.errors["{#IFKEY}"]'
          master_item:
            key: sd_wan.get.interfaces
          lld_macro_paths:
            - lld_macro: '{#IFDESC}'
              path: $.description
            - lld_macro: '{#IFINDEX}'
              path: $.ifindex
            - lld_macro: '{#IFKEY}'
              path: $.key
            - lld_macro: '{#IFNAME}'
              path: $.name
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var input = JSON.parse(value),
                  	output = [];
                  
                  input.data.forEach(function (if_item) {
                  	var desc = (typeof if_item['desc'] !== 'undefined')
                  		? if_item['desc']
                  		: ((typeof if_item['description'] !== 'undefined') ? if_item['description'] : '');
                  	output.push(
                  		{
                  			'key': if_item['vdevice-dataKey'],
                  			'ifindex': if_item['ifindex'],
                  			'name': if_item['ifname'],
                  			'description': (desc != 'None') ? desc : ''
                  		}
                  	);
                  });
                  
                  return JSON.stringify(output);
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: 5242a999e54a430da6d4eedcc5840fb1
          name: 'Route discovery'
          type: DEPENDENT
          key: sd_wan.routes.discovery
          description: 'Discovering Application-Aware routes from Cisco SD-WAN API.'
          item_prototypes:
            - uuid: 81cfb6100aad4404a66a2e1858f511b7
              name: 'Route [{#LOCAL} => {#REMOTE}]: Get data'
              type: DEPENDENT
              key: 'sd_wan.routes.get_data[{#LOCAL},{#REMOTE}]'
              history: '0'
              value_type: TEXT
              description: 'Item for gathering data for the route {#LOCAL} => {#REMOTE}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.data[?(@.local_color == "{#LOCAL}" && @.remote_color == "{#REMOTE}")].first()'
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: sd_wan.get.routes
              tags:
                - tag: component
                  value: raw
                - tag: local
                  value: '{#LOCAL}'
                - tag: remote
                  value: '{#REMOTE}'
            - uuid: f4ba8d21398c4bd4b5896ee647f5886e
              name: 'Route [{#LOCAL} => {#REMOTE}]: Jitter'
              type: DEPENDENT
              key: 'sd_wan.routes.jitter[{#LOCAL},{#REMOTE}]'
              value_type: FLOAT
              units: ms
              description: 'A change in the time it takes for a data packet to travel through the route.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.jitter
              master_item:
                key: 'sd_wan.routes.get_data[{#LOCAL},{#REMOTE}]'
              tags:
                - tag: component
                  value: route
                - tag: local
                  value: '{#LOCAL}'
                - tag: remote
                  value: '{#REMOTE}'
            - uuid: f06e822d76794b4f8a30978fcb406ff8
              name: 'Route [{#LOCAL} => {#REMOTE}]: Latency'
              type: DEPENDENT
              key: 'sd_wan.routes.latency[{#LOCAL},{#REMOTE}]'
              value_type: FLOAT
              units: ms
              description: 'The amount of time it takes for a data packet to travel through the route.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.latency
              master_item:
                key: 'sd_wan.routes.get_data[{#LOCAL},{#REMOTE}]'
              tags:
                - tag: component
                  value: route
                - tag: local
                  value: '{#LOCAL}'
                - tag: remote
                  value: '{#REMOTE}'
            - uuid: 9310f97111c0413f8d980cbf280863c2
              name: 'Route [{#LOCAL} => {#REMOTE}]: Loss'
              type: DEPENDENT
              key: 'sd_wan.routes.loss[{#LOCAL},{#REMOTE}]'
              value_type: FLOAT
              units: '%'
              description: 'Lost packets of data not reached the destination after being transmitted through the route.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.loss_percentage
              master_item:
                key: 'sd_wan.routes.get_data[{#LOCAL},{#REMOTE}]'
              tags:
                - tag: component
                  value: route
                - tag: local
                  value: '{#LOCAL}'
                - tag: remote
                  value: '{#REMOTE}'
          graph_prototypes:
            - uuid: da406cac8d844a2182b9ae0b9ed5451a
              name: 'Route [{#LOCAL} => {#REMOTE}]: Route statistic'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.routes.latency[{#LOCAL},{#REMOTE}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.routes.jitter[{#LOCAL},{#REMOTE}]'
                - sortorder: '2'
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'Cisco SD-WAN device by HTTP'
                    key: 'sd_wan.routes.loss[{#LOCAL},{#REMOTE}]'
          master_item:
            key: sd_wan.get.routes
          lld_macro_paths:
            - lld_macro: '{#LOCAL}'
              path: $.local_color
            - lld_macro: '{#REMOTE}'
              path: $.remote_color
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data
              error_handler: CUSTOM_VALUE
              error_handler_params: '[]'
      tags:
        - tag: class
          value: network
        - tag: target
          value: cisco-sdwan-device
      macros:
        - macro: '{$IFCONTROL}'
          value: '1'
          description: 'Macro for operational state of the interface for the link down trigger. Can be used with the interface name as context.'
        - macro: '{$SDWAN.API.URL}'
          description: 'Cisco SD-WAN Monitor API URL.'
        - macro: '{$SDWAN.CPU.UTIL.CRIT}'
          value: '90'
          description: 'Critical threshold of the CPU utilization, expressed in %.'
        - macro: '{$SDWAN.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for an API.'
        - macro: '{$SDWAN.FS.PUSED.MAX.CRIT}'
          value: '90'
          description: 'Critical threshold of the filesystem utilization. Can be used with the filesystem name as context.'
        - macro: '{$SDWAN.FS.PUSED.MAX.WARN}'
          value: '80'
          description: 'Warning threshold of the filesystem utilization. Can be used with the filesystem name as context.'
        - 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'
        - macro: '{$SDWAN.IF.ERRORS.WARN}'
          value: '2'
          description: 'Threshold of the error packets rate for the warning trigger. Can be used with the interface name as context.'
        - macro: '{$SDWAN.IF.UTIL.MAX}'
          value: '90'
          description: 'This macro is used as a threshold in the interface utilization trigger. Can be used with the interface name as context.'
        - macro: '{$SDWAN.LA.PER.CPU.MAX.WARN}'
          value: '1.5'
          description: 'Load per CPU considered sustainable. Tune if needed.'
        - macro: '{$SDWAN.LLD.FILTER.FSNAME.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable filesystems by name.'
        - macro: '{$SDWAN.LLD.FILTER.FSNAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discoverable filesystems by name.'
        - macro: '{$SDWAN.LLD.FILTER.IFNAME.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable interfaces by name.'
        - macro: '{$SDWAN.LLD.FILTER.IFNAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discoverable interfaces by name.'
        - macro: '{$SDWAN.MEMORY.AVAILABLE.MIN}'
          value: 100K
          description: 'This macro is used as a threshold in the memory available trigger.'
        - macro: '{$SDWAN.MEMORY.UTIL.MAX}'
          value: '90'
          description: 'Critical threshold of the memory utilization, expressed in %.'
        - macro: '{$SDWAN.ROUTES.FREQUENCY}'
          value: 1h
          description: 'Update interval for the Routes item, expressed in hours.'
        - macro: '{$SDWAN.TOKEN}'
          type: SECRET_TEXT
          description: 'Cisco SD-WAN Monitor API token.'
      dashboards:
        - uuid: 45ab5f4b9e9d445b9e774bbfa5cadafb
          name: 'SD-WAN: General'
          pages:
            - name: Overview
              widgets:
                - type: item
                  name: State
                  width: '24'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.state
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: Name
                  'y': '3'
                  width: '24'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.hostname
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'Control connections'
                  'y': '6'
                  width: '18'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.control_conn
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: Reachability
                  x: '18'
                  'y': '6'
                  width: '18'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.reachability
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: Model
                  x: '24'
                  width: '24'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.model
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: Uptime
                  x: '24'
                  'y': '3'
                  width: '24'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.uptime
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: Certificate
                  x: '36'
                  'y': '6'
                  width: '18'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.certificate_validity
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'Serial Number'
                  x: '48'
                  width: '24'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.serialnumber
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: Version
                  x: '48'
                  'y': '3'
                  width: '24'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.version
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: Role
                  x: '54'
                  'y': '6'
                  width: '18'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        key: sd_wan.device.role
                    - type: INTEGER
                      name: show.0
                      value: '2'
            - name: 'System performance'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        name: 'SD-WAN: System load'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        name: 'SD-WAN: Memory usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graphprototype
                  'y': '10'
                  width: '72'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        name: '["{#FSNAME}"]: Disk space usage'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        name: 'SD-WAN: CPU usage'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        name: 'SD-WAN: Processes'
                    - type: STRING
                      name: reference
                      value: AAAAD
            - name: 'Network interfaces'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '7'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        name: 'Interface ["{#IFNAME}"]: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAF
            - name: Routes
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '8'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Cisco SD-WAN device by HTTP'
                        name: 'Route [{#LOCAL} => {#REMOTE}]: Route statistic'
                    - type: STRING
                      name: reference
                      value: AAAAG
                    - type: INTEGER
                      name: rows
                      value: '2'
      valuemaps:
        - uuid: ac1ad6688715425b8d6d0ac3c7e72b14
          name: 'Admin status'
          mappings:
            - value: '0'
              newvalue: up
            - value: '1'
              newvalue: down
            - value: '10'
              newvalue: unknown
        - uuid: 7de6a0190832425a9b05d9740a6495c6
          name: 'Device state'
          mappings:
            - value: '0'
              newvalue: green
            - value: '1'
              newvalue: yellow
            - value: '2'
              newvalue: red
            - value: '10'
              newvalue: unknown
        - uuid: a8fdd703646d4f3bb5c3ac7b39fd65da
          name: 'Not used'
          mappings:
            - value: '-1'
              newvalue: 'not used'
        - uuid: a563ee950d954a3086170c5de9cabf71
          name: 'Operational status'
          mappings:
            - value: '0'
              newvalue: up
            - value: '1'
              newvalue: down
            - value: '2'
              newvalue: 'no pass'
            - value: '10'
              newvalue: unknown
        - uuid: 93bca94da129493ebfd4e7a9f833bdf8
          name: 'Reachability status'
          mappings:
            - value: '0'
              newvalue: reachable
            - value: '1'
              newvalue: unreachable
            - value: '2'
              newvalue: auth-failed
            - value: '3'
              newvalue: staging
            - value: '10'
              newvalue: unknown
        - uuid: fe4450cc25624972b754d834f369e7fc
          name: Unknown
          mappings:
            - value: '-1'
              newvalue: unknown
        - uuid: 7ab3966394504fb6a55c3247f4754729
          name: 'Validity status'
          mappings:
            - value: '0'
              newvalue: valid
            - value: '1'
              newvalue: invalid
            - value: '10'
              newvalue: unknown
  triggers:
    - uuid: fe3886ed10b94fd6b7cd99cba20809a4
      expression: 'last(/Cisco SD-WAN device by HTTP/sd_wan.device.state)<>0 and length(last(/Cisco SD-WAN device by HTTP/sd_wan.device.state_descr))>0'
      name: 'Device state is not green'
      opdata: 'Current state: {ITEM.LASTVALUE1}, Reason: {ITEM.LASTVALUE2}'
      priority: AVERAGE
      description: 'The device current state is not green.'
      tags:
        - tag: scope
          value: availability
    - uuid: 9e558d5397e34468bd845f3e3f0442ec
      expression: 'max(/Cisco SD-WAN device by HTTP/sd_wan.device.memory.avail,5m)<{$SDWAN.MEMORY.AVAILABLE.MIN} and last(/Cisco SD-WAN device by HTTP/sd_wan.device.memory.total)>0'
      name: 'Lack of available memory'
      event_name: 'Lack of available memory (<{$SDWAN.MEMORY.AVAILABLE.MIN} of {ITEM.VALUE2})'
      opdata: 'Available: {ITEM.LASTVALUE1}, total: {ITEM.LASTVALUE2}'
      priority: AVERAGE
      tags:
        - tag: scope
          value: capacity
        - tag: scope
          value: performance
    - uuid: f37b627ac23c411d935d08c1f6dafde9
      expression: |
        min(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.load[avg1],5m)/last(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.num)>{$SDWAN.LA.PER.CPU.MAX.WARN}
        and last(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.load[avg5])>0
        and last(/Cisco SD-WAN device by HTTP/sd_wan.device.cpu.load[avg15])>0
      name: 'Load average is too high'
      event_name: 'Load average is too high (per CPU load over {$SDWAN.LA.PER.CPU.MAX.WARN} for 5m)'
      opdata: 'Load averages(1m 5m 15m): ({ITEM.LASTVALUE1} {ITEM.LASTVALUE3} {ITEM.LASTVALUE4}), # of CPUs: {ITEM.LASTVALUE2}'
      priority: AVERAGE
      description: 'The load average per CPU is too high. The system might be slow to respond.'
      tags:
        - tag: scope
          value: performance
  graphs:
    - uuid: 8c9d1474c4384aacb045da2c7414e63b
      name: 'SD-WAN: CPU usage'
      type: STACKED
      ymin_type_1: FIXED
      ymax_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: 'sd_wan.device.cpu.util[idle]'
        - sortorder: '1'
          color: F63100
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: 'sd_wan.device.cpu.util[system]'
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: 'sd_wan.device.cpu.util[user]'
    - uuid: 9a99dcc198154d5189012fcbb2550c53
      name: 'SD-WAN: CPU utilization'
      ymin_type_1: FIXED
      ymax_type_1: FIXED
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: sd_wan.device.cpu.util
    - uuid: b35de32ff8244417b59614f0e5a47b29
      name: 'SD-WAN: Memory usage'
      ymin_type_1: FIXED
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: sd_wan.device.memory.total
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: sd_wan.device.memory.avail
    - uuid: a7a3543654d24a3eb922c81edbc45a46
      name: 'SD-WAN: Memory utilization'
      ymin_type_1: FIXED
      ymax_type_1: FIXED
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: sd_wan.device.memory.util
    - uuid: 164b95f665dc4cec8eabebdcd5417ae9
      name: 'SD-WAN: Processes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: sd_wan.device.proc.num
    - uuid: 29d55fad7a034b00a8a67bba8ad794a7
      name: 'SD-WAN: System load'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: 'sd_wan.device.cpu.load[avg1]'
        - sortorder: '1'
          color: F63100
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: 'sd_wan.device.cpu.load[avg5]'
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: 'sd_wan.device.cpu.load[avg15]'
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'Cisco SD-WAN device by HTTP'
            key: sd_wan.device.cpu.num
