I know Jotne's health report solution, which also works for Mikrotik routerOs v6 and V7.
:do {
# New version
:foreach id in=[/system health find] do={
:local health "$[/system health get $id]"
:set ( "$health"->"script" ) "health"
:log info message="$health"
}
} on-error={
# Old version
:if (!([/system health get]~"(state=disabled|^\$)")) do={
:local health "$[/system health get]"
:set ( "$health"->"script" ) "health"
:log info message="$health"
}
}
My problem is that I want to store the values read by the script in variables.
That is, I want to use a script for both V6 and V7.
How can the output of the above commands be split up and stored in a single variable?
What I'm looking for the solution the most is version 7. Although I know how to ask for all possible values one by one, but if, for example, the PSU1 FAN does not exist, the script stops with an error.
like:
set healthfan1speed "[/system health get value-name=fan1-speed]";