[gelöst] DbLog loggt keine Daten in mySQL Datenbank

Begonnen von t1me2die, 15 Februar 2018, 11:38:47

Vorheriges Thema - Nächstes Thema

t1me2die

Hallo liebe Community,

seit Beginn meiner FHEM Karriere wurden alle Daten immer via .txt Datei geloggt.
Nun bin ich gerade dabei meine FHEM Instanz auf eine VM mit Debian umzuziehen.
In diesem Zuge habe wollte ich auch direkt auf DbLog umstellen.

Habe mich an dem Wiki https://wiki.fhem.de/wiki/DbLog#Datenbank langt gehangelt.

Ich habe mich für eine MySQL DB entschieden.

Die Datenbank namens "fhem" habe ich auch erfolgreich angelegt.
Die Tabellen current, history werden mir angezeigt, wenn ich:


USE fhem;


mache.

In FHEM habe ich dann folgenden define angelegt:

define logdb DbLog ./db.conf .*:.*


Danach ein:

set logdb rereadcfg


Status springt auf connected.

Wenn ich es nun richtig verstanden habe, müssten nun alle Geräte Daten in die MySql DB geloggt werden.

Ein:

Select * from current;
oder ein:
Select * from history;


Gibt leider "empty" aus. Sprich keine Daten vorhanden.

Nun weiß ich leider nicht weiter, ich hoffe ihr könnt mir helfen.

Gruß
Mathze

DS_Starter

Folgende Schritte um mehr Infos zu wrhalten:

- ein set configCheck
- verbose auf 4 oder 5 hochdrehen , Infos im Logfile beachten

die jeweiligen Ausgaben posten und im Logfile auch mal auf Fehlermeldungen bei restart oder rereadcfg achten.

VG
Proxmox+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

t1me2die

Ein

select * from history;

Gibt jetzt 673Rows aus, scheint also doch zu klappen.

Die Ausgabe von set configCheck:


Result of DbLog version check

Used DbLog version: 3.8.4
Recommendation: Your running version may be the current one. Please check for updates of DbLog periodically.

Result of configuration read check

Connection parameter store type: file
Connection parameter: Connection -> mysql:database=fhem;host=localhost;port=3306, User -> admin, Password -> read o.k. 

Result of connection check

Connection to database fhem successfully done.
Recommendation: settings o.k.

Result of encoding check

Encoding used by Client (connection): LATIN1
Encoding used by DB fhem: UTF8
Recommendation: Both encodings should be identical. You can adjust the usage of UTF8 connection by setting the UTF8 parameter in file './db.conf' to the right value. 

Result of logmode check

Logmode of DbLog-device logdb is: synchronous
Recommendation: Switch logdb to the asynchronous logmode by setting the 'asyncMode' attribute. The advantage of this mode is to log events non-blocking.
There are attributes 'syncInterval' and 'cacheLimit' relevant for this working mode.
Please refer to commandref for further informations about these attributes.

Result of plot generation method check

WARNING - at least one of your FHEMWEB devices have attribute "plotfork = 1" not set. This may cause blocking situations when creating plots.
WEB: plotfork=0
WEBphone: plotfork=0
WEBtablet: plotfork=0
Recommendation: You should set attribute "plotfork = 1" in relevant devices

Result of table 'history' check

Column width set in DB fhem.history: 'DEVICE' = 32, 'TYPE' = 32, 'EVENT' = 512, 'READING' = 32, 'VALUE' = 32, 'UNIT' = 32
Column width used by logdb: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Recommendation: The relation between column width in table history and the field width used in device logdb don't meet the requirements. Please make sure that the width of database field definition is equal or larger than the field width used by the module. Compare the given results.
Currently the default values for field width are:

DEVICE: 64
TYPE: 64
EVENT: 512
READING: 64
VALUE: 128
UNIT: 32

You can change the column width in database by a statement like 'alter table history modify VALUE varchar(128);' (example for changing field 'VALUE'). You can do it for example by executing 'sqlCmd' in DbRep or in a SQL-Editor of your choice. (switch logdb to asynchron mode for non-blocking).
Alternatively the field width used by logdb can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)

Result of table 'current' check

