Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • stustanet/temperature-daemon
  • roman/temperature-daemon
  • 007638/temperature-daemon
3 results
Show changes
Commits on Source (5)
default: default:
image: debian-python-build:v2 image: debian-build-python:bullseye
# Is performed before the scripts in the stages step # Is performed before the scripts in the stages step
before_script: before_script:
...@@ -16,12 +16,12 @@ before_script: ...@@ -16,12 +16,12 @@ before_script:
# Defines stages which are to be executed # Defines stages which are to be executed
stages: stages:
- build_buster - build_bullseye
- upload_to_repo - upload_to_repo
# Stage "build_buster" # Stage "build_bullseye"
build_buster: build_bullseye:
stage: build_buster stage: build_bullseye
script: script:
- apt update - apt update
- apt install -y python3-stdeb python-all - apt install -y python3-stdeb python-all
......
tempermonitor (2.1.1) bullseye; urgency=medium
* fix for python 3.11
-- Wolfgang Walter <wolfgang.walter@stusta.de> Sun, 06 Aug 2023 00:21:00 +0200
tempermonitor (2.1.0) bullseye; urgency=medium
* upgrade to bullseye
-- Michael Loipführer <ml@stusta.de> Fri, 12 Nov 2021 18:40:18 +0200
tempermonitor (2.0.6) buster; urgency=medium
* fix missing module
-- Michael Loipführer <ml@stusta.de> Thu, 24 Apr 2020 18:40:18 +0200
tempermonitor (2.0.5) buster; urgency=medium tempermonitor (2.0.5) buster; urgency=medium
* fix missing module * fix missing module
......
from setuptools import setup from setuptools import setup
VERSION = '2.0.5' VERSION = '2.0.6'
def readme(): def readme():
......
...@@ -10,11 +10,10 @@ class Collectd(Plugin): ...@@ -10,11 +10,10 @@ class Collectd(Plugin):
""" """
def __init__(self, monitor): def __init__(self, monitor):
self.loop = asyncio.get_event_loop()
self.config = monitor.config self.config = monitor.config
self.path = self.config['collectd']['socketpath'] self.path = self.config['collectd']['socketpath']
self._reader, self._writer = (None, None) self._reader, self._writer = (None, None)
self.loop.run_until_complete(self.reconnect()) asyncio.run(self.reconnect())
self.monitor = monitor self.monitor = monitor
...@@ -28,8 +27,7 @@ class Collectd(Plugin): ...@@ -28,8 +27,7 @@ class Collectd(Plugin):
self._writer.close() self._writer.close()
self._reader, self._writer = await asyncio.open_unix_connection( self._reader, self._writer = await asyncio.open_unix_connection(
path=self.path, path=self.path)
loop=self.loop)
async def _send(self, identifier, interval, timestamp, value): async def _send(self, identifier, interval, timestamp, value):
""" """
......
import re
import asyncio import asyncio
from prometheus_client import start_http_server, Gauge from prometheus_client import start_http_server, Gauge
from . import Plugin from . import Plugin
stats_name_re = re.compile(r'^temperature-(?P<group>\w+)-(?P<type>\w+)$')
class Prometheus(Plugin): class Prometheus(Plugin):
def __init__(self, monitor): def __init__(self, monitor):
...@@ -29,20 +32,15 @@ class Prometheus(Plugin): ...@@ -29,20 +32,15 @@ class Prometheus(Plugin):
) )
print("started prometheus http server") print("started prometheus http server")
async def update_sensor_values(self, sensor):
"""
update
"""
print("updating prometheus metrics")
self.sensor_metrics.labels(sensor=sensor.name).set(sensor.temperature)
async def send_stats_graph(self, graph, stattype, stattime, statval): async def send_stats_graph(self, graph, stattype, stattime, statval):
""" """
to be called as a plugin callback to export aggregated measurements to be called as a plugin callback to export aggregated measurements
""" """
label_group = stattype.split("-")[1] m = stats_name_re.match(stattype)
label_type = stattype.split("-")[2] if not m:
self.aggregated_metrics.labels(group=label_group, type=label_type).set(statval) return
self.aggregated_metrics.labels(group=m.group('group'), type=m.group('type')).set(statval)
async def sensor_update(self): async def sensor_update(self):
""" """
...@@ -50,4 +48,4 @@ class Prometheus(Plugin): ...@@ -50,4 +48,4 @@ class Prometheus(Plugin):
""" """
for sensor in self.monitor.sensors.values(): for sensor in self.monitor.sensors.values():
if sensor.valid: if sensor.valid:
await self.update_sensor_values(sensor) self.sensor_metrics.labels(sensor=sensor.name).set(sensor.temperature)
...@@ -104,7 +104,7 @@ class Warnings(Plugin): ...@@ -104,7 +104,7 @@ class Warnings(Plugin):
tempdiff = ceil_avg - floor_avg tempdiff = ceil_avg - floor_avg
await self.monitor.call_plugin( await self.monitor.call_plugin(
"send_stats_graph", graph="stats", "send_stats_graph", graph="stats",
stattype="temperature-floor_ceil_diff", stattime=now, statval=tempdiff) stattype="temperature-floor_ceil-diff", stattime=now, statval=tempdiff)
print("floor: min {:05.2f} max {:05.2f} avg {:05.2f} var {:05.2f}".format( print("floor: min {:05.2f} max {:05.2f} avg {:05.2f} var {:05.2f}".format(
floor_min, floor_max, floor_avg, floor_var)) floor_min, floor_max, floor_avg, floor_var))
......