I have this script on my DHCP server that informs me when someone connects to my LAN.
Code: Select all
/ip dhcp-server lease
:if ($leaseBound = 1) do={
:do {
:local Comment [/ip dhcp-server lease get value-name=comment number=[/ip dhcp-server lease find address=$leaseActIP]]
:local interFace [/caps-man/registration-table get [find where mac-address=$leaseActMAC] interface]
# START Send Telegram Module
:local MessageText "\E2\84\B9 <b>Mikrotik: Info DHCP</b> %0D%0A Name: $"lease-hostname" %0D%0A IP: $leaseActIP %0D%0A MAC: $leaseActMAC %0D%0A Interface: $interFace %0D%0A Comment: $Comment";
:local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]];
$SendTelegramMessage MessageText=$MessageText;
#END Send Telegram Module
:log info "Send DHCP Alert $"lease-hostname" $leaseActMAC"
} on-error={:log error "Telegram notification failure"}
}
The script works fine when the hosts are wireless devices, but when they are connected by ethernet cable the script fails and does not send info to Telegram: "no such item" since the MAC of the ethernet device is not in CAPsMAN's "Registration Table".
Any help correcting the script please?
BR.