Column width set in DB fhem.current: 'DEVICE' = 32, 'TYPE' = 32, 'EVENT' = 512, 'READING' = 32, 'VALUE' = 32, 'UNIT' = 32
Column width used by logdb: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Recommendation: The relation between column width in table current and the field width used in device logdb don't meet the requirements. Please make sure that the width of database field definition is equal or larger than the field width used by the module. Compare the given results.
Currently the default values for field width are:

DEVICE: 64
TYPE: 64
EVENT: 512
READING: 64
VALUE: 128
UNIT: 32

You can change the column width in database by a statement like 'alter table current modify VALUE varchar(128);' (example for changing field 'VALUE'). You can do it for example by executing 'sqlCmd' in DbRep or in a SQL-Editor of your choice. (switch logdb to asynchron mode for non-blocking).
Alternatively the field width used by logdb can be adjusted by setting attributes 'colEvent', 'colReading', 'colValue'. (pls. refer to commandref)

Result of check 'Search_Idx' availability

Index 'Search_Idx' exists and contains recommended fields 'DEVICE', 'READING', 'TIMESTAMP'.
Recommendation: settings o.k.

Result of check 'Report_Idx' availability for DbRep-devices

No DbRep-device assigned to logdb is used. Hence an index for DbRep isn't needed.
Recommendation: settings o.k.



Und hier ein Log mit Verbose 5:

################################################################
2018.02.15 12:45:47 4: DbLog logdb -> ###
New database processing cycle - synchronous
###
2018.02.15 12:45:47 4: DbLog logdb ->
################################################################
2018.02.15 12:45:47 4: DbLog logdb -> DbLogType is: History
2018.02.15 12:45:47 4: DbLog logdb -> AutoCommit mode: ON, Transaction mode: ON
2018.02.15 12:45:47 5: DbLog logdb -> Primary Key used in fhem.history: none
2018.02.15 12:45:47 5: DbLog logdb -> Primary Key used in fhem.current: none
2018.02.15 12:45:47 4: DbLog logdb -> processing event Timestamp:
2018-02-15 12:45:47, Device: THGR228N_38_1, Type: OREGON, Event: temperature: 17.3, Reading: temperature, Value: 17.3, Unit: °C
2018.02.15 12:45:47 4: DbLog logdb -> processing event Timestamp:
2018-02-15 12:45:47, Device: THGR228N_38_1, Type: OREGON, Event: humidity: 70, Reading: humidity, Value: 70, Unit: %
2018.02.15 12:45:47 4: DbLog logdb -> processing event Timestamp:
2018-02-15 12:45:47, Device: THGR228N_38_1, Type: OREGON, Event: battery: low, Reading: battery, Value: low, Unit:
2018.02.15 12:45:47 4: DbLog logdb -> processing event Timestamp:
2018-02-15 12:45:47, Device: THGR228N_38_1, Type: OREGON, Event: state: T: 17.3 H: 70 BAT: low, Reading: state, Value: T: 17.3 H: 70 BAT: low, Unit:
2018.02.15 12:45:47 4: DbLog logdb -> 4 of 4 events inserted into table history
2018.02.15 12:45:47 4: DbLog logdb -> insert table history committed by autocommit
2018.02.15 12:45:47 5: DbLog logdb -> DbLog_Push Returncode: 0


Sieht doch alles gut aus oder?
In der History Datei ist ja auch was drin.

Was mich wundert, dass ist der Current Table nichts steht?

Gruß
Mathze

DS_Starter

#3
Der configCheck gibt einige Empfehlungen aus die du bereinigen solltest. Insbesondere die Spaltenbreite.
Die current wird erst befüllt wenn sie per Attribut zugeschaltet wurde.
Ich wundere mich immer dass diese einfachen Schritte nicht gemacht werden obwohl ich das inzwischen gleich zu Beginn der Commandref beschrieben habe !? 

Die userCommand Funktion arbeitet sehr simpel. Mehrzeilige Ausgaben gehen nicht. DbRep dafür vewenden.
was aber geht ist ein

select count(*) from history

was bringt das ?

Proxmox+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

t1me2die

Danke, habe die Feldlängen erstmal angepasst.

Bis zur Commandref kam ich noch nicht, habe erstmal das Wiki durchgelesen.
Muss nun erstmal die notwendigen Includes und Exclude setzen, damit nicht alles geloggt wird.

Danke für die Hilfe

Gruß
Mathze