Hi All,
I am using SIGAR to monitor the System information of my Openhab Host.
But i got another Linux device (Rpi) which i want to be monitored within openhab.
Due to limited memory of a raspberry pi, i do not want to install openhab twice.
Required informations from my slave:
Uptime, CPU Load (Percentage) Ram usage, in % and in MB
What about a cronjob with SIGAR and sending the values to OpenHAB.
Install mosquitto on your openHAB server and setup an MQTT broker. Then install the mosquitto client libraries on your Pi (very lightweight) and write a script to publish your SIGAR readings to MQTT topics. Then setup openHAB to subscribe to your SIGAR topics and voila - you have your SIGAR data in openHAB.
You donāt have to usemosquitto on the RPi, you could use any number of MQTT libraries for other languages.
Thanks,
i have a few questions: is it possible to send the Systems formatted uptime (like SIGAR) over mqtt?
How do i start the script, if my system starts (create a bash script under init.d or similar?)
is it possible to send the Systems formatted uptime (like SIGAR) over mqtt?
actually psutil library (used by my tool) provides boot_time parameter that is unix timestamp of moment when box was booted. It isnāt supported now by my tool but itās easy to add. But I have to think how add formatted representation of uptime parameter
How do i start the script, if my system starts (create a bash script under init.d or similar?)
I use /etc/rc.local for it (and other similar scripts)
Hey,
Why is there a different percentage for the ram usage, than it should be, based on the RAM Usage in megabytes?
By the way: your output is showing bytes, so you need to transform the item, dividing by 1000000
Iāve checked sources of psutil and found that percents are calculated as
avail = free + buffers + cached
used = total - free
percent = usage_percent((total - avail), total, _round=1)
So in your case (of course if all 4 parameters are get at the same moment of time)
total = 971
free = 579
used = 392 (40%)
avail = 85% * 971 = 825
buffers+cached = avail-free=825-579=246
By the way: your output is showing bytes, so you need to transform the item, dividing by 1000000
Iām still not sure that formatting of output data is a task for my tool. Need to think more about it
Iāve updated branch with new feature (not documented yet)
Now values could be formatted using templates
Please install jinja2 pip module and after you can use
virtual_memory/free/{{x|MB}} - to get free RAM in MB
boot_time/{{x|uptime}} - boot time formatted as uptime
āDBuptimeā does not work at the moment.
It is a Dashing Cotrolpanel, the PID is stored in a file ( /dashing/tmp/pids/thin.pid )
The process is called thin server
How can i get the uptime of a certain Process within OpenHAB?
processes/pid[|path|to|pid|file.pid]/create_time/{{x|uptime}} - to get uptime of process using .pid file or
processes/name[name*pattern]/create_time/{{x|uptime}} - using pattern for process name
also there is an option (see Schedule section of README) to use more pretty looking MQTT topics for such ugly task names
The best feature for me (Uptime of certain process) is not working for me.
this ist my output (i use both formats), when launching the application:
./psmqtt.sh Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "psmqtt.py", line 181, in run self.s.run() File "/usr/lib/python2.7/sched.py", line 117, in run action(*argument) File "psmqtt.py", line 146, in on_timer run_task(task, task) File "psmqtt.py", line 50, in run_task if task.startswith(topic_prefix): AttributeError: 'dict' object has no attribute 'startswith'
Your configuration is a bit wrong (dict is an element of list) but I think it could be convinient in some cases so now it should be supported by parser.
Please update from github for this fix but please note that now default prefix for mqtt topic is /psmqtt/COMPUTER_NAME (to avoid conflict if several computers have psmqtt run)
Looks like the default folder when you run psmqtt.py is not same where psmqtt.py is located and thatās why it cannot locate psmqtt.conf. I can adjust the code to be smarter but without code changes, you have two options:
change default folder to the psmqtt before running psmqtt.py
set full path for the psqmtt.conf file to the PSMQTTCONFIG environment variable
@eschava
I installed this yesterday and I am trying to get the uptime without the formatting
Also
These is no CPU temperature information, is that something you could add?
@vzorglub
to get uptime in seconds please use āboot_timeā request
CPU temperature information was added in recent versions of psutil library and not implemented yet in psmqtt. Iāll add support for it at the nearest time