From 2ad586295dcd5dcef3d29af32998d55bb5c09843 Mon Sep 17 00:00:00 2001 From: arf20 Date: Mon, 10 Nov 2025 00:28:43 +0100 Subject: WIP api alert --- monitor.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 5d34824..109de89 100644 --- a/monitor.c +++ b/monitor.c @@ -24,7 +24,8 @@ typedef struct { } incident_t; -const char *type_str[] = { "reach", "dns", "web" }; +static const char *status_str[] = { "down", "up" }; +static const char *type_str[] = { "reach", "dns", "web" }; target_t *targets = NULL; size_t targets_size = 0, targets_capacity = INIT_VEC_CAPACITY; @@ -35,7 +36,6 @@ static size_t incidents_size = 0, incidents_capacity = 0; static char timestr[256]; -static char *status_str[] = { "down", "up" }; static void @@ -215,7 +215,7 @@ monitor_init() char *name = strtok(NULL, ","); char *target = strtok(NULL, ","); - if (!target || !name || !target) { + if (!type || !name || !target) { fprintf(stderr, "malformed config line: %s\n", line); continue; } @@ -226,6 +226,10 @@ monitor_init() targets[targets_size].type = TYPE_DNS; else if (strcmp(type, "web") == 0) targets[targets_size].type = TYPE_WEB; + else { + fprintf(stderr, "unknown target type: %s\n", line); + continue; + } targets[targets_size].name = strdup(name); targets[targets_size].target = strdup(target); @@ -246,7 +250,7 @@ monitor_init() ); targets_size++; - } + } incidents = malloc(sizeof(incident_t) * INIT_VEC_CAPACITY); incidents_capacity = INIT_VEC_CAPACITY; -- cgit v1.2.3