global-functions: introduce and use $DeviceInfo

This commit is contained in:
Christian Hesse 2019-09-12 13:45:44 +02:00
parent 23b38fa15a
commit 94581741f4
5 changed files with 41 additions and 47 deletions

View file

@ -294,3 +294,32 @@
:delay ([ $GetRandom $1 ] . "s");
}
# get readable device info
:global DeviceInfo do={
:global Identity;
:local BoardName [ / system resource get board-name ];
:local RouterBoard [ / system routerboard get ];
:local Update [ / system package update get ];
:local Info ( \
"Hostname: " . $Identity . "\n" . \
"Board name: " . $BoardName);
:if ($RouterBoard->"routerboard" = true) do={
:set Info ($Info . "\n" . \
"Model: " . $RouterBoard->"model" . "\n" . \
"Serial number: " . $RouterBoard->"serial-number");
}
:set Info ($Info . "\n" . \
"RouterOS:\n" . \
" Channel: " . $Update->"channel" . "\n" . \
" Installed: " . $Update->"installed-version");
:if ([ :typeof ($Update->"latest-version") ] != "nothing" && \
$Update->"installed-version" != $Update->"latest-version") do={
:set Info ($Info . "\n" . \
" Available: " . $Update->"latest-version");
}
:return $Info;
}