侧边栏壁纸
博主头像
Backspace‘s Blog 博主等级

行动起来,活在当下

  • 累计撰写 33 篇文章
  • 累计创建 8 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

ros_email_res_worker.native.conf

Backspace
2026-01-21 / 0 评论 / 1 点赞 / 1 阅读 / 0 字 / 正在检测是否收录...
## Fox RouterOS Notification
:local Project "Resource Report";
:local WanInterface "pppoe-out1";              # Need to customize
:local UpdateChannel "stable";

## Check For Upgrade
:local SystemVer [/system package update get installed-version ];
:local UpstreamVer;
:local Status;
:local Channel;

:if ($UpstreamVer = nothing) do={
    /system package update set channel=$UpdateChannel
    /system package update check-for-updates
    :delay 10s;
    :set UpstreamVer [/system package update get latest-version ];
    :set Status [/system package update get status ];
    :set Channel [/system package update get channel ];
}
## End Check For Upgrade

## Check Licence Status
:local Level [/system license get nlevel ];
:local SID [/system license get software-id ];
:local Features [/system license get features ];
## End Check Licence Status

## Check CPU Status
:local CpuCores [/system resource get cpu-count ];
:local CpuLoad [/system resource get cpu-load ];
:local CpuFrequency [/system resource get cpu-frequency ];
## End Check CPU Status

## Check Memory Status
:local MemoryFree [/system resource get free-memory ];
:local MemoryTotal [/system resource get total-memory ];
## End Check Memory Status

## Check Disk Status
:local DiskFree [/system resource get free-hdd-space ];
:local DiskTotal [/system resource get total-hdd-space ];
:local DiskWrites [/system resource get write-sect-since-reboot ];
:local DiskWritesTotal [/system resource get write-sect-total ];
:local DiskBadBlocks [/system resource get bad-blocks ];

:if ([:typeof $DiskBadBlocks] = "num") do={
    :set DiskBadBlocks "$DiskBadBlocks %";
} else={
    :set DiskBadBlocks "No NAND detected";
}
## End Check Disk Status

## Check WAN Status
:local WanIPv4 [/ip address get [/ip address find interface=$WanInterface] address ];
:local WanIPv4Network [/ip address get [/ip address find interface=$WanInterface] network ];
:local WanLinkDownTime [/interface get $WanInterface last-link-down-time ];
:local WanLinkUpTime [/interface get $WanInterface last-link-up-time ];
:local WanLinkDowns [/interface get $WanInterface link-downs ];
:local WanTx [/interface get $WanInterface tx-byte ];
:local WanRx [/interface get $WanInterface rx-byte ];
:local WanTxDrop [/interface get $WanInterface tx-drop ];
:local WanRxDrop [/interface get $WanInterface rx-drop ];
:local WanTxError [/interface get $WanInterface tx-error ];
:local WanRxError [/interface get $WanInterface rx-error ];
## End Check WAN Status

## Check WAN IPv6 Status
:local WanIPv6;
:local WanIPv6Prefix;
:local WanIPv6PrefixLength;

:local GetGuaAddress [/ipv6 address find where from-pool ~ ".+" ];
:local LenGuaAddress [:len $GetGuaAddress];
:local IPv6Probe ($GetGuaAddress -> ($LenGuaAddress-1));

:if ($IPv6Probe != nothing) do={
    # Check IPv6 Status Passed
    :set WanIPv6 [/ipv6 address get $IPv6Probe address ];
    :set WanIPv6Prefix [/ipv6 dhcp-client get $WanInterface prefix ];
    :set WanIPv6PrefixLength [/ipv6 dhcp-client get $WanInterface pool-prefix-length ];
} else={
    # Check IPv6 Status Failed
    :set WanIPv6 "N/A";
    :set WanIPv6Prefix "N/A";
    :set WanIPv6PrefixLength "N/A";
}
## End Check WAN IPv6 Status

## Check Dns Status
:local DnsCacheSize [/ip dns get cache-size ];
:local DnsCacheUsed [/ip dns get cache-used ];
## End Check Dns Status

## Resolve Mail Server
:local MailServer "<smtp.xxx.com>";            # Need to customize
:local SendTo "<your-email-y@yyy.com>";        # Need to customize
:local MailTls "yes";
:local MailIp;
:onerror e {
    :retry command={
        :set MailIp [:resolve $MailServer ];
        :delay 2s;
    } delay=5 max=3;
} do={
    # Failed to resolve mail server
    :error ("Failed to resolve email server address...");
}
## End Resolve

:local DeviceName [/system identity get name ];
:local Time [/system clock get time ];
:local Date [/system clock get date ];
:local Uptime [/system resource get uptime ];

/tool e-mail send server=$MailIp tls=$MailTls to=$SendTo \
subject="$DeviceName $Project: [Uptime: $Uptime] [$Date $Time]" body= \
"=====>   RouterOS Report   <=====\r

Router hostname: $DeviceName\r
System date: $Date $Time\r
System uptime: $Uptime\r

System status: $Status\r
Upstream version: $UpstreamVer ( channel: $Channel )\r
Installed version: $SystemVer\r

System licence level: $Level\r
System software ID: $SID\r
System features: $Features\r

=====>   Extranet Status   <=====\r

WAN interface: $WanInterface\r

Last link down time: $WanLinkDownTime\r
Last link up time: $WanLinkUpTime\r
Link downs: $WanLinkDowns\r

IPv4 address: $WanIPv4\r
Network: $WanIPv4Network\r

Prefix: $WanIPv6Prefix\r
IPv6 address: $WanIPv6\r
Pool prefix length: $WanIPv6PrefixLength\r

WAN Rx: $[($WanRx / 1048576)] MiB ( as $[($WanRx / 1073741824)] GiB )\r
WAN Tx: $[($WanTx / 1048576)] MiB ( as $[($WanTx / 1073741824)] GiB )\r

WAN Rx quality: Drop $WanRxDrop , Error $WanRxError\r
WAN Tx quality: Drop $WanTxDrop , Error $WanTxError\r

=====>   CPU   <=====\r

Core: $CpuCores Cores\r
Load: $CpuLoad %\r
Frequency: $CpuFrequency MHz\r

=====>   Memory   <=====\r

Total: $[($MemoryTotal / 1048576)] MiB\r
Used:  $[(($MemoryTotal / 1048576) - ($MemoryFree / 1048576))] MiB\r
Free:  $[($MemoryFree / 1048576)] MiB\r

=====>   Disk   <=====\r

Total: $[($DiskTotal / 1048576)] MiB\r
Used:  $[(($DiskTotal / 1048576) - ($DiskFree / 1048576))] MiB\r
Free:  $[($DiskFree / 1048576)] MiB\r

Total sector writes: $DiskWritesTotal\r
Sector writes since reboot: $DiskWrites\r
Bad blocks: $DiskBadBlocks\r

=====>   DNS   <=====\r

Cache size: $DnsCacheSize KiB\r
Cache used: $DnsCacheUsed KiB\r
Cache free: $[($DnsCacheSize - $DnsCacheUsed)] KiB\r
";
## End Fox RouterOS Notification

1
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区