Sytems info - I don't get it

All,

I would like to check the CPU load of openhab2 on my Raspberry.

I am using systeminfo, so I tried:

Number CPU_openhab   		"CPU OpenHAB xxx[%.1f%%]"	<cpu>		(G_Numbers)			{channel="systeminfo:computer:Homer:process#load"}
Number MEM_openhab   		"MEM OpenHAB xxx[%.1f%%]"	<cpu>		(G_Numbers)			{channel="systeminfo:computer:Homer:process#used"}
String Proc_Name		"Prozess-Name [%s]"		<cpu>		(G_Numbers)			{channel="systeminfo:computer:Homer:process#name"}
String Proc_Path		"Prozess-Pfad [%s]"		<cpu>		(G_Numbers)			{channel="systeminfo:computer:Homer:process#path"}

Do I need to specify the Name (e.g. karaf) and the path (e.g. /usr/share/openhab2/runtime/bin/karaf) to get the binding to return the information about karaf / openhab2 ?

Sorry for this possibly stupid question.

What are you getting displayed now. Do you get any errors in the log?
As I understand you don’t need to specify any parh, however you need a (self-discovered?) thing representing the computer you want to get the information from. In your case that should be “homer”.

@opus thanks for your response.

Another item works just fine:

Number uptime "Laufzeit xxx[%s]" {channel="systeminfo:computer:Homer:cpu#uptime"}

No error messages so far, only the Numbers (items CPU_openhab and MEM_openhab) without data cannot be stored by persistence (UnDefType)
Actually my main question is, do I need to set the string Proc_Name to karaf?
(so to run somthing like “sudo ps -fC karaf” through the systeminfo binding?)

At the moment I have to say: I don’t think so.
Since I’m not (actually ) using this binding, I can’tell say for sure. I will check that when back on my system (might take until tomorrow evening ).

Don’t worry - no rush.
Thanks for your help.

I was able to get data, however with different settings:

Number CPU_openhab      "CPU OpenHAB xxx[%.1f%%]" <cpu>   (G_Numbers)     {channel="systeminfo:computer:Homeri:**cpu**#load"}
Number MEM_openhab      "MEM OpenHAB xxx[%.1f%%]" <cpu>   (G_Numbers)     {channel="systeminfo:computer:Homeri:**memory**#used"}

I guessed you were looking for the CPU-Load, not the load a process causes, the same goes for the total memory used.
The process information needs the process-ID (as stated in documentation, however the example item definitions are missing the process-ID!). ATM I have no idea how to set it correctly.

Not karaf. You want to look for a process named “java” that is owned by the openhab user.

I don’t use this binding so don’t know if that is strictly possible. With any luck, there is only one Java process on the machine.

I didn’t mention, mine is a Raspi2.
I think the problem was solely caused by the use of process channels, which would need the Process ID. As stated a explicit syntax how to state that isn’t published.

All,

thanks for all your help.
Actually I get the (system’s) CPU load within another item, but I would like to monitor the openhab process (according to Rich it must be mainly the java process).

@opus:
Right, I just saw the pid briefly mentioned in the documentation as well (I just missed it, because it’s not mentioned in the item examples - as you stated.

So that’s actually my issue: How to find out and put the pid correctly into OH to monitor the process performance?

That is going to be a challenge because every time OH starts it gets a new PID. Since you have to supply the PID as part of the Thing definition I think this might be a case where you can’t make this work very easily without having a way to discover the pid and then edit the Thing every time OH restarts.

@rlkoshak you are only partly correct.
Yes, the PID can not be set in the Item definition, it has to be set in the channel definition of the Thing. However, this can be updated during runtime!
Click on the configure button (pencil) of the desired channel and a window “Configue Channel” comes up. The channels in the group “Process” have the posibility to set the priority and the PID.
Just found that by “clicking around”.:wink:

I had no idea it was possible to change a Thing or Channel config at runtime. That’s really cool. I don’t use this binding so my knowledge is limited.

In that case, one could write a shell script to run ps -elf | grep openhab | grep java | <sed, awk, cut, ???> to extract the PID in a System started Rule. Then presumably one could set the PID using the REST API? Or are you saying that one could link an Item to a channel in Process and just postUpdate the PID to that?

Sounds pretty cool.

I’m saying nothing more then posted above. I just found that and I have never changed a Thing during runtime so far.
I was using this binding only because of this question!

pgrep -f openhab2.*java :wink:

It might be possible to update it using the REST API, but am unsure. You would have to look into using /things/{thingUID}/config for it.

1 Like

Thanks to all of you - that’s quite a bit to digest.
Since I have a pretty stable system with almost all I need, I do not restart very often anymore.

Changing the PID to the java PID in PaperUI according to @Benjy the name of the item (systeminfo:computer:Homer:process#name) changes to “java” (events-log).

So I guess specifying java in the name (e.g. by rule) makes OH to look itself for the PID with the process name “java”!?

However, both systeminfo:computer:Homer:process#load and systeminfo:computer:Homer:process#used are not populated with data.

Anyone with a comment about this?
Why don’t I get the load and used populated with data?

Maybe some other users might be interested in updating the PID at startup…
So, this is part of my startup rule (freshly baked :smile:):

rule "System startup"
when
    System started
then
...............................
        //update systemstatus thing with openhab PID
        val openhab_pid = executeCommandLine('pgrep -f openhab2.*java',1000)
        logWarn('DEBUG','openhab_pid = [' + openhab_pid + ']')
        val systemstatus_thing = sendHttpGetRequest('http://127.0.0.1:8080/rest/things/systeminfo%3Acomputer%3AopenHAB')
        sendHttpPutRequest('http://127.0.0.1:8080/rest/things/systeminfo%3Acomputer%3AopenHAB','application/json',systemstatus_thing.replaceAll('"pid":([0-9]+)','"pid":' + openhab_pid))
................................
end

where systeminfo:computer:openHAB is the UID for my systemstatus thing

1 Like