Community discussions

MikroTik App
 
zepcenas
just joined
Topic Author
Posts: 2
Joined: Fri Aug 25, 2023 9:47 pm

cant get cpu temperature in script

Fri Aug 25, 2023 10:01 pm

Hello

I'm having some trouble figuring this out. This is a RB5009

On the terminal:
/system health print
Columns: NAME, VALUE, TYPE
# NAME VALUE TYPE
0 cpu-temperature 54 C

/system health get number=0
[nothing]

/system health get value-name=temperature (just to show that doesn't work)
input does not match any value of value-name

/system health get value-name=cpu-temperature
input does not match any value of value-name

Script:
:log info "$[/system identity get name] $[/system health print] testing";
outputs: router testing

How can get router temperature in a script?

Thank you
 
msatter
Forum Guru
Forum Guru
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: cant get cpu temperature in script

Fri Aug 25, 2023 10:50 pm

Have a read overhere: viewtopic.php?t=198614
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: cant get cpu temperature in script  [SOLVED]

Sat Aug 26, 2023 9:41 am

The correct syntax would have been /system/health get "cpu-temperature" value if the RouterOS programmers had made one thing uniform with everything else.

But since "cpu-temperature" is not already solved like other sections, [find where name=cpu-temperature] is needed.

So, the needed command line is:
{
    :local cputemp [/system/health get [find where name=cpu-temperature] value]
    :put $cputemp
}
 
eldoncito2019
Member
Member
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Re: cant get cpu temperature in script

Sat Aug 26, 2023 12:51 pm

REX:
How do I make the script appear in green letters like you do. Thanks for teaching.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: cant get cpu temperature in script

Sat Aug 26, 2023 1:10 pm

Use the "code display" button [ ] ...........

or manually...
[code]script[/code]
 
zepcenas
just joined
Topic Author
Posts: 2
Joined: Fri Aug 25, 2023 9:47 pm

Re: cant get cpu temperature in script

Sat Aug 26, 2023 6:17 pm

The correct syntax would have been /system/health get "cpu-temperature" value if the RouterOS programmers had made one thing uniform with everything else.

But since "cpu-temperature" is not already solved like other sections, [find where name=cpu-temperature] is needed.

So, the needed command line is:
{
    :local cputemp [/system/health get [find where name=cpu-temperature] value]
    :put $cputemp
}
Thank you Rex. I see it now.

Who is online

Users browsing this forum: Ami123waston, techcomtecnico and 6 guests