<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export><version>5.0</version><date>2021-11-21T21:48:34Z</date><groups><group><name>Templates</name></group></groups><templates><template><template>Mikrotik - OSPF LLD</template><name>Mikrotik - OSPF LLD</name><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

</description><groups><group><name>Templates</name></group></groups><applications><application><name>OSPF</name></application><application><name>OSPF JSONs</name></application></applications><items><item><name>OSPF - Neighbor JSON</name><type>SSH</type><key>ssh.run[OSPF - Neighbor JSON,,{$MIKROTIK_SSH_PORT},]</key><delay>{$UPDATEINT}</delay><history>1d</history><trends>0</trends><value_type>TEXT</value_type><params>:global list [/routing ospf neighbor find]; :global count 0; :global total [:len $list]; :put &quot;{&quot;;   :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 &lt; $total-1) do={; :put &quot;\&quot;$count\&quot;:{\&quot;ID\&quot;:\&quot;$i\&quot;,\&quot;STATECHANGES\&quot;:\&quot;$statechanges\&quot;,\&quot;ROUTERID\&quot;:\&quot;$router\&quot;,\&quot;ADDRESS\&quot;:\&quot;$address\&quot;,\&quot;INTERFACE\&quot;:\&quot;$interface\&quot;,\&quot;STATEOSPF\&quot;:\&quot;$state\&quot;},&quot;;} else={; :put &quot;\&quot;$count\&quot;:{\&quot;ID\&quot;:\&quot;$i\&quot;,\&quot;STATECHANGES\&quot;:\&quot;$statechanges\&quot;,\&quot;ROUTERID\&quot;:\&quot;$router\&quot;,\&quot;ADDRESS\&quot;:\&quot;$address\&quot;,\&quot;INTERFACE\&quot;:\&quot;$interface\&quot;,\&quot;STATEOSPF\&quot;:\&quot;$state\&quot;}&quot;;};   :set count ($count + 1); }; :put &quot;}&quot;;</params><username>{$MIKROTIK_SSH_USER}</username><password>{$MIKROTIK_SSH_PASS}</password><applications><application><name>OSPF JSONs</name></application></applications></item></items><discovery_rules><discovery_rule><name>OSPF - Neighbor</name><type>SSH</type><key>ssh.run[OSPF - Neighbor,,{$MIKROTIK_SSH_PORT},]</key><delay>1h</delay><params>:global list [/routing ospf neighbor find]; :global count 0; :global total [:len $list]; :put &quot;{\&quot;data\&quot;:[&quot;;   :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 &lt; $total-1) do={; :put &quot;{\&quot;{#NUMBER}\&quot;:\&quot;$count\&quot;,\&quot;{#ID}\&quot;:\&quot;$i\&quot;,\&quot;{#STATECHANGES}\&quot;:\&quot;$statechanges\&quot;,\&quot;{#ROUTERID}\&quot;:\&quot;$router\&quot;,\&quot;{#ADDRESS}\&quot;:\&quot;$address\&quot;,\&quot;{#INTERFACE}\&quot;:\&quot;$interface\&quot;,\&quot;{#STATE}\&quot;:\&quot;$state\&quot;},&quot;;} else={; :put &quot;{\&quot;{#NUMBER}\&quot;:\&quot;$count\&quot;,\&quot;{#ID}\&quot;:\&quot;$i\&quot;,\&quot;{#STATECHANGES}\&quot;:\&quot;$statechanges\&quot;,\&quot;{#ROUTERID}\&quot;:\&quot;$router\&quot;,\&quot;{#ADDRESS}\&quot;:\&quot;$address\&quot;,\&quot;{#INTERFACE}\&quot;:\&quot;$interface\&quot;,\&quot;{#STATE}\&quot;:\&quot;$state\&quot;}&quot;;};   :set count ($count + 1); }; :put &quot;]}&quot;;</params><username>{$MIKROTIK_SSH_USER}</username><password>{$MIKROTIK_SSH_PASS}</password><item_prototypes><item_prototype><name>{#NUMBER}-{#ROUTERID}-{#ADDRESS}-{#INTERFACE}-state</name><type>DEPENDENT</type><key>state.[{#NUMBER},{#ROUTERID},{#ADDRESS},{#INTERFACE}]</key><delay>0</delay><history>{$HISTORY}</history><trends>0</trends><value_type>TEXT</value_type><applications><application><name>OSPF</name></application></applications><preprocessing><step><type>JSONPATH</type><params>$.{#NUMBER}.STATEOSPF</params></step></preprocessing><master_item><key>ssh.run[OSPF - Neighbor JSON,,{$MIKROTIK_SSH_PORT},]</key></master_item><trigger_prototypes><trigger_prototype><expression>{str(Full)}=0</expression><name>OSPF Neighbor ({#NUMBER}-{#ROUTERID}-{#ADDRESS}-{#INTERFACE}) is not FULL</name><priority>DISASTER</priority></trigger_prototype></trigger_prototypes></item_prototype><item_prototype><name>{#NUMBER}-{#ROUTERID}-{#ADDRESS}-{#INTERFACE}-statechange</name><type>DEPENDENT</type><key>statechange.[{#NUMBER},{#ROUTERID},{#ADDRESS},{#INTERFACE}]</key><delay>0</delay><history>{$HISTORY}</history><trends>0</trends><value_type>TEXT</value_type><applications><application><name>OSPF</name></application></applications><preprocessing><step><type>JSONPATH</type><params>$.{#NUMBER}.STATECHANGES</params></step></preprocessing><master_item><key>ssh.run[OSPF - Neighbor JSON,,{$MIKROTIK_SSH_PORT},]</key></master_item><trigger_prototypes><trigger_prototype><expression>{change()}&gt;10</expression><name>OSPF Neighbor ({#NUMBER}-{#ROUTERID}-{#ADDRESS}-{#INTERFACE}) state change  is to high</name><priority>DISASTER</priority></trigger_prototype></trigger_prototypes></item_prototype></item_prototypes></discovery_rule></discovery_rules><macros><macro><macro>{$MIKROTIK_SSH_PASS}</macro><value>11111</value></macro><macro><macro>{$MIKROTIK_SSH_PORT}</macro><value>22</value></macro><macro><macro>{$MIKROTIK_SSH_USER}</macro><value>mikmon</value></macro></macros></template></templates></zabbix_export>
