Show system information from remote computer

Hello community,
i hope someone can help me. I have a small raspberry pi cluster and want to display its system values in openHAB.
What i have installed: Systeminfo Binding, Exec Binding, openHAB 2.5.9.

What i want to display: CPU temperature, Physical Memory Usage and Storage Usage.
With the Systeminfo Binding i can display this infos local on the openhab raspberry. That is clear.

What i’ve tried: I have build a script with the following contant (ssh XXX@ ‘vcgencmd measure_temp’) and use it with the exec binding. It works well.

What i fail now: How can I display the value as a “Number Item” so that I can display it in the correct system info channel.

I fail because of the transformation of the output value.
I’ve looked at many options but unfortunately haven’t found any with a simple solution.

The solution should be as simple as possible.

Does anyone have an idea or can show me a simple solution?

Thanks and best regards

I think you cannot do that by ‘reusing’ the binding.
As far as I understand that what you can do is:

  • to remote query the computers system values
  • define your own things/items ( Numbers ) as you need them
  • fill in the values that you get from the ssh command by using REST API calls

psmqtt on pi to MQTT Broker

MQTT Broker into openHAB

Run it on as many PI’s as you like

1 Like

I do the same thing: I have two Pis. One as the OH Server and one in another room doing some other things.
I wanted to monitor the other pis system information and came up with this solution:


Number  RPi2Helper_CPUAuslastung_1min           "CPU Auslastung in der letzten Minute [%.2f]"       <settings>  (Gruppe_RPi2Helper_CPU)
Number  RPi2Helper_CPUAuslastung_15min          "CPU Auslastung in den letzten 15 Minuten [%.2f]"   <settings>  (Gruppe_RPi2Helper_CPU)
Number  RPi2Helper_RAM_Frei                     "Verfügbar [JS(mb2gb_ram_pi2.js):%s]"               <settings>
Number  RPi2Helper_RAM_Benutzt                  "Benutzt [JS(mb2gb_ram_pi2.js):%s]"                 <settings>
Number  RPi2Helper_Speicher_Frei                "Verfügbar [JS(mb2gb_storage_pi2.js):%s]"           <settings>
Number  RPi2Helper_Speicher_Benutzt             "Benutzt [JS(mb2gb_storage_pi2.js):%s]"             <settings>
Number  RPi2Helper_Temperatur                   "CPU Temperatur [%.1f °C]"                          <settings>
Number  RPi2Helper_Threads                      "Anzahl der Threads [%.0f]"                         <settings>
Number  RPi2Helper_Laufzeit                     "Laufzeit [JS(timetransformation.js):%s]"           <settings>
Number  RPi2Helper_Updates                      "Anzahl der verfügbaren Updates [%.0f]"             <settings>
String  RPi2Helper_Updates_Namen                "Namen der verfügbaren Updates"                     <settings>                          

Then there is a cronjob running on the monitored pi:

pi@rpi2helper:~ $ crontab -l
0 1/3 * * * /home/pi/OpenHAB-Config/scripts/RPi2/Status\ an\ OpenHAB\ senden/
* * * * * /home/pi/OpenHAB-Config/scripts/RPi2/Status\ an\ OpenHAB\ senden/

So every minute the monitored pi sends information to the server. See these scripts. Feel free to just copy them as I did all the testing already:

pi@rpi2helper:~/OpenHAB-Config/scripts/RPi2/Status an OpenHAB senden $ cat


    curl -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$state" "http://$OHIP:8080/rest/items/$item/state"

state=$(uptime | sed -n -e 's/.*average: //p' | sed 's/ /\n/g' | sed -n 1p | sed 's/.$//' | sed 's/,/\./' )

state=$(uptime | sed -n -e 's/.*average: //p' | sed 's/ /\n/g' | sed -n 3p | sed 's/.$//' | sed 's/,/\./' )

state=$(free -m | sed -n 2p | sed 's/ /\n/g' | sed -r '/^\s*$/d' | sed -n 7p)

