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 (18)
Showing with 259 additions and 26 deletions
......@@ -5,3 +5,4 @@ __pycache__
/venv/
/.mypy_cache
/.idea
/*.egg-info
default:
image: debian-build-python:bullseye
# Is performed before the scripts in the stages step
before_script:
- source /etc/profile
# Load the ssh private key from the gitlab build variables to enable dupload
# to connect to the repo via scp
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan repo.stusta.mhn.de >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# Defines stages which are to be executed
stages:
- build_bullseye
- upload_to_repo
# Stage "build_bullseye"
build_bullseye:
stage: build_bullseye
script:
- apt update
- apt install -y python3-stdeb python-all
- dpkg-buildpackage -us -uc
- mkdir -p build/
- mv ../tempermonitor*.deb build/
- mv ../tempermonitor*.changes build/
- mv ../tempermonitor*.tar.gz build/
- mv ../tempermonitor*.dsc build/
- mv ../tempermonitor*.buildinfo build/
# The files which are to be made available in GitLab
artifacts:
paths:
- build/*
upload_to_repo:
stage: upload_to_repo
script:
- echo "Uploading debian package to ssn repository"
- ssh repo@repo.stusta.mhn.de "echo SSH-Connection working"
- dupload -f -t ssn_repo build/tempermonitor*.changes
when: manual
only:
- master
#!/usr/bin/env sh
rm -rf deb_dist tempermonitor.egg-info dist
python3 setup.py --command-packages=stdeb.command bdist_deb
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
* fix missing module
-- Michael Loipführer <ml@stusta.de> Thu, 23 Apr 2020 23:40:18 +0200
tempermonitor (2.0.4) buster; urgency=medium
* improve plugin handling
-- Michael Loipführer <ml@stusta.de> Thu, 23 Apr 2020 23:30:18 +0200
tempermonitor (2.0.3) buster; urgency=medium
* rename config file
-- Michael Loipführer <ml@stusta.de> Thu, 23 Apr 2020 23:10:18 +0200
tempermonitor (2.0.2) buster; urgency=medium
* change main function
-- Michael Loipführer <ml@stusta.de> Thu, 23 Apr 2020 23:00:18 +0200
tempermonitor (2.0.1) buster; urgency=medium
* package renaming
-- Michael Loipführer <ml@stusta.de> Thu, 23 Apr 2020 22:55:18 +0200
tempermonitor (2.0.0) buster; urgency=medium
* Initial debian release
-- Michael Loipführer <ml@stusta.de> Thu, 23 Apr 2020 19:15:18 +0200
11
Source: tempermonitor
Maintainer: Michael Loipführer <ml@stusta.de>
Section: python
Priority: optional
Build-Depends: python3-setuptools, python3-all, debhelper (>= 11)
Standards-Version: 4.2.1
Package: tempermonitor
Homepage: https://gitlab.stusta.de/stustanet/temperature-daemon
Vcs-Browser: https://gitlab.stusta.de/stustanet/temperature-daemon
Vcs-Git: https://gitlab.stusta.de/stustanet/temperature-daemon.git
Architecture: any
Depends: ${misc:Depends}, ${python3:Depends}
Description: Tempermonitor sensor temperature reading deamon
This is the StuStaNet Temperature Monitoring System.
.
# Hardware Setup and Protocol
.
The temperature sensors are ds18x20 sensors connected via the onewire protocol
to an esp32. The esp is connected via usb-serial to the host computer.
This sends roughly every second a measurement value from one of the sensors.
After a complete round it sends an empty line.
.
# Dependencies
.
pyserial-asyncio. And >=python3.5.
.
# Architecture
The communications is done within the temperature_daemon.py file as well as
error handling for the sensor measurements.
It will then call functions in plugins to do the majority of the work.
.
The plugins are located in the `plugins` folder.
.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: tempermonitor
Source: gitlab.stusta.de/stustanet/temperature-daemon
License: GPL
etc/* /etc/
\ No newline at end of file
#!/usr/bin/make -f
# This file was automatically generated by stdeb 0.9.0 at
# Thu, 23 Apr 2020 19:15:18 +0200
%:
dh $@ --with python3 --buildsystem=python_distutils
override_dh_auto_clean:
python3 setup.py clean -a
find . -name \*.pyc -exec rm {} \;
override_dh_auto_build:
python3 setup.py build --force
override_dh_auto_install:
python3 setup.py install --force --root=debian/tempermonitor --no-compile -O0 --install-layout=deb
override_dh_python2:
dh_python2 --no-guessing-versions
extend-diff-ignore="\.egg-info$"
\ No newline at end of file
......@@ -3,8 +3,7 @@ Description=SSN temperature monitoring service
After=network.target
[Service]
WorkingDirectory=/usr/local/bin/temperature-daemonv2/
ExecStart=/usr/local/bin/temperature-daemonv2/venv/bin/python /usr/local/bin/temperature-daemonv2/tempermonitor.py tempermon_hugin.ini
ExecStart=/usr/bin/python3 -m tempermonitor
Restart=on-failure
[Install]
......
[general]
plugins = prometheus,mail,warnings
plugins=prometheus,mail,warnings
[serial]
#port=/dev/ttyUSB0
port=/tmp/temperature_pts
baudrate=115200
timeout=100
[collectd]
#socketpath=/var/run/collectd-unixsock
socketpath=/tmp/collectd_sock
hostname=hugin
interval=1
......@@ -16,6 +14,7 @@ interval=1
[prometheus]
sensor_metric_name=ssn_container_temperature
aggregated_metric_name=ssn_container_temperature_agg
address=localhost
port=9199
[mail]
......@@ -32,10 +31,3 @@ min_ceiling_warning=35
floor_ceiling_diff=15
ceiling_warning_level=40
[testsensor]
name=Test
calibration=5
[sensortest]
name=Test2
calibration=5
File moved
from setuptools import setup
VERSION = '2.0.6'
def readme():
with open('README.md') as f:
return f.read()
setup(
name='tempermonitor',
version=VERSION,
description='Tempermonitor sensor temperature reading deamon',
long_description=readme(),
url='http://gitlab.stusta.de/stustanet/temperature-daemon',
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.7',
'Operating System :: POSIX :: Linux'
],
install_requires=[
'asyncio',
'pyserial-asyncio',
'prometheus_client'
],
license='MIT',
packages=[
'tempermonitor',
'tempermonitor.plugins'
],
include_package_data=True,
zip_safe=False
)
[tempermonitor]
Depends: python3-serial-asyncio python3-prometheus-client
Suite: buster
from tempermonitor.tempermonitor import main
main()
from abc import ABCMeta
PLUGINS = dict()
class PluginMeta(ABCMeta):
"""
Metaclass for available container backends.
"""
def __init__(cls, name, bases, classdict):
super().__init__(name, bases, classdict)
PLUGINS[cls.plugin_name()] = cls
class Plugin(metaclass=PluginMeta):
@classmethod
def plugin_name(cls):
return cls.__name__.lower()
@property
def name(self):
return self.__class__.__name__.lower()
# import all plugins so metaclass can populare PLUGINS dict
from . import collectd, mail, prometheus, warnings
import asyncio
import time
from . import Plugin
def init(monitor):
return PluginCollectd(monitor)
class PluginCollectd:
class Collectd(Plugin):
"""
Implements a super simple collectd interface for only sending temperature data
"""
def __init__(self, monitor):
self.loop = asyncio.get_event_loop()
self.config = monitor.config
self.path = self.config['collectd']['socketpath']
self._reader, self._writer = (None, None)
self.loop.run_until_complete(self.reconnect())
asyncio.run(self.reconnect())
self.monitor = monitor
......@@ -30,8 +27,7 @@ class PluginCollectd:
self._writer.close()
self._reader, self._writer = await asyncio.open_unix_connection(
path=self.path,
loop=self.loop)
path=self.path)
async def _send(self, identifier, interval, timestamp, value):
"""
......
......@@ -3,6 +3,8 @@ from email.mime.text import MIMEText
from email.utils import formatdate
import smtplib
from . import Plugin
UNKNOWN_SENSOR_SUBJECT = "WARNING: Unconfigured Sensor ID: {owid}"
UNKNOWN_SENSOR_BODY = """Hello Guys,
......@@ -89,14 +91,7 @@ with love,
Temperator"""
def init(monitor):
"""
Plugin initialization method to be called from the outside
"""
return PluginMail(monitor)
class PluginMail:
class Mail(Plugin):
"""
Handle all the mail sending stuff
"""
......