I'm trying to monitor a device (Xbox) in a short term rental, I want to know if its been removed from the network and be notified.
Unfortunately I cannot use net watch as the device stays offline and comes online briefly to re-bind to DHCP then goes offline again.
I'm trying to use the binder IP address using the following
Now I need to add an IF statement and send a notification via LOG message if its up or down; but only report a single time per instance./ip dhcp-server lease get [find comment="XBOX - 30c Snowmass" status=bound]
i.e. dont message me every time the script has run if the device is up, up, up, etc
I've gotten this far but it isn't working...
I just cant figure out how to put it all together and like I said, only send a single notification per state:local sentfound
:local sentmissing
:local macfound [/ip dhcp-server lease get [find comment="XBOX - 30c Snowmass" status=bound]]
:if ($macfound != "") do={
:if ($sentfound = 1) do {
:log info "XBOX found"
}
:set sentfound 0
:set sentmissing 0
}
} else= {
:if ($sentmissing = 1) do {
:log info "XBOX missing"
}
:set sentfound 0
:set sentmissing 0
}
}
Any help would be greatly appreciated
Thanks in advance