Hi there, i’m trying to make a script for SNMP protocol to monitor one of my resources but had no luck, maybe someone can help me ? So the idea - use ping command, count recieved packets and if success - return integer number. The idea was took from this guide https://github.com/gitpel/routeros-ipsec-snmp
So my script:
Using 1.3.6.1.4.1.14988.1.1.18.1.1.2.X OID from guide what i mantioned before. I need exactly “0” or “1” to integrate this script to my Zabbix. Thank you.
It is the usual problem of taking something done to do something very specific, and thinking of upsetting it.
I already have the solution for you, just answer to my questions.
If possible I want you to deduce the soluction instead to spoon feeding you.
Is more constructive, from my point of view.
First question: What tool inside RouterOS can already “ping” the IP,
and already can execute something when does it come back online or when does it go offline?
I understand what you mean, but Netwatch does not fit for my task. The idea - every 5 minutes Zabbix through SNMP protocol sending request to mikrotik to execute this script. This script must return "0" or "1" after execution and send this value to Zabbix server to operate this value in triggers. I need exactly this schema because i need ping specific resource via IPSEC vpn tunnel from mikrotik side. As i mantioned before about this guide GitHub - gitpel/routeros-ipsec-snmp: How to handle IPsec tunnels at RouterOS\Mikrotik with SNMP i tested this script and it works fine. But i cant get it how to make same thing work with ping check command.
Yes SNMP is preferable, but that’s not the point. Script working not as should be, it must return just integer number “0” or “1” but instead it return ping result as string like this “sent=5 received=5 packet-loss=0% min-rtt=21ms avg-rtt=21ms max-rtt=21ms”
Thank you again for explanation. But still not working, for some reason when i declare global var in netwatch
:global test "1"
Mikrotik cant see this var at all. When i'm trying to return the value of this var in terminal, mikrotik even do not know this var and return empty value. When i declare this var directly from terminal and used :put $test - it returns "1" as should be. Also found this thread Netwatch tool + script: Are global variables truly global? where support guy said "For netwatch, scheduler, etc current user is sys*. As I mentioned it is not a bug it is designed to work so.". In continue of this in mikrotik wiki says "global - accessible from all scripts created by current user, defined by global keyword;". So maybe my script just cant see this global var because it was created from netwatch with sys* user but script was created from admin user for example ?
The “solution” on your post is not relevant to the discussion or to the solution of this problem.
In fact, you don’t provide any solution, description or procedure, neither to the main problem, nor to the netwatch problem,
you just copied and pasted one script from my other post.