/sensoric

Logs systems and sensor values to a time series database such as influxdb, prometheus or victoria-metrics.

Primary LanguagePythonApache License 2.0Apache-2.0

Sensoric

Collects system and sensor data which is then submitted to a time series database such as InfluxDB, and victoria-metrics.

Requirements

  • python3-influxdb
  • python3-psutil

Supported modules

  • cpu_sensor:
  • fritzbox_sensor: network traffic (bytes sent, bytes received)
  • memory_sensor: memory consumption
  • weather_sensor: provide temperature and humidity for the provided locations

Environment variables

Required

  • SENSORIC_DB_HOST: IP address of the influxdb / victoria metrics host
  • SENSORIC_DB_PORT: port of the influxdb / victoria metrics host
  • SENSORIC_DB_NAME: name of the time series database
  • SENSORIC_BATCH_SIZE: number of batches to collect before sending them to the time series database

Disk sensor

  • SENSORIC_DISKS: space separated list of partitions to watch for disk usage

Fritzbox sensor

  • SENSORIC_FRITZ_HOST: IP address of the Fritz!Box
  • SENSORIC_FRITZ_PORT: port of the Fritz!Box

Weather sensor

  • SENSORIC_WEATHER: a space sparated list of locations. Spaces within location names need to be replaced with %20 (e.g., Domat Ems > Domat%20Ems)

Usage:

Call sensoric-daemon.py with the list of sensors to use as outlined below.

export SENSORIC_DB_HOST=192.168.0.120
export SENSORIC_DB_PORT=8999
export SENSORIC_DB_NAME=sensoric
export SENSORIC_FRITZ_HOST=192.168.0.200
python3 sensoric-daemon.py cpu_sensor memory_sensor network_sensor disk_sensor fritzbox_sensor

systemd

You can also start sensoric-daemon from systemd:

Unit]
Description=Sensoric daemon service

[Service]
Type=simple
WorkingDirectory=/srv/sensors
Environment=SENSORIC_DB_HOST=192.168.0.120 SENSORIC_DB_PORT=8999 SENSORIC_DB_NAME=sensoric SENSORIC_BATCH_SIZE=1 SENSORIC_DISKS="sda mmcblk1" SENSORIC_FRITZ_HOST=192.168.0.200 SENSORIC_FRITZ_PORT=49000
ExecStart=/srv/sensors/sensoric-daemon.py cpu_sensor memory_sensor network_sensor disk_sensor power_consumption_sensor
Restart=always
User=sensors

[Install]
WantedBy=multi-user.target
Alias=sensor.service