Skip to content

Instantly share code, notes, and snippets.

@L4ky
Created July 10, 2021 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L4ky/08f946cf3449c9020a5ac0f380b8a652 to your computer and use it in GitHub Desktop.
Save L4ky/08f946cf3449c9020a5ac0f380b8a652 to your computer and use it in GitHub Desktop.
mikrotik-monitor-lte-cellid-and-notify
# Please forgive me for the quality of this code, i worked on it very quickly.
# Set a schedule every 1 minute ( suggested ) in System/Scheduler
# Telegram Setup
:local botId "_YOUR_TOKEN_TELEGRAM_"
:local chatId _YOUR_CHAT_ID
# Reference Cell Setup
:global refCellId "_CELLID_HEX_"
:global refEarfcn "_EARFCN_"
:global refPci "_PCI_"
:global prevCellId
# Get data via AT Command
:local cell (:tostr(:put [/interface lte at-chat lte1 input="AT+QENG=\"servingcell\"" wait=yes as-value]));
:local cell [:pick $cell 0]
# Wait for response from LTE Module
:delay 2000ms;
# String splitting
:local myArray [:toarray [:pick $cell ([:find $cell "QENG"]+5) [:len $cell]]]
:local currentCellId [:pick $myArray 6]
:local currentPci [:pick $myArray 7]
:local currentEarfcn [:pick $myArray 8]
# Create Message
:local message "New Cell: $currentCellId - PCI: $currentPci - EARFCN: $currentEarfcn | Previous Cell: $prevCellId | Ref: $refCellId $refPci $refEarfcn"
:if ($currentCellId != $refCellId and $currentCellId != $prevCellId) do= {
:local response ([ /tool fetch url="https://api.telegram.org/bot$botId/sendMessage?chat_id=$chatId&text=$message" output=user as-value]->"data")
:log info $message
} else={:put "Cella OK"}
:set prevCellId ($currentCellId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment