mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 19:56:30 +00:00
recreate 16044 (#22232)
This commit is contained in:
parent
bf0f7316b9
commit
b09b3560b9
@ -298,7 +298,7 @@ void HandleMetrics(void) {
|
|||||||
JsonParserObject Object3 = value2.getObject();
|
JsonParserObject Object3 = value2.getObject();
|
||||||
for (auto key3 : Object3) {
|
for (auto key3 : Object3) {
|
||||||
const char *value = key3.getValue().getStr(nullptr);
|
const char *value = key3.getValue().getStr(nullptr);
|
||||||
if (value != nullptr && isdigit(value[0])) {
|
if (value != nullptr && (isdigit(value[0]) || (value[0] == '-') || (value[0] == '.'))) {
|
||||||
String sensor = FormatMetricName(key2.getStr());
|
String sensor = FormatMetricName(key2.getStr());
|
||||||
String type = FormatMetricName(key3.getStr());
|
String type = FormatMetricName(key3.getStr());
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ void HandleMetrics(void) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const char *value = value2.getStr(nullptr);
|
const char *value = value2.getStr(nullptr);
|
||||||
if (value != nullptr && isdigit(value[0])) {
|
if (value != nullptr && (isdigit(value[0]) || (value[0] == '-') || (value[0] == '.'))) {
|
||||||
String sensor = FormatMetricName(key1.getStr());
|
String sensor = FormatMetricName(key1.getStr());
|
||||||
String type = FormatMetricName(key2.getStr());
|
String type = FormatMetricName(key2.getStr());
|
||||||
if (strcmp(type.c_str(), "totalstarttime") != 0) { // this metric causes Prometheus of fail
|
if (strcmp(type.c_str(), "totalstarttime") != 0) { // this metric causes Prometheus of fail
|
||||||
@ -336,7 +336,7 @@ void HandleMetrics(void) {
|
|||||||
const char *value = value1.getStr(nullptr);
|
const char *value = value1.getStr(nullptr);
|
||||||
String sensor = FormatMetricName(key1.getStr());
|
String sensor = FormatMetricName(key1.getStr());
|
||||||
|
|
||||||
if (value != nullptr && isdigit(value[0] && strcmp(sensor.c_str(), "time") != 0)) { //remove false 'time' metric
|
if (value != nullptr && (isdigit(value[0]) || (value[0] == '-') || (value[0] == '.')) && strcmp(sensor.c_str(), "time") != 0) { //remove false 'time' metric
|
||||||
WritePromMetricStr(PSTR("sensors"), kPromMetricGauge, value,
|
WritePromMetricStr(PSTR("sensors"), kPromMetricGauge, value,
|
||||||
PSTR("sensor"), sensor.c_str(),
|
PSTR("sensor"), sensor.c_str(),
|
||||||
nullptr);
|
nullptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user