state=$(free -m | sed -n 2p | sed 's/ /\n/g' | sed -r '/^\s*$/d' | sed -n 3p)

state=$(df -m | grep '/dev/root' | sed 's/ /\n/g' | sed -r '/^\s*$/d' | sed -n 4p)

state=$(df -m | grep '/dev/root' | sed 's/ /\n/g' | sed -r '/^\s*$/d' | sed -n 3p)

state=$(ps -eLf | wc -l)
state=$(less /proc/uptime | awk '{print $0/60;}'|  cut -d "." -f1 )

state=$(vcgencmd measure_temp | sed 's/temp=//' | sed "s/'C//" )


pi@rpi2helper:~/OpenHAB-Config/scripts/RPi2/Status an OpenHAB senden $ cat


    curl -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$state" "http://$OHIP:8080/rest/items/$item/state"

#Updates bestimmen
sudo apt list --upgradable 2>/dev/null | tail -n +2 >.alt
sudo apt update 1>/dev/null 2>/dev/null
sudo apt list --upgradable 2>/dev/null | tail -n +2 >.neu

diff=$(diff .neu .alt | grep "<" | sed 's/< //g')
anzahl=$(cat .neu | wc -l)

IFS=$'\n'                                                                                                                                                                       #Seperator auf Neuzeile setzen für for-loop
updates_names="Verfügbare Updates auf RPi2: $anzahl"

#Alte Updates einfügen, falls die Anzahl der alten Updates ungleich 0 ist
input=$(cat .alt )

if [ "$(cat .alt | wc -l)" -ne "0" ]; then
    updates_names="$updates_names  Bisher:}$(cat .alt | wc -l)"

    for line in $input
        name=$(echo $line | cut -d"/" -f1)                                                                                                                       #Namen zuschneiden
        updates_names="$updates_names $name"                                                                                                                #Namen konkatenieren

#Neue Updates einfügen
#Diff ist nie leer, da OH die Annotation nur einträgt, wenn sich die Anzahl geändert hat. Somit kann immer das "Neue" im String enthalten sein
updates_names="$updates_names  Neu:}$(( $(cat .neu | wc -l) - $(cat .alt | wc -l) ))"

for line in $diff
    name=$(echo $line | cut -d"/" -f1)                                                                                                                          #Namen zuschneiden
    updates_names="$updates_names $name"                                                                                                                        #Namen konkatenieren

updates_names=$(echo $updates_names | sed 's/ /\\n/g' )                                                                                                 #Leerzeichen durch "\n" ersetzen
updates_names=$(echo $updates_names | sed 's/\\n/ /' | sed 's/\\n/ /' | sed 's/\\n/ /' | sed 's/\\n/ /' )                       #Die ersten e "\n" durch Leerzeichen ersetzten
updates_names=$(echo $updates_names | sed 's/}/ /' | sed 's/}/ /')                                                          #In Zeilen 30 und 36 wurde statt einem Leerzeichen eine "}" vewendet, dass dieses nicht durch ein "\n" ersetzt wird

rm .alt .neu

state=$(echo $updates_names)

sleep 10



So the cronjob runs every minute and every three hours for the updates and sends this information to theserver.

This is no issue with my solution. So you dont have to deal with that.

This was my first idea and had a solution that workes. However for multiple reasons the solution using the REST API is way better!

Any questions?

thanks for the answers but that’s just the long and complicated way. What i want is the simple transformation of the exec binding with the regex transformation. Do you know what i mean?

I am not a developer and therefore need a simple example to understand what does what.

This is the configuration of my exec thing:

The exec transformation is installed but I don’t know what to write there.
And that’s what’s coming out of it right now:
I just can’t do it with the transformation. I’ve read through all of this, but I just can’t figure it out.

Best regards

Please provide the output / returned string of your script otherwise no-one can help with the REGEX.

