mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-07 05:01:39 +02:00
Add uptime to Prometheus metrics
This commit is contained in:
parent
02dc025814
commit
ecfefc6041
1 changed files with 8 additions and 3 deletions
|
@ -681,8 +681,13 @@ class Web {
|
||||||
mApp->getVersion(), mConfig->sys.deviceName);
|
mApp->getVersion(), mConfig->sys.deviceName);
|
||||||
metrics = String(type) + String(topic);
|
metrics = String(type) + String(topic);
|
||||||
|
|
||||||
snprintf(topic,sizeof(topic),"# TYPE ahoy_solar_freeheap gauge\nahoy_solar_freeheap{devicename=\"%s\"} %u\n",mConfig->sys.deviceName,ESP.getFreeHeap());
|
snprintf(type,sizeof(type),"# TYPE ahoy_solar_freeheap gauge\n");
|
||||||
metrics += String(topic);
|
snprintf(topic,sizeof(topic),"ahoy_solar_freeheap{devicename=\"%s\"} %u\n",mConfig->sys.deviceName,ESP.getFreeHeap());
|
||||||
|
metrics += String(type) + String(topic);
|
||||||
|
|
||||||
|
snprintf(type,sizeof(type),"# TYPE ahoy_solar_uptime counter\n");
|
||||||
|
snprintf(topic,sizeof(topic),"ahoy_solar_uptime{devicename=\"%s\"} %u\n", mApp->getUptime());
|
||||||
|
metrics += String(type) + String(topic);
|
||||||
|
|
||||||
// NRF Statistics
|
// NRF Statistics
|
||||||
stat = mApp->getStatistics();
|
stat = mApp->getStatistics();
|
||||||
|
@ -789,7 +794,7 @@ class Web {
|
||||||
|
|
||||||
String radioStatistic(String statistic, uint32_t value) {
|
String radioStatistic(String statistic, uint32_t value) {
|
||||||
char type[60], topic[80], val[25];
|
char type[60], topic[80], val[25];
|
||||||
snprintf(type, sizeof(type), "# TYPE ahoy_solar_radio_%s gauge",statistic.c_str());
|
snprintf(type, sizeof(type), "# TYPE ahoy_solar_radio_%s counter",statistic.c_str());
|
||||||
snprintf(topic, sizeof(topic), "ahoy_solar_radio_%s",statistic.c_str());
|
snprintf(topic, sizeof(topic), "ahoy_solar_radio_%s",statistic.c_str());
|
||||||
snprintf(val, sizeof(val), "%d", value);
|
snprintf(val, sizeof(val), "%d", value);
|
||||||
return ( String(type) + "\n" + String(topic) + " " + String(val) + "\n");
|
return ( String(type) + "\n" + String(topic) + " " + String(val) + "\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue