diff --git a/tempermon.ini b/tempermon.ini index 2851b7320a4c4d81344a6cbe74aeacde22685995..6e98a68c14c949cc041419f2e394c7526fcc923b 100644 --- a/tempermon.ini +++ b/tempermon.ini @@ -1,11 +1,14 @@ [serial] -port=/dev/ttyUSB0 +#port=/dev/ttyUSB0 +port=/tmp/temperature_pts baudrate=115200 timeout=100 [collectd] -socketpath=/var/run/collectd-unixsock +#socketpath=/var/run/collectd-unixsock +socketpath=/tmp/collectd_sock hostname=hugin +interval=1 [mail] from=Temperman <root@temperator.stusta.de> @@ -13,6 +16,19 @@ to=jw@stusta.de,markus.hefele@stusta.de to_urgent=jw@stusta.de,markus.hefele@stusta.de min_delay_between_messages=3600 +[warning] +floor_sensors=Test +ceiling_sensors=Test2 + +min_ceiling_warning=35 +floor_ceiling_diff=15 +ceiling_warning_level=40 + + [testsensor] name=Test calibration=5 + +[sensortest] +name=Test2 +calibration=5 diff --git a/test/collectdmock.py b/test/collectdmock.py new file mode 100755 index 0000000000000000000000000000000000000000..9f56073436308622d54f5e9674e963322ee253b0 --- /dev/null +++ b/test/collectdmock.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys + +for line in sys.stdin: + print("Ack") + sys.stdout.flush() diff --git a/test/run_tests.sh b/test/run_tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..72251a84c0053976cdd79bd8ce003ecf8cab9ac2 --- /dev/null +++ b/test/run_tests.sh @@ -0,0 +1,5 @@ +# IMPORTANT: Set the config to use the right socket path + +socat -d PTY,link=/tmp/temperature_pts,echo=0 "EXEC:python3 test.py ...,pty,raw",echo=0 & +socat UNIX-LISTEN:/tmp/collectd_sock,fork EXEC:"python3 collectdmock.py" + diff --git a/test/test.py b/test/test.py new file mode 100755 index 0000000000000000000000000000000000000000..fce72a6d144738c583cabdb118538ac38a268936 --- /dev/null +++ b/test/test.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +import random +import time +import sys + +delay = 0.1 + +while True: + for _ in range(3): + print("testsensor {}".format(random.random() * 40)) + print("sensortest {}".format(random.random() * 40)) + print() + time.sleep(delay) + + print("Sensor Error test", file=sys.stderr) + print("testsensor {}".format(9001)) + print("sensortest {}".format(random.random() * 40)) + print() + time.sleep(delay) + + + for _ in range(3): + print("testsensor {}".format(random.random() * 40)) + print("sensortest {}".format(random.random() * 40)) + print() + time.sleep(delay) + + print("Missing sensor test", file=sys.stderr) + print("sensortest {}".format(random.random() * 40)) + print() + time.sleep(delay) + + for _ in range(3): + print("testsensor {}".format(random.random() * 40)) + print("sensortest {}".format(random.random() * 40)) + print() + time.sleep(delay) + + print("Extra sensor test", file=sys.stderr) + print("idonotexist {}".format(random.random() * 40)) + print("testsensor {}".format(random.random() * 40)) + print("sensortest {}".format(random.random() * 40)) + print() + time.sleep(delay) + + + for _ in range(3): + print("testsensor {}".format(random.random() * 40)) + print("sensortest {}".format(random.random() * 40)) + print() + time.sleep(delay) + + print("Too Hot Test", file=sys.stderr) + print("testsensor {}".format(45)) + print("sensortest {}".format(40)) + print() + time.sleep(delay) + + for _ in range(3): + print("testsensor {}".format(random.random() * 40)) + print("sensortest {}".format(random.random() * 40)) + print() + time.sleep(delay) + + print("high diff test", file=sys.stderr) + print("testsensor {}".format(45)) + print("sensortest {}".format(25)) + print() + time.sleep(delay)