zabbix_export: version: '5.4' date: '2021-11-21T21:48:35Z' groups: - uuid: 7df96b18c230490a9a0a9e2307226338 name: Templates templates: - uuid: 602ae95c6106465088ae1e8087a93005 template: 'Mikrotik - OSPF LLD' name: 'Mikrotik - OSPF LLD' description: | ## Overview The Zabbix Mikrotik OSPF template for 4.0, which uses LLD, JSON, SSH for connection to Mikrotik router wihout externel scripts. Discovers OSPF neighbors and monitors STATE and changes. Uses one ssh connection to the Mikrotik for getting data. This template needs changing macroses: {$MIKROTIK\_SSH\_PASS} {$MIKROTIK\_SSH\_PORT} {$MIKROTIK\_SSH\_USER} ## Author AlKosmos groups: - name: Templates items: - uuid: 1f4fffaefcd5429db87012a9e96f19bf name: 'OSPF - Neighbor JSON' type: SSH key: 'ssh.run[OSPF - Neighbor JSON,,{$MIKROTIK_SSH_PORT},]' delay: '{$UPDATEINT}' history: 1d trends: '0' value_type: TEXT params: ':global list [/routing ospf neighbor find]; :global count 0; :global total [:len $list]; :put "{"; :foreach i in=$list do={ :local router [/routing ospf neighbor get value-name=router-id number=$i]; :local address [/routing ospf neighbor get value-name=address number=$i]; :local statechanges [/routing ospf neighbor get value-name=state-changes number=$i]; :local interface [/routing ospf neighbor get value-name=interface number=$i]; :local state [/routing ospf neighbor get value-name=state number=$i]; :if ( $count < $total-1) do={; :put "\"$count\":{\"ID\":\"$i\",\"STATECHANGES\":\"$statechanges\",\"ROUTERID\":\"$router\",\"ADDRESS\":\"$address\",\"INTERFACE\":\"$interface\",\"STATEOSPF\":\"$state\"},";} else={; :put "\"$count\":{\"ID\":\"$i\",\"STATECHANGES\":\"$statechanges\",\"ROUTERID\":\"$router\",\"ADDRESS\":\"$address\",\"INTERFACE\":\"$interface\",\"STATEOSPF\":\"$state\"}";}; :set count ($count + 1); }; :put "}";' username: '{$MIKROTIK_SSH_USER}' password: '{$MIKROTIK_SSH_PASS}' tags: - tag: Application value: 'OSPF JSONs' discovery_rules: - uuid: 5173fb3e568146f79c987497d64b660b name: 'OSPF - Neighbor' type: SSH key: 'ssh.run[OSPF - Neighbor,,{$MIKROTIK_SSH_PORT},]' delay: 1h params: ':global list [/routing ospf neighbor find]; :global count 0; :global total [:len $list]; :put "{\"data\":["; :foreach i in=$list do={ :local router [/routing ospf neighbor get value-name=router-id number=$i]; :local address [/routing ospf neighbor get value-name=address number=$i]; :local statechanges [/routing ospf neighbor get value-name=state-changes number=$i]; :local interface [/routing ospf neighbor get value-name=interface number=$i]; :local state [/routing ospf neighbor get value-name=state number=$i]; :if ( $count < $total-1) do={; :put "{\"{#NUMBER}\":\"$count\",\"{#ID}\":\"$i\",\"{#STATECHANGES}\":\"$statechanges\",\"{#ROUTERID}\":\"$router\",\"{#ADDRESS}\":\"$address\",\"{#INTERFACE}\":\"$interface\",\"{#STATE}\":\"$state\"},";} else={; :put "{\"{#NUMBER}\":\"$count\",\"{#ID}\":\"$i\",\"{#STATECHANGES}\":\"$statechanges\",\"{#ROUTERID}\":\"$router\",\"{#ADDRESS}\":\"$address\",\"{#INTERFACE}\":\"$interface\",\"{#STATE}\":\"$state\"}";}; :set count ($count + 1); }; :put "]}";' username: '{$MIKROTIK_SSH_USER}' password: '{$MIKROTIK_SSH_PASS}' item_prototypes: - uuid: b882ccf9c5794e489e59b962e4e6615e name: '{#NUMBER}-{#ROUTERID}-{#ADDRESS}-{#INTERFACE}-state' type: DEPENDENT key: 'state.[{#NUMBER},{#ROUTERID},{#ADDRESS},{#INTERFACE}]' delay: '0' history: '{$HISTORY}' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - '$.{#NUMBER}.STATEOSPF' master_item: key: 'ssh.run[OSPF - Neighbor JSON,,{$MIKROTIK_SSH_PORT},]' tags: - tag: Application value: OSPF trigger_prototypes: - uuid: 95a5d6b094444f68bae42518440756e8 expression: 'find(/Mikrotik - OSPF LLD/state.[{#NUMBER},{#ROUTERID},{#ADDRESS},{#INTERFACE}],,"like","Full")=0' name: 'OSPF Neighbor ({#NUMBER}-{#ROUTERID}-{#ADDRESS}-{#INTERFACE}) is not FULL' priority: DISASTER - uuid: bf3c580e1f424d399d64e1e197d8c9f2 name: '{#NUMBER}-{#ROUTERID}-{#ADDRESS}-{#INTERFACE}-statechange' type: DEPENDENT key: 'statechange.[{#NUMBER},{#ROUTERID},{#ADDRESS},{#INTERFACE}]' delay: '0' history: '{$HISTORY}' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - '$.{#NUMBER}.STATECHANGES' master_item: key: 'ssh.run[OSPF - Neighbor JSON,,{$MIKROTIK_SSH_PORT},]' tags: - tag: Application value: OSPF trigger_prototypes: - uuid: 67dec4c9ed3e4934a5bb7d9d25f07f07 expression: 'change(/Mikrotik - OSPF LLD/statechange.[{#NUMBER},{#ROUTERID},{#ADDRESS},{#INTERFACE}])>10' name: 'OSPF Neighbor ({#NUMBER}-{#ROUTERID}-{#ADDRESS}-{#INTERFACE}) state change is to high' priority: DISASTER macros: - macro: '{$MIKROTIK_SSH_PASS}' value: '11111' - macro: '{$MIKROTIK_SSH_PORT}' value: '22' - macro: '{$MIKROTIK_SSH_USER}' value: mikmon