Alles mit den vergangenen Ferien. Dieses Thema ist eine bessere
Version dessen, was ich 2016 hier geschrieben habe .
Im Allgemeinen hat sich das Arbeitsprinzip nicht geändert, mit dem einzigen Unterschied, dass es jetzt sofort und ohne Verzögerung funktioniert.
Wir laden das Skript in Mikrotik hoch, ändern BotID und ChatID in unsere und erstellen einen Zeitplan dafür. Setzen Sie den Parameter "Start Time" auf "startup" (Führen Sie das Skript beim Start aus.)
Intervall: 00:00:00
Ansonsten ist alles so wie es war.
Telegramm-v2:delay 10 :global mtIdentity [/system identity get name]; :global botID "botXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXX" ; :global myChatID "YYYYYY" ; :local chatId 0; :local messageId 0; :local parse do={ :local startLoc ([:find $content $variable -1] + [:len $variable] + 2); :local commaLoc ([:find $content "," $startLoc] - 1 + 1); :local braceLoc ([:find $content "}" $startLoc] - 1 + 1); :local endLoc $commaLoc; :local startSymbol [:pick $content $startLoc] :if ($braceLoc != 0 and ($commaLoc = 0 or $braceLoc < $commaLoc)) do={ :set endLoc $braceLoc; }; :if ($startSymbol = "{") do={ :set endLoc ($braceLoc + 1); }; :if ($quotas = true) do={ :set startLoc ($startLoc + 1); :set endLoc ($endLoc - 1); } :if ($endLoc < $startLoc) do={ :set endLoc ($startLoc + 1); }; :local message [:pick $content $startLoc $endLoc]
Für ein paar Jahre des Gebrauchs wurde ein Fehler entdeckt, aus irgendeinem Grund schwache Mikrotik aus irgendeinem Grund stoppen Sie das Skript, es funktioniert, ohne auf leistungsstärkeren zu stoppen.
Zu diesem Zweck habe ich eine WatchDog-Krücke geworfen. Hier ändern wir den Namen des Skripts in den oben angegebenen. und stellen Sie das Neustartintervall auf 5 Minuten ein. Alle 5 Minuten überprüft unser „schauender Hund“ das Skript und wenn es nicht funktioniert, wird es ausgeführt.
WatchDogT.me :global scriptname "t.me" :if ([:len [/system script job find script=$"scriptname"]] > 0) do={ :log info "$scriptname Already Running - killing old script before continuing" :foreach counter in=[/system script job find script=$"scriptname"] do={ /system script job remove $counter } } /system script run $scriptname
Nun, zum Nachtisch stammt das Drehbuch aus dem Mikrotik-Forum.
Sendet wichtige Themen aus dem Protokoll in unseren Warenkorb.
Wir fügen das Skript in den Zeitplan ein und legen alle 5 Minuten das Neustartintervall fest. Ändern Sie die BotID und die ChatID in unsere.
Benachrichtigungs-Log :global lastTime :global output :global mtIdentity [/system identity get name]; :global botID "botXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXX" ; :global myChatID "YYYYYY" ; :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 } }
Wir erhalten das Ergebnis:
