Lm_sensors for ubuntu core

I am working on an amd64 server built using ubuntu core 18 (maybe 20 in near future) as OS. These servers would be deployed on the field. I need to periodically get hardware telemetry from each server (things like CPU temperature, fan health, etc). lm_sensors provides all this data on a regular Ubuntu server. However, I could not find a snap package for the same. Found package such as sensors unity, but they are geared towards desktop. What I need is a barebone sensors utility that will get fired periodically and send output upstream.

Thought of writing a python script to accomplish the same, but got stuck at unable to create venv.

If needed I am willing to write code. Would highly appreciate if someone could point me in the right direction to get through above.

If you use Ubuntu Core you will have to package your project as a snap, here is a quickly thrown together snapcraft.yaml to start from:

name: sensors
base: core20
version: '0.1'
summary: lm-sensors as a snap
description: |
  this snap ships lm_sensors

grade: stable
confinement: strict

apps:
  sensors:
    command: usr/bin/sensors
    plugs:
      - system-observe
      - hardware-observe

parts:
  lm-sensors:
    plugin: nil
    stage-packages:
      - lm-sensors

that will give you the “sensors” command in a snap package … to do something more with it, you can just add another part to the snapcraft.yaml that for example ships your python script … (and to execute that, just add another apps: entry) … do not forget to connect the interfaces using snap connect ...

1 Like