<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hallo Ruppert<br>
</p>
<div class="moz-cite-prefix">On 08.10.22 13:42, Rupert Schöttler
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:a287af63-967b-b803-4803-2521aff6d0c5@gmx.de"><br>
<br>
- Wenn ich das Pythonscript richtig verstehe, produziert es je
Aufruf
<br>
(alle 60 sec aus vzlogger heraus) 2 Zeilen, weil 2x "print".
<br>
Möglicherweise verwirrt das vzlogger.
<br>
</blockquote>
Das dachte ich auch schon. Deswegen habe ich das zweite print
auskommentiert. Ändert aber nichts.<br>
<blockquote type="cite"
cite="mid:a287af63-967b-b803-4803-2521aff6d0c5@gmx.de">
<br>
- Aggmode und duplicates macht in diesem Setting m.E. keinen Sinn.
Und
<br>
sind es nicht genau die sich wiederholenden 2 und 3 Impulse je
Minute,
<br>
die verloren gehen??
<br>
</blockquote>
<p>Ich habe die Eintröge aus dem syslog den Einträgen in der
Datenbank gegenübergestellt. Du hast recht.</p>
<p> </p>
<table cellspacing="0" border="0">
<colgroup width="137"></colgroup> <colgroup width="121"></colgroup>
<colgroup width="128"></colgroup> <colgroup width="46"></colgroup>
<colgroup width="49"></colgroup> <colgroup width="85"></colgroup>
<colgroup width="171"></colgroup> <colgroup width="103"></colgroup>
<colgroup width="48"></colgroup> <tbody>
<tr>
<td height="17" align="left"><i>/var/log/syslog (Python-Skipt)<br>
</i></td>
<td align="left"><br>
</td>
<td align="left"><br>
</td>
<td align="left"><br>
</td>
<td align="left"><br>
</td>
<td align="left"><br>
</td>
<td align="left">mysql</td>
<td align="left"><br>
</td>
<td align="left"><br>
</td>
</tr>
<tr>
<td style="border-top: 1px solid #000000; border-left: 1px
solid #000000" height="37" align="left">Timestam Syslog</td>
<td style="border-top: 1px solid #000000" align="left">Timestamp
Counter (Ticks)</td>
<td style="border-top: 1px solid #000000" align="left">Timestamp
Counter (Date)</td>
<td style="border-top: 1px solid #000000" align="left">Delta
Count</td>
<td style="border-top: 1px solid #000000; border-right: 1px
solid #000000" align="left">Total Count</td>
<td align="left"><br>
</td>
<td style="border-top: 1px solid #000000; border-left: 1px
solid #000000" align="left">Timestamp (Date)</td>
<td style="border-top: 1px solid #000000" align="left">Timestamp
(Ticks)</td>
<td style="border-top: 1px solid #000000; border-right: 1px
solid #000000" align="left">Count</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:19:22</td>
<td align="left"> 1665224362</td>
<td align="right">08.10.2022 10:19:22</td>
<td align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">207</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:19:22.0000</td>
<td align="right">1665224362000</td>
<td style="border-right: 1px solid #000000" align="right">2</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:20:23</td>
<td align="left"> 1665224423</td>
<td align="right">08.10.2022 10:20:23</td>
<td bgcolor="#FFFF00" align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">209</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:21:25</td>
<td align="left"> 1665224485</td>
<td align="right">08.10.2022 10:21:25</td>
<td align="right">3</td>
<td style="border-right: 1px solid #000000" align="right">212</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:21:25.0000</td>
<td align="right">1665224485000</td>
<td style="border-right: 1px solid #000000" align="right">3</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:22:27</td>
<td align="left"> 1665224547</td>
<td align="right">08.10.2022 10:22:27</td>
<td bgcolor="#FFFF00" align="right">3</td>
<td style="border-right: 1px solid #000000" align="right">215</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:23:32</td>
<td align="left"> 1665224612</td>
<td align="right">08.10.2022 10:23:32</td>
<td bgcolor="#FFFF00" align="right">3</td>
<td style="border-right: 1px solid #000000" align="right">218</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:24:33</td>
<td align="left"> 1665224673</td>
<td align="right">08.10.2022 10:24:33</td>
<td bgcolor="#FFFF00" align="right">3</td>
<td style="border-right: 1px solid #000000" align="right">221</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:25:35</td>
<td align="left"> 1665224735</td>
<td align="right">08.10.2022 10:25:35</td>
<td bgcolor="#FFFF00" align="right">3</td>
<td style="border-right: 1px solid #000000" align="right">224</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:26:36</td>
<td align="left"> 1665224796</td>
<td align="right">08.10.2022 10:26:36</td>
<td align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">226</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:26:36.0000</td>
<td align="right">1665224796000</td>
<td style="border-right: 1px solid #000000" align="right">2</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:27:37</td>
<td align="left"> 1665224857</td>
<td align="right">08.10.2022 10:27:37</td>
<td align="right">3</td>
<td style="border-right: 1px solid #000000" align="right">229</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:27:37.0000</td>
<td align="right">1665224857000</td>
<td style="border-right: 1px solid #000000" align="right">3</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:28:39</td>
<td align="left"> 1665224919</td>
<td align="right">08.10.2022 10:28:39</td>
<td align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">231</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:28:39.0000</td>
<td align="right">1665224919000</td>
<td style="border-right: 1px solid #000000" align="right">2</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:29:40</td>
<td align="left"> 1665224980</td>
<td align="right">08.10.2022 10:29:40</td>
<td bgcolor="#FFFF00" align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">233</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:30:42</td>
<td align="left"> 1665225042</td>
<td align="right">08.10.2022 10:30:42</td>
<td bgcolor="#FFFF00" align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">235</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:31:43</td>
<td align="left"> 1665225103</td>
<td align="right">08.10.2022 10:31:43</td>
<td bgcolor="#FFFF00" align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">237</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:32:44</td>
<td align="left"> 1665225164</td>
<td align="right">08.10.2022 10:32:44</td>
<td bgcolor="#FFFF00" align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">239</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left"><br>
</td>
<td align="left"><br>
</td>
<td style="border-right: 1px solid #000000" align="left"><br>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:33:45</td>
<td align="left"> 1665225225</td>
<td align="right">08.10.2022 10:33:45</td>
<td align="right">1</td>
<td style="border-right: 1px solid #000000" align="right">240</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:33:45.0000</td>
<td align="right">1665225225000</td>
<td style="border-right: 1px solid #000000" align="right">1</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:34:47</td>
<td align="left"> 1665225287</td>
<td align="right">08.10.2022 10:34:47</td>
<td align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">242</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:34:47.0000</td>
<td align="right">1665225287000</td>
<td style="border-right: 1px solid #000000" align="right">2</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:35:48</td>
<td align="left"> 1665225348</td>
<td align="right">08.10.2022 10:35:48</td>
<td align="right">3</td>
<td style="border-right: 1px solid #000000" align="right">245</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:35:48.0000</td>
<td align="right">1665225348000</td>
<td style="border-right: 1px solid #000000" align="right">3</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:36:51</td>
<td align="left"> 1665225411</td>
<td align="right">08.10.2022 10:36:51</td>
<td align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">247</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:36:51.0000</td>
<td align="right">1665225411000</td>
<td style="border-right: 1px solid #000000" align="right">2</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:37:53</td>
<td align="left"> 1665225473</td>
<td align="right">08.10.2022 10:37:53</td>
<td align="right">1</td>
<td style="border-right: 1px solid #000000" align="right">248</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:37:53.0000</td>
<td align="right">1665225473000</td>
<td style="border-right: 1px solid #000000" align="right">1</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000" height="17"
align="left">Oct 8 12:38:54</td>
<td align="left"> 1665225534</td>
<td align="right">08.10.2022 10:38:54</td>
<td align="right">2</td>
<td style="border-right: 1px solid #000000" align="right">250</td>
<td align="left"><br>
</td>
<td style="border-left: 1px solid #000000" align="left">2022-10-08
12:38:54.0000</td>
<td align="right">1665225534000</td>
<td style="border-right: 1px solid #000000" align="right">2</td>
</tr>
<tr>
<td style="border-bottom: 1px solid #000000; border-left: 1px
solid #000000" height="17" align="left">Oct 8 12:39:55</td>
<td style="border-bottom: 1px solid #000000" align="left">
1665225595</td>
<td style="border-bottom: 1px solid #000000" align="right">08.10.2022
10:39:55</td>
<td style="border-bottom: 1px solid #000000" align="right">2</td>
<td style="border-bottom: 1px solid #000000; border-right: 1px
solid #000000" align="right">252</td>
<td align="left"><br>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px
solid #000000" align="left"><br>
</td>
<td style="border-bottom: 1px solid #000000" align="left"><br>
</td>
<td style="border-bottom: 1px solid #000000; border-right: 1px
solid #000000" align="left"><br>
</td>
</tr>
</tbody>
</table>
<p>
<style type="text/css">body,div,table,thead,tbody,tfoot,tr,th,td,p { font-family:"Liberation Sans"; font-size:x-small }a.comment-indicator:hover + comment { background:#ffd; position:absolute; display:block; border:1px solid black; padding:0.5em; }a.comment-indicator { background:red; display:inline-block; border:1px solid black; width:0.5em; height:0.5em; }comment { display:none; }</style></p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:a287af63-967b-b803-4803-2521aff6d0c5@gmx.de">
<br>
- Du kannst, ggf. auch einfach zusätzlich (eine weitere UUID
<br>
einrichten), die Impulse von Python direkt in die Datenbank
schreiben.
<br>
So mache ich das gerne: Ohne den vzlogger, einfach per cron
irgendein
<br>
Script regelmäßig laufen lassen und den Eintrag per HTTP-Aufruf
(wget
<br>
o.ä.) in die Middleware pushen. Der "Umweg" über vzlogger hat
natürlich
<br>
den Vorteil der Pufferung, sollte die Middleware mal nicht laufen.
<br>
</blockquote>
<p>Ich habe "duplicates" gelöscht und aggmode auf "none" gesetzt.</p>
<p>Mal schauen, ob es jetzt funktioniert.<br>
</p>
<blockquote type="cite"
cite="mid:a287af63-967b-b803-4803-2521aff6d0c5@gmx.de">
<br>
Grüße von Lech und Wertach
<br>
<br>
Rupert
<br>
</blockquote>
<p>Vielen Dank vom Fernsehturm am Nekar nach Augsburg<br>
</p>
<p>Tilman<br>
</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:a287af63-967b-b803-4803-2521aff6d0c5@gmx.de">
<br>
<br>
Am 05.10.22 um 21:23 schrieb Tilman Glötzner:
<br>
<blockquote type="cite">Hallo
<br>
<br>
wie bereits vor kurzen geschrieben, verwende ich einen
Kompaßsensor
<br>
zum Detektieren des Magnetes im Gaszähler. Das Zählen der
Impulse
<br>
übernimmt ein C-Programm, das die gezählten Impulse über einen
Socket
<br>
zur Verfügung stellt. Das unten gezeigte Python-Script holt die
<br>
gezählten Impulse ab und übergibt sie an den Volkszähler, der
sie in
<br>
die Datenbank schreibt. Dabei gehen Impulse verloren.
<br>
<br>
Ich habe nun festgestellt, dass das Pythonscript regelmäßig
läuft
<br>
(siehe log in /var/log/syslog). Die Zählerstände landen aber
nicht
<br>
alle in der Datenbank.
<br>
<br>
Woran kann das liegen bzw. wie kann ich das Debuggen?
<br>
<br>
<br>
Danke und Gruß
<br>
<br>
Tilman
<br>
<br>
<br>
================database ==============
<br>
<br>
MariaDB [volkszaehler]> select
FROM_UNIXTIME(timestamp/1000),timestamp
<br>
as UNIX,value from data where channel_id = 22 AND
<br>
FROM_UNIXTIME(timestamp/1000) > '2022-10-05 19:45:00';
<br>
+-------------------------------+---------------+-------+
<br>
| FROM_UNIXTIME(timestamp/1000) | UNIX | value |
<br>
+-------------------------------+---------------+-------+
<br>
| 2022-10-05 19:49:40.0000 | 1664992180000 | 0 |
<br>
| 2022-10-05 19:50:41.0000 | 1664992241000 | 2 |
<br>
| 2022-10-05 19:52:48.0000 | 1664992368000 | 3 |
<br>
| 2022-10-05 19:57:54.0000 | 1664992674000 | 2 |
<br>
| 2022-10-05 19:58:55.0000 | 1664992735000 | 1 |
<br>
| 2022-10-05 20:00:58.0000 | 1664992858000 | 2 |
<br>
| 2022-10-05 20:04:02.0000 | 1664993042000 | 1 |
<br>
| 2022-10-05 20:05:03.0000 | 1664993103000 | 2 |
<br>
| 2022-10-05 20:06:04.0000 | 1664993164000 | 1 |
<br>
| 2022-10-05 20:07:05.0000 | 1664993225000 | 0 |
<br>
| 2022-10-05 20:19:21.0000 | 1664993961000 | 0 |
<br>
| 2022-10-05 20:31:45.0000 | 1664994705000 | 0 |
<br>
| 2022-10-05 20:44:01.0000 | 1664995441000 | 0 |
<br>
| 2022-10-05 20:56:15.0000 | 1664996175000 | 0 |
<br>
+-------------------------------+---------------+-------+
<br>
<br>
================/var/log/syslog ==============
<br>
<br>
ct 5 19:50:41 logger /countingmeter.py: 1664992241: Counter =
2;
<br>
TotalCounter = 69
<br>
Oct 5 19:51:43 logger /countingmeter.py: 1664992303: Counter =
2;
<br>
TotalCounter = 71
<br>
Oct 5 19:52:48 logger /countingmeter.py: 1664992368: Counter =
3;
<br>
TotalCounter = 74
<br>
Oct 5 19:53:49 logger /countingmeter.py: 1664992429: Counter =
3;
<br>
TotalCounter = 77
<br>
Oct 5 19:54:51 logger /countingmeter.py: 1664992491: Counter =
3;
<br>
TotalCounter = 80
<br>
Oct 5 19:55:52 logger /countingmeter.py: 1664992552: Counter =
3;
<br>
TotalCounter = 83
<br>
Oct 5 19:56:53 logger /countingmeter.py: 1664992613: Counter =
3;
<br>
TotalCounter = 86
<br>
Oct 5 19:57:54 logger /countingmeter.py: 1664992674: Counter =
2;
<br>
TotalCounter = 88
<br>
Oct 5 19:58:55 logger /countingmeter.py: 1664992735: Counter =
1;
<br>
TotalCounter = 89
<br>
Oct 5 19:59:57 logger /countingmeter.py: 1664992797: Counter =
1;
<br>
TotalCounter = 90
<br>
Oct 5 20:00:01 logger CRON[30553]: (root) CMD (flock -n
<br>
/tmp/flock-vz_aggregate.lock php
<br>
/var/www/volkszaehler.org/bin/aggregate run
<br>
-m delta -l minute >/dev/null)
<br>
Oct 5 20:00:58 logger /countingmeter.py: 1664992858: Counter =
2;
<br>
TotalCounter = 92
<br>
Oct 5 20:01:01 logger CRON[30939]: (root) CMD (php
<br>
/var/www/volkszaehler.org/bin/aggregate run -m delta -l hour
>/dev/null)
<br>
Oct 5 20:01:59 logger /countingmeter.py: 1664992919: Counter =
2;
<br>
TotalCounter = 94
<br>
Oct 5 20:03:01 logger /countingmeter.py: 1664992981: Counter =
2;
<br>
TotalCounter = 96
<br>
Oct 5 20:04:02 logger /countingmeter.py: 1664993042: Counter =
1;
<br>
TotalCounter = 97
<br>
Oct 5 20:05:03 logger /countingmeter.py: 1664993103: Counter =
2;
<br>
TotalCounter = 99
<br>
Oct 5 20:06:04 logger /countingmeter.py: 1664993164: Counter =
1;
<br>
TotalCounter = 100
<br>
<br>
============= /etc/vzlogger.conf ===========
<br>
<br>
.....
<br>
<br>
{
<br>
// gas counter via i2c daemon and python script
<br>
"enabled": true,
<br>
"allowskip": true,
<br>
"protocol": "exec",
<br>
"command": "countingmeter.py",
<br>
"format": "$t: $i = $v",
<br>
"interval": 60,
<br>
"channels": [{
<br>
"uuid": "3e66af30-3efc-11ed-9625-9f6024cb27ed",
<br>
"identifier": "Counter",
<br>
"api": "volkszaehler",
<br>
"middleware": <a class="moz-txt-link-rfc2396E" href="http://localhost/middleware.php">"http://localhost/middleware.php"</a>,
<br>
"aggmode": "sum",
<br>
"duplicates": 720
<br>
}]
<br>
}
<br>
<br>
============= python script ===========
<br>
<br>
#!/usr/bin/python3
<br>
import datetime
<br>
import socket
<br>
import json
<br>
import syslog
<br>
<br>
HOST = "127.0.0.1" # The server's hostname or IP address
<br>
PORT = 8888 # The port used by the server
<br>
<br>
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
<br>
<br>
s.connect(("127.0.0.1", 8888))
<br>
string = (s.recv(1024).decode('utf-8'))
<br>
#print (string)
<br>
<br>
data = json.loads(string)
<br>
now = str(int( datetime.datetime.now().timestamp() ))
<br>
<br>
print(now + ': Counter = ' + str(data["counter"]))
<br>
print(now + ': TotalCounter = ' + str(data["total"]))
<br>
if data["counter"] != 0:
<br>
message = now + ': Counter = ' + str(data["counter"]) + ';
<br>
TotalCounter = ' + str(data["total"])
<br>
syslog.syslog(syslog.LOG_DEBUG, message)
<br>
<br>
</blockquote>
</blockquote>
</body>
</html>