StateFS replacement for stats

With StateFS deprecation, would be great to know how the same statistics can be gathered in the system. Interest stems from collectd which is using stateFS for several readouts. As collectd is C daemon, I am looking for something that can be read out from pure C and available for regular users, not root.

Readouts I am interested in:

  • /run/state/namespaces/Battery/

    • ChargePercentage, Capacity, Current, Energy, Power, Temperature, TimeUntilFull, TimeUntilLow, Voltage
  • /run/state/namespaces/Bluetooth/

    • Connected, Enabled, Visible
  • /run/state/namespaces/Cellular/

    • Technology, SignalStrength
  • /run/state/namespaces/Internet/

    • NetworkState, NetworkType, SignalStrength

Whether it is possible to use StateFS on 3.4.0 and later releases, I donā€™t know.

3 Likes

Iā€™ve been using those via ContextProperty (in C++). I have no idea, if that is still supported though: https://nheko.im/nheko-reborn/konheko/-/blob/master/src/sync.cpp#L22

1 Like

i am the developer of batterybuddy, and i tried to use statefs only to found out that the ā€˜filesā€™ there donā€™t update when their contents get updated. that is, i canā€™t monitor the file for modification, but i have to constantly re-read the file in order to spot the changes. i guess this behavior is inherited from /proc and is ultimately caused by crappy aosp implementation. if it canā€™t be relied upon - thanks sony and qualcomm i guess - it should be removed, or fixed, or replaced with something that worksā€¦ iā€™m not saying sony should be ditched, but a competitor would be nice. they wonā€™t care anyway.

another piece of art is flashlight; on xa2 it involves gstreamer, which means itā€™s requesting a 1x1 px video with the led on or something. back on jolla1 it was simply a file in /proc iircā€¦ with cumbersome platform there is only so much the sailors can doā€¦

1 Like

For all the drawbacks in terms of not notifying the change, stateFS allows to use plain C daemons to query system state. Thatā€™s exactly what collectd has been doing for years. In this respect, Qt & C++ would not be desirable ā€œsolutionsā€, unfortunately.