So from your initial post my understanding was that you would like to use the systeminfo binding either to get the remote values resp. to display the remote values but according to your latest post this seems not to be correct.

Sorry, of course you are right.

When the script is executed I get the following value back:
Of course, I would like to see this value as a “Number Item” in the return status.

What I get is this error message with the return value. I was looking for a solution here and actually this error message should not trigger at all.
The input value always remains empty and the input status is always only 255.
Only the time of the last execution is displayed correctly.

I hope the information makes it a little clearer. And yes, I also thought that I would then embed this value in the correct channel of the system info binding.
I think a number item is a number item and which binding I use it with shouldn’t matter, right?

I have now tried to do it with the exec transformation, but I fail miserably. There is an example in the documentation that shows exactly what I want.
But I just don’t know how to convert the determined value so that it is displayed correctly in openHAB.
For me, what it says is “Chinese”.

Exuse my bad english.

Best regards

instead of using

vcgencmd measure_temp


vcgencmd measure_temp | sed 's/temp=//' | sed "s/'C//"

This way only the temperature gets returned

This cannot be done directly. The Exec binding only allows the output Channel to be linked to a String Item. If you want to have the value stored in a Number Item you have to create a Rule to transfer updates from the String to the Number.

You should look at the SNMP binding as monitoring this sort of information from remote computers is the whole point of SNMP.

Thank you,
I’ve tried, that prevents the error message. Unfortunately, the end result remains the same.


I have already looked at the SNMP solution, but just to read the temperature I am busy with the configuration for 2 days.

The transformation of the output value should actually be the simplest method, but unfortunately neither in the documentation of the Exec binding nor in the documentation of the RegEx transformation there is no simple example of what actually does what.

This is the example in the RegEX Transformation documentation and that is exactly what I want.

What is the input string and what content must it have? Unfortunately, this is not written for “dummies”, you know what i mean?

In the end, it’s all about the content of this line in the Exec Thing. What must be in there so that the output value is transformed correctly?

The result that I have assembled from the RegEx documentation now looks like this.
The solution is certainly very simple, but unfortunately the documentation is not.

Best regards

I think the setup is not correct yet.
The exit status / Rueckgabestatus 255 indicates that there is a problem with the execution of a script / binary. Normally the exit status 0 indicates that everything is ok.

Message about VCHI Initialization failed means that the command does not run correct. See e.g.

The error message is only output in openHAB via the return value. I had already checked everything.
I get the 255 return status when I query the temperature with vcgencmd measure_temp.

I get the return status 0 when I measure the temperature with vcgencmd measure_temp | sed ‘s / temp = //’ | sed “s / 'C //” query and then strangely enough the error message also disappears in the return value.

[quote=“Smarthome-Creator, post:13, topic:106113, full:true”]
The error message is only output in openHAB via the return value. I had already checked everything.
I get the 255 return status when I query the temperature with vcgencmd measure_temp.
Am I right that you get the return status only when you run vcgencmd from within OpenHAB but not if you run the command on the command line ? On command line you can check return status by executing

echo $?

If this is the case and I have nearly no doubt that it is then the vcgencmd command is not executed corret resp. with the correct privileges. Keep in mind that you have different environment settings on the Linux console/shell compared to the openHAB exec environment.

I thing the error message of the first command is still there but gets lost because of piping the output from the first command through the sed command.
You may try something like this:
vcgencmd measure_temp 2>&1| sed ‘s/temp=//’ | sed “s/'C//”


will redirect the erorr message of the first command from STDERR to STDOUT.

And the return status is 0 because it is the return status of the sed command and not the return status of the vcgencmd.

After a lot of reading and searching I have now made it work.
The solution is very simple. Use sudo to issue the command and choose the correct transformation. Like this:

Then follow the example in the RegEx documentation and in the end everyone will be happy.

I now get the correct return value and can convert it to the return status using a rule and then link it to the system info binding.

Thanks for your help