docker services real

This commit is contained in:
2026-02-16 20:47:44 +09:00
parent 2e5ad58978
commit b33c658885
6 changed files with 65 additions and 19 deletions

View File

@@ -369,9 +369,14 @@ void dashboard_ui_update_stats(const pi_stats_t *stats)
/* Services table */
s_service_count = stats->service_count;
for (int i = 0; i < stats->service_count && i < WS_MAX_SERVICES; i++) {
const char *tag;
switch (stats->services[i].status) {
case SVC_RUNNING: tag = "[RUN]"; break;
case SVC_WARNING: tag = "[WARN]"; break;
default: tag = "[STOP]"; break;
}
lv_table_set_cell_value(tbl_services, i, 0, stats->services[i].name);
lv_table_set_cell_value(tbl_services, i, 1,
stats->services[i].running ? "[RUN]" : "[STOP]");
lv_table_set_cell_value(tbl_services, i, 1, tag);
}
/* Clear unused rows */
for (int i = stats->service_count; i < WS_MAX_SERVICES; i++) {

View File

@@ -133,7 +133,7 @@ static void ws_data_cb(const pi_stats_t *stats)
}
for (int i = 0; i < stats->service_count; i++) {
if (!stats->services[i].running) {
if (stats->services[i].status != SVC_RUNNING) {
alert_trigger(ALERT_SERVICE_DOWN);
break;
}

View File

@@ -92,7 +92,13 @@ static void parse_stats_json(const char *data, int len)
s_stats.services[i].name[WS_SERVICE_NAME_LEN - 1] = '\0';
}
if (status && status->valuestring) {
s_stats.services[i].running = (strcmp(status->valuestring, "running") == 0);
if (strcmp(status->valuestring, "running") == 0) {
s_stats.services[i].status = SVC_RUNNING;
} else if (strcmp(status->valuestring, "warning") == 0) {
s_stats.services[i].status = SVC_WARNING;
} else {
s_stats.services[i].status = SVC_STOPPED;
}
}
}
}

View File

@@ -8,7 +8,7 @@
extern "C" {
#endif
#define WS_MAX_SERVICES 8
#define WS_MAX_SERVICES 20
#define WS_SERVICE_NAME_LEN 16
typedef enum {
@@ -18,9 +18,15 @@ typedef enum {
WS_STATE_ERROR,
} ws_state_t;
typedef enum {
SVC_STOPPED = 0,
SVC_WARNING,
SVC_RUNNING,
} ws_svc_status_t;
typedef struct {
char name[WS_SERVICE_NAME_LEN];
bool running;
ws_svc_status_t status;
} ws_service_t;
typedef struct {