Code: Select all
/ip dhcp-server lease
:if ($leaseBound = 1 && [ get [ find where mac-address=$leaseActMAC ] dynamic ] = true) do={
:do {
:tool fetch url="https://api.telegram.org/bot1688353301:AAHL3EGpj7DbbI98JhAvJUTClI8vN0MHdQQ/sendmessage?chat_id=-XXXXXXXXX&text=La dirección MAC [$leaseActMAC] recibió la IP dinámica [$leaseActIP] del servidor DHCP"
:log info "Sent alert for MAC $leaseActMAC to telegram"
} on-error={:log error "Failed to send telegram alert"}
}
:local recipient "mikrotik@gmail.com"
/ip dhcp-server lease
:if (($leaseBound=1) && ([/ip dhcp-server lease find where dynamic mac-address=$leaseActMAC]!="")) do {
:do {
:tool e-mail send to=$recipient subject="DHCP Alert [MAC: $leaseActMAC]" body="La dirección MAC [$leaseActMAC] recibió la IP dinámica [$leaseActIP] del servidor DHCP"
# :log info "Sent DHCP alert for MAC $leaseActMAC"
} on-error={:log error "Failed to send email to $recipient"}
}
I have a netwatch set to send a message over telegram too and this one works very well so my telegram bot is fine and if I do :tool fetch url= in CLI it sends the message but when the script runs on event it goes to on-error. I'm trying to isolate the cause as to why is only the telegram part of my alert for new DHCP lease failing as it used to work before but one day it just didn't.