Оповещения об критических событиях в Telegram

How can we help?

Оповещения об критических событиях в Telegram

Навигация

Создаем System/Shedule для

:global lastTime
:global output
:global mtIdentity [/system identity get name];
:global botID "bot14940261111111111111111111111111TwJ1ysZs" ;
:global myChatID "27811112";

: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/sendmessage\?chat_id=$myChatID&text=\"$mtIdentity\" :  $output") keep-result=no
   }
}