mirror of
https://github.com/furaihan/simple-mikrotik-script.git
synced 2025-06-24 23:18:39 +02:00
closes #1 and fix question mark typo
This commit is contained in:
parent
840defec9b
commit
cbdd01373d
2 changed files with 13 additions and 31 deletions
|
@ -22,7 +22,7 @@ if ($avgcpu > 65) do={
|
||||||
global CHATID
|
global CHATID
|
||||||
global BOTID
|
global BOTID
|
||||||
local sendToTelegram ("Mikrotik ".[/system resource get value-name=board-name]."(".[/sy id get value-name=name].") :%0A\E2\9A\A0 \E2\9A\A0 <b>CPU Load Report</b>%0AAverage: $avgcpu%25%0ACPU Samples: $cpusample%0AReboot if CPU sample show highload: $rebootIfHigh")
|
local sendToTelegram ("Mikrotik ".[/system resource get value-name=board-name]."(".[/sy id get value-name=name].") :%0A\E2\9A\A0 \E2\9A\A0 <b>CPU Load Report</b>%0AAverage: $avgcpu%25%0ACPU Samples: $cpusample%0AReboot if CPU sample show highload: $rebootIfHigh")
|
||||||
/tool fetch url="https://api.telegram.org/bot$BOTID/sendMessage?chat_id=$CHATID&text=$sendToTelegram&parse_mode=html" keep-result=no;
|
/tool fetch url="https://api.telegram.org/bot$BOTID/sendMessage\?chat_id=$CHATID&text=$sendToTelegram&parse_mode=html" keep-result=no;
|
||||||
} else={
|
} else={
|
||||||
log warning message="Cannot send message to telegram. is internet connected?"
|
log warning message="Cannot send message to telegram. is internet connected?"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,12 @@
|
||||||
:local keluar
|
global CheckConnection
|
||||||
:delay 2s
|
$CheckConnection
|
||||||
:local boros ([/interface get value-name=fp-rx-byte wlan1] + [/interface get value-name=fp-tx-byte wlan1])
|
global ConnectionAvailable
|
||||||
:delay 1s
|
if ($ConnectionAvailable=true) do={
|
||||||
:local borostotal ($boros / 1024 / 1024 /1024);
|
global CHATID
|
||||||
:delay 3s
|
global BOTID
|
||||||
:local signall ("\F0\9F\93\B6 Signal Strength: ".[/int wir reg get value-name=signal-strength number=0]."%0A")
|
local wan [/ip arp get number=[find where address=[/ip route get number=[find where dst-address="0.0.0.0/0" && active=yes ] gateway]] interface]
|
||||||
:delay 5s
|
local SendTelegram ("<b>Daily Data Usage Report:</b>%0A"."WAN Interface: $wan%0A"."Upload Usage:".([/interface get $wan tx-byte] / 1024 / 1024 / 1024)." GB%0ADownload Usage: ".([/interface get $wan rx-byte] / 1024 / 1024 / 1024)." GB%0ATotal: ".(([/interface get $wan tx-byte] / 1024 / 1024 / 1024) + ([/interface get $wan rx-byte] / 1024 / 1024 / 1024))." GB")
|
||||||
:local murup ([/system resource get uptime])
|
/tool fetch url="https://api.telegram.org/bot$BOTID/sendMessage\?chat_id=$CHATID&text=$SendTelegram&parse_mode=html" keep-result=no;
|
||||||
:local papan ([/system resource get board-name])
|
} else={
|
||||||
:local ngalong ("MikroTik $papan%0A\E2\8C\9B Uptime: $murup%0A")
|
log warning message="Cannot send message to telegram. is internet connected?"
|
||||||
:delay 5s
|
}
|
||||||
:local ssid ("\F0\9F\86\94 SSID Connected: ".[/interface wireless get value-name=ssid wlan1]."%0A")
|
|
||||||
:local MACAddr ("\F0\9F\8E\AC MAC Address: ".[/interface wireless get value-name=mac-address wlan1]."%0A")
|
|
||||||
:local frequency ("\F0\9F\93\A1 Frequency Used: ".[/interface wireless get value-name=frequency wlan1]."%0A")
|
|
||||||
:local RXTot ([/interface get wlan1 rx-byte])
|
|
||||||
:local TXTot ([/interface get wlan1 tx-byte])
|
|
||||||
:local byteyt ([/ip firewall filter get value-name=bytes number=3])
|
|
||||||
:local TXGB ($TXTot / 1024 / 1024 / 1024);
|
|
||||||
:local RXGB ($RXTot / 1024 / 1024 / 1024);
|
|
||||||
:local YTGB ($byteyt / 1024 / 1024);
|
|
||||||
:local upload ("\F0\9F\93\A4 Upload Usage: $TXGB GB%0A")
|
|
||||||
:local download ("\F0\9F\93\A5 Download Usage $RXGB GB%0A")
|
|
||||||
:local youtube ("\E2\96\B6 Youtube Usage: $YTGB MB%0A")
|
|
||||||
:local catatan ("Data diatas adalah hasil perhitungan selama: $murup%0A")
|
|
||||||
:set keluar ($ngalong.$ssid.$MACAddr.$frequency.$signall.$upload.$download.$youtube.$catatan."%0A")
|
|
||||||
/tool fetch url="https://api.telegram.org/bot624175217:AAEbatoTY88FkeYvjwYQbzdlurwYjMOoaFU/sendMessage?chat_id=-487804024&text=$keluar" keep-result=no;
|
|
||||||
global CHATID
|
|
||||||
global BOTID
|
|
||||||
local wan
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue