I know you experts will cringe at a simpleness, but I'm proud of myself.
Code: Select all
# Collect system resource
/system resource
:local cpuload [get cpu-load]
:local freemem ([get free-memory]/1048576)
:local totmem ([get total-memory]/1048576)
:local freehddspace ([get free-hdd-space]/1048576)
:local totalhddspace ([get total-hdd-space]/1048576)
:local up [get uptime]
:local sector [get write-sect-total]
:log info message=\"free_memory=\$freemem MB total_memory=\$totmem MB free_hdd_space=\$freehddspace MB total_hdd_space=\$totalhddspace MB cpu_load=\$cpuload uptime=\$up write-sect-total=\$sector\"
# Collect system information
:local model na
:local ffirmware na
:local cfirmware na
:local ufirmware na
:local version ([/system resource get version])
:local board ([/system resource get board-name])
:local identity ([/system identity get name])
:do {
:if (\$board!=\"CHR\" OR \$board!=\"x86\") do={
/system routerboard
:set model ([get model])
:set ffirmware ([get factory-firmware])
:set cfirmware ([get current-firmware])
:set ufirmware ([get upgrade-firmware])
}
} on-error={}
:log info message=\"version=\\\"\$version\\\" board-name=\\\"\$board\\\" model=\\\"\$model\\\" identity=\\\"\$identity\\\"\"
# Collect IP addresses
:foreach neighborID in=[/ip address find] do={
:local nb [/ip address get \$neighborID]
:local id [:pick (\"\$nb\"->\".id\") 1 99]
:foreach key,value in=\$nb do={
:local newline [:find \$value \"\\"]
:if ([\$newline]>0) do={
:set value [:pick \$value 0 \$newline]
}
:if (\$key~\"add\") do={
:log info message=\"System IP Address \$value\"\
}
}
}