mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-25 22:15:09 +00:00
93_DbLog: contrib 5.5.3
git-svn-id: https://svn.fhem.de/fhem/trunk@26831 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e530cb5b23
commit
1e3bb94a23
@ -397,11 +397,12 @@ sub DbLog_Define {
|
|||||||
return "Bad regexp: $@" if($@);
|
return "Bad regexp: $@" if($@);
|
||||||
|
|
||||||
$hash->{REGEXP} = $regexp;
|
$hash->{REGEXP} = $regexp;
|
||||||
$hash->{MODE} = AttrVal($name, "asyncMode", undef) ? "asynchronous" : "synchronous"; # Mode setzen Forum:#76213
|
#$hash->{MODE} = AttrVal($name, 'asyncMode', undef) ? 'asynchronous' : 'synchronous'; # Mode setzen Forum:#76213
|
||||||
$hash->{HELPER}{OLDSTATE} = "initialized";
|
$hash->{MODE} = 'synchronous';
|
||||||
|
$hash->{HELPER}{OLDSTATE} = 'initialized';
|
||||||
$hash->{HELPER}{MODMETAABSENT} = 1 if($modMetaAbsent); # Modul Meta.pm nicht vorhanden
|
$hash->{HELPER}{MODMETAABSENT} = 1 if($modMetaAbsent); # Modul Meta.pm nicht vorhanden
|
||||||
$hash->{HELPER}{TH} = "history"; # Tabelle history (wird ggf. durch Datenbankschema ergänzt)
|
$hash->{HELPER}{TH} = 'history'; # Tabelle history (wird ggf. durch Datenbankschema ergänzt)
|
||||||
$hash->{HELPER}{TC} = "current"; # Tabelle current (wird ggf. durch Datenbankschema ergänzt)
|
$hash->{HELPER}{TC} = 'current'; # Tabelle current (wird ggf. durch Datenbankschema ergänzt)
|
||||||
|
|
||||||
DbLog_setVersionInfo ($hash); # Versionsinformationen setzen
|
DbLog_setVersionInfo ($hash); # Versionsinformationen setzen
|
||||||
notifyRegexpChanged ($hash, $regexp); # nur Events dieser Devices an NotifyFn weiterleiten, NOTIFYDEV wird gesetzt wenn möglich
|
notifyRegexpChanged ($hash, $regexp); # nur Events dieser Devices an NotifyFn weiterleiten, NOTIFYDEV wird gesetzt wenn möglich
|
||||||
@ -418,8 +419,7 @@ sub DbLog_Define {
|
|||||||
|
|
||||||
InternalTimer(gettimeofday()+2, 'DbLog_setinternalcols', $hash, 0); # set used COLUMNS
|
InternalTimer(gettimeofday()+2, 'DbLog_setinternalcols', $hash, 0); # set used COLUMNS
|
||||||
|
|
||||||
readingsSingleUpdate ($hash, 'state', 'waiting for connection', 1);
|
DbLog_setReadingstate ($hash, 'waiting for connection');
|
||||||
|
|
||||||
DbLog_SBP_CheckAndInit ($hash); # SubProcess starten - direkt nach Define !! um wenig Speicher zu allokieren
|
DbLog_SBP_CheckAndInit ($hash); # SubProcess starten - direkt nach Define !! um wenig Speicher zu allokieren
|
||||||
_DbLog_initOnStart ($hash); # von init_done abhängige Prozesse initialisieren
|
_DbLog_initOnStart ($hash); # von init_done abhängige Prozesse initialisieren
|
||||||
|
|
||||||
@ -823,7 +823,7 @@ sub _DbLog_setclearReadings { ## no critic "not used"
|
|||||||
|
|
||||||
for my $key(@allrds) {
|
for my $key(@allrds) {
|
||||||
next if($key =~ m/state/ || $key =~ m/CacheUsage/ || $key =~ m/NextSync/);
|
next if($key =~ m/state/ || $key =~ m/CacheUsage/ || $key =~ m/NextSync/);
|
||||||
readingsSingleUpdate($hash, $key, " ", 0);
|
readingsSingleUpdate($hash, $key, ' ', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -940,7 +940,7 @@ sub _DbLog_setreopen { ## no critic "not used"
|
|||||||
my $ts = (split " ",FmtDateTime(gettimeofday()+$prop))[1];
|
my $ts = (split " ",FmtDateTime(gettimeofday()+$prop))[1];
|
||||||
Log3 ($name, 2, "DbLog $name - Connection closed until $ts ($prop seconds).");
|
Log3 ($name, 2, "DbLog $name - Connection closed until $ts ($prop seconds).");
|
||||||
|
|
||||||
readingsSingleUpdate($hash, "state", "closed until $ts ($prop seconds)", 1);
|
DbLog_setReadingstate ($hash, "closed until $ts ($prop seconds)");
|
||||||
|
|
||||||
InternalTimer(gettimeofday()+$prop, "DbLog_reopen", $hash, 0);
|
InternalTimer(gettimeofday()+$prop, "DbLog_reopen", $hash, 0);
|
||||||
|
|
||||||
@ -2126,7 +2126,7 @@ sub DbLog_execMemCacheAsync {
|
|||||||
my $nsdt = FmtDateTime ($nextsync);
|
my $nsdt = FmtDateTime ($nextsync);
|
||||||
my $se = AttrVal ($name, "syncEvents", undef) ? 1 : 0;
|
my $se = AttrVal ($name, "syncEvents", undef) ? 1 : 0;
|
||||||
|
|
||||||
readingsSingleUpdate($hash, "NextSync", $nsdt. " or when CacheUsage ".$clim." is reached", $se);
|
readingsSingleUpdate($hash, 'NextSync', $nsdt. " or when CacheUsage ".$clim." is reached", $se);
|
||||||
|
|
||||||
DbLog_setReadingstate ($hash, $error);
|
DbLog_setReadingstate ($hash, $error);
|
||||||
|
|
||||||
@ -2236,8 +2236,7 @@ sub DbLog_SBP_onRun {
|
|||||||
ot => 0
|
ot => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2270,11 +2269,10 @@ sub DbLog_SBP_onRun {
|
|||||||
name => $name,
|
name => $name,
|
||||||
msg => 'connection params saved into SubProcess. Connection to DB is established when it is needed',
|
msg => 'connection params saved into SubProcess. Connection to DB is established when it is needed',
|
||||||
oper => $operation,
|
oper => $operation,
|
||||||
ot => 0,
|
ot => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2299,8 +2297,7 @@ sub DbLog_SBP_onRun {
|
|||||||
reqdbdat => 1 # Request Übertragung DB Verbindungsparameter
|
reqdbdat => 1 # Request Übertragung DB Verbindungsparameter
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2340,8 +2337,7 @@ sub DbLog_SBP_onRun {
|
|||||||
rowlback => $cdata # Rückgabe alle übergebenen Log-Daten
|
rowlback => $cdata # Rückgabe alle übergebenen Log-Daten
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2372,8 +2368,7 @@ sub DbLog_SBP_onRun {
|
|||||||
rowlback => $cdata # Rückgabe alle übergebenen Log-Daten
|
rowlback => $cdata # Rückgabe alle übergebenen Log-Daten
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent($retjson);
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2455,7 +2450,7 @@ sub DbLog_SBP_onRun {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(300000); # reduziert CPU Last
|
usleep(300000); # reduziert CPU Last im "Leerlauf"
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -2700,8 +2695,7 @@ sub _DbLog_SBP_onRun_Log {
|
|||||||
rowlback => $rowlback
|
rowlback => $rowlback
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2742,8 +2736,7 @@ sub _DbLog_SBP_onRun_Log {
|
|||||||
oper => $operation
|
oper => $operation
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2868,8 +2861,7 @@ sub _DbLog_SBP_onRun_Log {
|
|||||||
rowlback => $cdata
|
rowlback => $cdata
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2991,8 +2983,7 @@ sub _DbLog_SBP_onRun_Log {
|
|||||||
oper => $operation
|
oper => $operation
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3110,8 +3101,7 @@ sub _DbLog_SBP_onRun_Log {
|
|||||||
rowlback => $rowlback
|
rowlback => $rowlback
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3154,8 +3144,7 @@ sub _DbLog_SBP_onRun_Count {
|
|||||||
cc => $cc
|
cc => $cc
|
||||||
};
|
};
|
||||||
|
|
||||||
my $retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3221,8 +3210,7 @@ sub _DbLog_SBP_onRun_deleteOldDays {
|
|||||||
oper => $operation
|
oper => $operation
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3244,8 +3232,7 @@ sub _DbLog_SBP_onRun_deleteOldDays {
|
|||||||
numdel => $numdel
|
numdel => $numdel
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3293,8 +3280,7 @@ sub _DbLog_SBP_onRun_userCommand {
|
|||||||
oper => $operation
|
oper => $operation
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3314,8 +3300,7 @@ sub _DbLog_SBP_onRun_userCommand {
|
|||||||
res => $res
|
res => $res
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3361,8 +3346,7 @@ sub _DbLog_SBP_onRun_importCachefile {
|
|||||||
oper => $operation
|
oper => $operation
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3421,8 +3405,7 @@ sub _DbLog_SBP_onRun_importCachefile {
|
|||||||
res => $improws
|
res => $improws
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3514,8 +3497,7 @@ sub _DbLog_SBP_onRun_reduceLog {
|
|||||||
oper => $operation
|
oper => $operation
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3543,8 +3525,7 @@ sub _DbLog_SBP_onRun_reduceLog {
|
|||||||
oper => $operation
|
oper => $operation
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3565,8 +3546,7 @@ sub _DbLog_SBP_onRun_reduceLog {
|
|||||||
oper => $operation
|
oper => $operation
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3914,8 +3894,7 @@ sub _DbLog_SBP_onRun_reduceLog {
|
|||||||
res => $res
|
res => $res
|
||||||
};
|
};
|
||||||
|
|
||||||
$retjson = eval { encode_json($ret) };
|
__DbLog_SBP_sendToParent ($subprocess, $ret);
|
||||||
$subprocess->writeToParent ($retjson);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4102,6 +4081,20 @@ sub __DbLog_SBP_sthUpdTable {
|
|||||||
return ($err, $sth);
|
return ($err, $sth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#################################################################
|
||||||
|
# Information an Parent Prozess senden, Verarbeitung in
|
||||||
|
# read Schleife DbLog_SBP_Read
|
||||||
|
#################################################################
|
||||||
|
sub __DbLog_SBP_sendToParent {
|
||||||
|
my $subprocess = shift;
|
||||||
|
my $ret = shift;
|
||||||
|
|
||||||
|
my $json = eval {encode_json($ret)};
|
||||||
|
$subprocess->writeToParent ($json);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
## Subprocess wird beendet
|
## Subprocess wird beendet
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -4505,7 +4498,7 @@ sub DbLog_SBP_Read {
|
|||||||
|
|
||||||
readingsBeginUpdate ($hash);
|
readingsBeginUpdate ($hash);
|
||||||
readingsBulkUpdate ($hash, 'background_processing_time', sprintf("%.4f",$brt));
|
readingsBulkUpdate ($hash, 'background_processing_time', sprintf("%.4f",$brt));
|
||||||
readingsBulkUpdate ($hash, 'sql_processing_time', sprintf("%.4f",$rt));
|
readingsBulkUpdate ($hash, 'sql_processing_time', sprintf("%.4f",$rt) );
|
||||||
readingsEndUpdate ($hash, 1);
|
readingsEndUpdate ($hash, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user