Получение ip адреса вместо идентификатора
Добавлено: 27 дек 2021, 11:14
Добрый день. Имеется скрипт отправки аллертов в телегу. Подскажите как я могу получить вместо [/system identity get name] идентификатора микротика чтобы мне подставлялся адрес бридж интерфейса /ip addresses bridge?
:global lastTime
:global output
:global mtIdentity [/system identity get name];
:global botID "botxxxxx" ;
:global myChatID "xxxx" ;
:local LogGet [ :toarray [ /log find topics~"critical" || message~"login failure" || message~"[Ff]ailure" ] ] ;
:local LogtLineCount [ :len $LogGet ] ;
if ($LogtLineCount > 0) do={
:local currentTime "$[ /log get [ :pick $LogGet ($LogtLineCount -1) ] time ]";
:if ([:len $currentTime] = 10 ) do={
:set currentTime [ :pick $currentTime 0 10 ];
}
:set output "$currentTime - $[/log get [ :pick $LogGet ($LogtLineCount-1) ] message ]";
:if (([:len $lastTime] < 1) || (([:len $lastTime] > 0) && ($lastTime != $currentTime))) do={
:set lastTime $currentTime ;
:tool fetch url=("https://api.telegram.org/$botID/sendmes ... mtIdentity\" : $output") keep-result=no
}
}
:global lastTime
:global output
:global mtIdentity [/system identity get name];
:global botID "botxxxxx" ;
:global myChatID "xxxx" ;
:local LogGet [ :toarray [ /log find topics~"critical" || message~"login failure" || message~"[Ff]ailure" ] ] ;
:local LogtLineCount [ :len $LogGet ] ;
if ($LogtLineCount > 0) do={
:local currentTime "$[ /log get [ :pick $LogGet ($LogtLineCount -1) ] time ]";
:if ([:len $currentTime] = 10 ) do={
:set currentTime [ :pick $currentTime 0 10 ];
}
:set output "$currentTime - $[/log get [ :pick $LogGet ($LogtLineCount-1) ] message ]";
:if (([:len $lastTime] < 1) || (([:len $lastTime] > 0) && ($lastTime != $currentTime))) do={
:set lastTime $currentTime ;
:tool fetch url=("https://api.telegram.org/$botID/sendmes ... mtIdentity\" : $output") keep-result=no
}
}