Community discussions

MikroTik App
 
Kvanas
just joined
Topic Author
Posts: 1
Joined: Mon Sep 26, 2022 2:38 am

Temperature on ROS 7+

Mon Sep 26, 2022 2:55 am

Hi,
I would like to ask about the change since version ROS 7+.

I used a script to detect the temperature on version ROS 6 and today I found out that it no longer works on 7.
Previously, a value was returned directly, and now an array is returned.
.id=*e;name=temperature;type=C;value=43

I tried editing the script and using regex
([0-9][0-9]+[.][0-9])|([0-9][0-9])
but it doesn't work for me. I always get only true returned

--
:local temp [/system health get 1]
:local msg \
"$temp"
/iot mqtt publish broker="XXX" topic="stat/temp/" message=$msg
--

Does anyone know the solution.
Thanks a lot
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Temperature on ROS 7+

Mon Sep 26, 2022 6:50 pm

This is the part of Mikrotik for Splunk scipt posted here: viewtopic.php?t=179960
As you see it tries one version to get the health information (new), if that fails, use the old format.
# Collect system health
# ----------------------------------
:if ($SystemHealth) do={
	: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"
		}
	}
}

Who is online

Users browsing this forum: A9691, JDF and 21 guests