Sys2mqtt: send system metrics from your computer to MQTT

Intro

What if you could detect if a user is idle or actively using a computer ?

I have seen posts about placing a weight/pressure sensor under a chair, etc… And I did even consider the option. I am using various sensors (PIR, mWave, etc…) but those are not perfects and there are cases where I simply would need OH to know whether I am at my desk working or not.

What if the light would no longer go off when I work ?
What if the light would always turn on into “work” mode when I do work ?

I have seen some tools that are deprecated and/or Windows only so I decided to investidate a new option and wrote sys2mqtt.

What is sys2mqtt

tldr: very light weight (cpu and memory) agent that runs on your machine and sends metrics to an MQTT Broker.

The project is still young and does not countain many “probes” (I started yesterday) but I have a working version already and it solves one of the main problem I had on my list: knowing if a user/machine is “idle”.

sys2mqtt is a utility writte in Rust. I have been testing it on MacOS. It should work as is or with little efforts on Linux/Windows as well. I would love to hear some feedback if you tested that.

Getting the binary to do the job was surprinsingly not what took the longest. Instead, it took me a few hours to figure out MacOS Sequoia’s requirements to run the binary as an Agent.

The easiest to install is, as mentioned in the installation guide, to use the installer. This will fetch you a binary build that is signed already. if you install via source or using cargo install (which is possible), the Agent will NOT work due to the lack of information in the binary to allow MacOS accessing the local network.

I added a write-up explaining the usage with OpenHab. If you are using Z2M or MQTT, you will find it rather straight forward.

FAQ

Can I send MQTT commands to control my machine ? Say turn it off ?

No, not at the moment.

You say I should run a binary you built and let it run on my machine ?

Yeah I know. If you doubt, don’t run it :slight_smile:
You can also check the code and build it and sign it yourself if you wish.

What if I use some of those mouse jiggler ?

I am not familiar with those but I guess that, if they work well, you will be seen as not idle !

What is the point of the heart_beat ?

Say you are active and turn off your machine. Nothing will now change user_idle to idle any more. Unless you use the heart_beat to turn on a switch and auto expire if after a period that is longer than the heart_beat duration. This way, you know when sys2mqtt is Offline/Online and you may react appropriately.