Get device status

Hi,

can anyone tell how I can check ,admin-status, of interfaces ? I need monitoring interface if run or not via scripts.


Thanks

/Tomi

please describe more specific what do you want to achieve? What interface do you want to be monitored and where do you want to put this status of interface?

Edgars

get oid of needed interface in /interface print oid
and snmpget it:

$ snmpget -v 1 -c public <ip> <oid>

sorry for short description :slight_smile:

My problem is : I need monitoring status of L2TP in/out, EoIP,PPTP.. connections on router and send email when one of connections goes down or up. Not via SNMP, only script based.


/Tomi

here is an example how to monitor the interface status:

:global u
/interface ethernet monitor ether1 once do={
  :set u $status
  }
:if ($u != "link-ok") do={
  /tool e-mail send to=someone@somewhere.com subject="Ether1 link down!"
  }

configure also e-mail client settings in this case.

To make this script run, for example, every 5 minutes, put it in the system scheduler task.

Edgars

thats what I need : /interface ethernet monitor ether1 once
but what about monitoring L2TP IN and L2TP-OUT ?

/Tomi

ok, next problem, I need monitor interface and send email shen interface goes up and the same when goes down. When I use your script and make copy of script with “disconnected” value instead “connected”, script send every x minute email, I need send mail only once when goe down, and next mail only if interface goes up.

I try write this two scripts but not work :frowning:

script 1 - InitMonitorL2TP

:global l2-mikro32
:global temp1
/interface l2tp-server monitor L2TP-MIKRO32 once do={ :set l2-mikro32 $status}
:if ($l2-mikro32 = “connected”) do={:set temp1 “0”}
:if ($l2-mikro32 = “disconnected”) do={:set temp1 “1”}

script 2 - Status (run every 5 minutes)

:if ([/system scheduler get InitMonitorL2TP run-count]<=1) do={ /system script run InitMonitorL2TP }

:if ($temp1=“0”) do={ :if ($l2-mikro32 = “connected” ) do={
/tool e-mail send from=“xxx” to=“xxx” subject=“L2TP-MIKRO 32 connected”
:set temp1 “1” }
}

:if ($temp1=“1”) do={ :if ($l2-mikro32 = “disconnected” ) do={
/tool e-mail send from=“xxx” to=“xxx” subject=“WIFI Router 01 - L2TP-MIKRO 32 disconnected”
:set temp1 “0” }
}

But they dont want work :frowning:
Any ideas ?

Thanks

/Tomi

sorry, script 2 is :

:if ([/system scheduler get InitMonitorL2TP run-count]<=1) do={ /system script run InitMonitorL2TP }

/interface l2tp-server monitor L2TP-MIKRO32 once do={ :set l2-mikro32 $status}

:if ($temp1=“0”) do={ :if ($l2-mikro32 = “connected” ) do={
/tool e-mail send from=“xxx” to=“xxx” subject=“L2TP-MIKRO 32 connected”
:set temp1 “1” }
}

:if ($temp1=“1”) do={ :if ($l2-mikro32 = “disconnected” ) do={
/tool e-mail send from=“xxx” to=“xxx” subject=“WIFI Router 01 - L2TP-MIKRO 32 disconnected”
:set temp1 “0” }
}

/Tomi

if i look at the latest script2 (previosu post) then i can’t see where are you setting some value to ‘temp1’ variable. What king of errors are appearing when you run the script?

Edgars

error is :
script error: input does not match any value of item name
:frowning:

/Tomi