[admin@NHSHITFW001] > / system health print;
Columns: NAME, VALUE, TYPE
# NAME VALUE TYPE
0 power-consumption 50.7 W
1 cpu-temperature 40 C
2 fan1-speed 4931 RPM
3 fan2-speed 5060 RPM
4 fan3-speed 4986 RPM
5 fan4-speed 5099 RPM
6 board-temperature1 27 C
7 board-temperature2 25 C
8 psu1-voltage 12.1 V
9 psu2-voltage 12.1 V
10 psu1-current 0.3 A
11 psu2-current 3.9 A
:put [/system health get]
.id=*10;name=power-consumption;type=W;value=8.9;.id=*11;name=cpu-temperature;type=C;value=54;.id=*1b59;name=fan1-speed;type=RPM;value=0;.id=*1b5a;name=fan2-speed;type=RPM;value=0;.id=*1b5b;name=fan3-speed;type=RPM;value=0;.id=*1b5c;name=fan4-speed;type
=RPM;value=0;.id=*1bbd;name=board-temperature1;type=C;value=30;.id=*1c21;name=psu1-voltage;type=V;value=26.2;.id=*1c22;name=psu2-voltage;type=V;value=52.3;.id=*1c85;name=psu1-current;type=A;value=0;.id=*1c86;name=psu2-current;type=A;value=0.1
:put [/system health get]
[@M-71rc6] > :put [/system/health/get]
state=disabled;state-after-reboot=enabled
.id=*1c22;name=psu2-voltage;type=V;value=52.3
MMM MMM III KKK KKK RRR RRR OOOOOO TTT I
MikroTik RouterOS 7.1rc6 (c) 1999-2021 https://www.mikr
[xxx@M-71rc6] > :put [/system/health/get]
state=disabled;state-after-reboot=enabled
[xxx@M-71rc6] >
:foreach id in=[/system/health/find] do={:put [/system/health/get $id]}
:put [/system health get]
:foreach id in=[/system/health/find] do={:put [/system/health/get $id]}
[admin@RouterOS] > :put [/system health get]
number: 0
.id=*d;name=voltage;type=V;value=24.1
[admin@RouterOS] > :foreach id in=[/system/health/find] do={:put [/system/health/get $id]}
.id=*d;name=voltage;type=V;value=24.1
.id=*e;name=temperature;type=C;value=36
[admin@RouterOS] > :put [/system health get num=0]
.id=*d;name=voltage;type=V;value=24.1
[admin@RouterOS] >
[admin@RouterOS] > /system/health/print
Columns: NAME, VALUE, TYPE
# NAME VALUE TYPE
0 voltage 24.1 V
1 temperature 36 C
[admin@RouterOS] >
Strange that you do not get temperature from:From my RB4011, running RC6, output looks like this:
put [/system health get]
He answered the interactive prompt with "0", so this is correct.Strange that you do not get temperature from:From my RB4011, running RC6, output looks like this:put [/system health get]
in his case does not give any output without adding an id.:put [/system health get]
:foreach id in=[/system/health/find] do={:put [/system/health/get $id]}
bad command name find (line 1 column 33)
:foreach id in=[/system/health/find] do={:put [/system/health/get $id]}
.id=*d;name=voltage;type=V;value=24
.id=*e;name=temperature;type=C;value=37
: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"
}
}
[admin@MikroTik] > /system/health/print
Columns: NAME, VALUE, TYPE
# NAME VALUE TYPE
0 voltage 15.2 V
1 temperature 34 C
2 power-consumption 11.5 W
3 cpu-temperature 54 C
4 current 0.7 A
5 fan1-speed 5693 RPM
6 psu1-state ok
7 psu2-state ok
{
:put [/system/routerboard/get model]
:foreach id in=[/system health find] do={
:local health "$[/system health get $id]"
:put "$health"
}
}
SXT 5HPnD r2
.id=*d;name=voltage;type=V;value=12.2
.id=*e;name=temperature;type=C;value=16
RouterBOARD 3011UiAS
.id=*d;name=voltage;type=V;value=27.8
.id=*e;name=temperature;type=C;value=22
RB4011iGS+
.id=*d;name=voltage;type=V;value=24.5
.id=*e;name=temperature;type=C;value=29
RB4011iGS+5HacQ2HnD
.id=*d;name=voltage;type=V;value=24.4
.id=*e;name=temperature;type=C;value=27
CRS226-24G-2S+
.id=*d;name=voltage;type=V;value=24.9
.id=*e;name=temperature;type=C;value=23
.id=*d;name=voltage;type=V;value=15.2
.id=*e;name=temperature;type=C;value=34
.id=*10;name=power-consumption;type=W;value=11.5
.id=*11;name=cpu-temperature;type=C;value=54
.id=*12;name=current;type=A;value=0.7
.id=*1b59;name=fan1-speed;type=RPM;value=5713
.id=*1ce9;name=psu1-state;type=;value=ok
.id=*1cea;name=psu2-state;type=;value=ok
.id=*10;name=power-consumption;type=W;value=47.2
.id=*11;name=cpu-temperature;type=C;value=58
.id=*1b59;name=fan1-speed;type=RPM;value=405
.id=*1b5a;name=fan2-speed;type=RPM;value=795
.id=*1bbd;name=board-temperature1;type=C;value=32
.id=*1c21;name=psu1-voltage;type=V;value=25.6
.id=*1c22;name=psu2-voltage;type=V;value=51.1
.id=*1c85;name=psu1-current;type=A;value=0.7
.id=*1c86;name=psu2-current;type=A;value=0.5
.id=*1ce9;name=psu1-state;type=;value=ok
.id=*d;name=voltage;type=V;value=24.2
.id=*e;name=temperature;type=C;value=34
.id=*10;name=power-consumption;type=W;value=24.9
.id=*11;name=cpu-temperature;type=C;value=57
.id=*12;name=current;type=A;value=1
.id=*1b59;name=fan1-speed;type=RPM;value=6573
.id=*1ce9;name=psu1-state;type=;value=ok
.id=*1cea;name=psu2-state;type=;value=fail
:local health [/system health get [find name="psu2-voltage"]]
: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"
}
}
{
:local ros [:pick [/system resource get version] 0 1]
:if ($ros = "7") do={
:put ([/system health get [find where name="cpu-temperature"]]->"value")
} else={
:put ([/system health print as-value]->"temperature")
}
}
{... :local ros [:pick [/system resource get version] 0 1]
{...
{... :if ($ros = "7") do={
{{... :put ([/system health get [find where name="cpu-temperature"]]->"value")
{{... } else={
{{... :put ([/system health print as-value]->"temperature")
{{... }
{... }
bad command name find (line 5 column 36)
hEX 7.2.3 does not work::if (!([/system health get]~"(state=disabled|^\$)")) do={
{
{... :local ros [:pick [/system resource get version] 0 1]
{...
{... :if ($ros = "7") do={
{{... :put ([/system health get [find where name="cpu-temperature"]]->"value")
{{... } else={
{{... :put ([/system health print as-value]->"temperature")
{{... }
{... }
no such item
#---- send temperature to telegram if > 60C
:local temperatura [/system/health get [find name=cpu-temperature] value]
#or
#:local temperatura [/system/health get [find name=temperature] value]
#:local volts [/system/health get [find name=voltage] value]
#...
:local emessage ""
:global sendCPUTemperature
#:log warning $temperatura;
##
{
#create variable
:if ($sendCPUTemperature<0) do={
:global sendCPUTemperature 0
}
#check temp limit
:if ($temperatura>60 && $sendCPUTemperature=0) do={
:set emessage "Temp CPU HIGH: $temperatura C"
:global telegramMessage $emessage
#system script run SendToTelegram
:log warning $emessage;
:global sendCPUTemperature 1
:delay 3;
}
# send on telegram only when the temperature drop
:if ($temperatura<60 && $sendCPUTemperature=1) do={
:set emessage "Temp CPU OK: $temperatura C"
:log warning $emessage;
:global sendCPUTemperature 0
:global telegramMessage $emessage
/system script run SendToTelegram
:delay 3;
}
}
:global telegramMessage
:local botid
:local chatid
:local CurDate [/system clock get date]
:local CurTime [/system clock get time]
:local CurIdent [/system identity get name]
set botid "xxxxxxxxx:yourbootidcode"
set chatid "xxxxxxxxx"
if ($telegramMessage != "") do={
/tool fetch url="https://api.telegram.org/bot$botid/sendmessage?chat_id=-$chatid&text=$telegramMessage %0A >>>$CurIdent" \
keep-result=no
set telegramMessage ""
}