commit 8018bb5ef75f8f0b2998cdbee3dacc34da50a39b Author: furaihan Date: Wed Aug 26 18:25:49 2020 +0700 some script added added the following script:cpu monitoring, auto add dns address to addres list, and monitoring data usage send to telegram diff --git a/cpu-monitoring b/cpu-monitoring new file mode 100644 index 0000000..b67433e --- /dev/null +++ b/cpu-monitoring @@ -0,0 +1,41 @@ +#using System; +#using System.Reflection; +#using System.ComponentModel; +#using System.Threading; + +global cpuarray ([/system resource get value-name=cpu-load]) +local isInternetConnected +local rebootIfHigh false +local setup do={ + delay 950ms; + global cpuarray + set cpuarray ([/system resource get value-name=cpu-load],$cpuarray) +} +local cpusample 20 +for i from=1 to=[$cpusample -1] do={ + $setup +} +local totalcpuarray 0 +foreach value in=$cpuarray do={ set totalcpuarray ($totalcpuarray + $value)} +:put $totalcpuarray +local avgcpu ($totalcpuarray / [:len $cpuarray]) +if ($avgcpu > 65) do={ + tool flood-ping 8.8.8.8 count=10 do={ + /if ($received > 8) do={ + set $isInternetConnected [tobool true] + } else={ + set $isInternetConnected [tobool false] + } + } + if ($isInternetConnected=true) do={ + global CHATID + 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 CPU Load Report%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; + } else={ + log warning message="Cannot send message to telegram. is internet connected?" + } + if ($rebootIfHigh = true) do={/system reboot} +} else={ + nothing +} diff --git a/data-usage-to-telegram b/data-usage-to-telegram new file mode 100644 index 0000000..e0f2c5e --- /dev/null +++ b/data-usage-to-telegram @@ -0,0 +1,27 @@ +:local keluar +:delay 2s +:local boros ([/interface get value-name=fp-rx-byte wlan1] + [/interface get value-name=fp-tx-byte wlan1]) +:delay 1s +:local borostotal ($boros / 1024 / 1024 /1024); +:delay 3s +:local signall ("\F0\9F\93\B6 Signal Strength: ".[/int wir reg get value-name=signal-strength number=0]."%0A") +:delay 5s +:local murup ([/system resource get uptime]) +:local papan ([/system resource get board-name]) +:local ngalong ("MikroTik $papan%0A\E2\8C\9B Uptime: $murup%0A") +: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; \ No newline at end of file diff --git a/dns-game-and-socmed--to-address-list b/dns-game-and-socmed--to-address-list new file mode 100644 index 0000000..ad42e58 --- /dev/null +++ b/dns-game-and-socmed--to-address-list @@ -0,0 +1,68 @@ +#=============================================== DNS Monitor Information ================================================ +# +# COPYRIGHT MIKROTIK ROUTEROS SCRIPT PROVIDED BY FURAIHAN +# +#=============================================== DNS Monitor by furaihan ================================================ +# +# THE SCRIPT FILE LOADED SUCCESFULLY. +# DETECTED VERSION: 1.0 BETA +# +#=============================================== DNS Monitor by furaihan ================================================ + +foreach 11g in=[/ip dns cache all find where (name~"zynga" or name~"kojima" or name~"konami" or name~"projektred" or name~"rockstar" or name~"ubisoft" or name~"gameloft" or name~"superevil" or name~"mojang" or name~"game" or name~"steampowered" or name~"garena" or name~"freefire" or name~"supercell" or name~"moonton" or name~"dragonraja" or name~"activision" or name~"bandai" or name~"codmobile") && (type="CNAME")] do={ + :local 22g [/ip dns cache all get value-name=name $11g] + :local 33g [/ip dns cache all get value-name=data $11g] + :local 44g [:resolve "$33g"] + :local 55g [:len [/ip fir ad find where address=$44g]] + :put message="Address $22g - $44g found, checking availability on firewall address list" + :if ($55g=0) do={ + /ip fir ad add address=$44g list=GAME + :local sms ("DNS game $22g has been added succesfully") + :put $sms + :log info message="$sms" + /ip fir ad set [find where address=$44g] comment=[] + } +} +delay 2s; +foreach 11gg in=[/ip dns cache all find where (name~"zynga" or name~"kojima" or name~"konami" or name~"projektred" or name~"rockstar" or name~"ubisoft" or name~"gameloft" or name~"superevil" or name~"mojang" or name~"game" or name~"steampowered" or name~"garena" or name~"freefire" or name~"supercell" or name~"moonton" or name~"dragonraja" or name~"activision" or name~"bandai" or name~"codmobile") && (type="A")] do={ + :local 22gg [/ip dns cache all get value-name=name $11gg] + :local 33gg [/ip dns cache all get value-name=data $11gg] + :local 55gg [:len [/ip fir ad find where address=$33gg]] + :put message="Address $22gg - $33gg found, checking availability on firewall address list" + :if ($55gg=0) do={ + /ip fir ad add address=$33gg list=GAME + :local sms ("DNS game $22gg has been added succesfully") + :put $sms + :log info message="$sms" + /ip fir ad set [find where address=$33gg] comment=[] + } +} +delay 1s; +foreach 11s in=[/ip dns cache all find where (name~"tiktok" or name~"instagram" or name~"fbcdn" or name~"whatsapp" or name~"telegram" or name~"wa.me" or name~"today.line" or name~"likee" or name~"twitter" or name~"twimg" or name~"pinterest" or name~"pinimg" or name~"snapchat" or name~"appspot.com" or name~"linkedin" or name~"licdn" or name~"line-scdn" or name~"tumblr" or name~"reddit" or name~"facebook" or name~"1cak.com" or name~"redd.it") && (type="CNAME")] do={ + :local 22s [/ip dns cache all get value-name=name $11s] + :local 33s [/ip dns cache all get value-name=data $11s] + :local 44s [:resolve "$33s"] + :local 55s [:len [/ip fir ad find where address=$44s]] + :put message="Address $22s - $44s found, checking availability on firewall address list" + :if ($55s=0) do={ + /ip fir ad add address=$44s list=SOSMED + :local sms ("DNS sosmed $22s has been added succesfully") + :put $sms + :log info message="$sms" + /ip fir ad set [find where address=$44s] comment=[] + } +} +delay 1s; +foreach 11ss in=[/ip dns cache all find where (name~"tiktok" or name~"instagram" or name~"fbcdn" or name~"whatsapp" or name~"telegram" or name~"wa.me" or name~"today.line" or name~"likee" or name~"twitter" or name~"twimg" or name~"pinterest" or name~"pinimg" or name~"snapchat" or name~"appspot.com" or name~"linkedin" or name~"licdn" or name~"line-scdn" or name~"tumblr" or name~"reddit" or name~"facebook" or name~"1cak.com" or name~"redd.it") && (type="A")] do={ + :local 22ss [/ip dns cache all get value-name=name $11ss] + :local 33ss [/ip dns cache all get value-name=data $11ss] + :local 55ss [:len [/ip fir ad find where address=$33ss]] + :put message="Address $22ss - $33ss found, checking availability on firewall address list" + :if ($55ss=0) do={ + /ip fir ad add address=$33ss list=SOSMED + :local sms ("DNS sosmed $22ss has been added succesfully") + :put $sms + :log info message="$sms" + /ip fir ad set [find where address=$33ss] comment=[] + } +}