]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Add gauge to track RTR readyness
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 11 Sep 2025 23:45:57 +0000 (17:45 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 11 Sep 2025 23:45:57 +0000 (17:45 -0600)
Starts as 0, becomes 1 when the VRP database has been populated.

Intended to replace the awkward log msg at least one user tracks:

> First validation cycle successfully ended,
> now you can connect your router(s)

For #133.

src/main.c
src/stats.c
src/stats.h

index 676cdba05d17ee6ea8d25fdc104b0b9f9b5e7b7b..84cc2d58e3e2b0c39125ff49854f966b3970b26e 100644 (file)
@@ -49,11 +49,9 @@ fort_server(void)
 
        rtr_notify();
 
-       /*
-        * See issue #133.
-        * TODO (#50) Remove this message once the stats server is implemented.
-        */
+       /* TODO (#133) Stats ready; remove this message in a couple versions. */
        pr_op_warn("First validation cycle successfully ended, now you can connect your router(s)");
+       stats_gauge_set(stat_rtr_ready, 1);
 
        do {
                pr_op_info("Main loop: Sleeping.");
index 6f2d391dc6b34399d576b46ac125c4d45585f717..96dca04e8f1b54faeaf5ffa17b8504481a31665c 100644 (file)
@@ -19,6 +19,7 @@ struct stats_gauge {
 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
 static struct stats_gauge *gauges;
 
+struct stats_gauge *stat_rtr_ready;
 struct stats_gauge *stat_rtr_connections;
 
 /* Steals ownership of @name */
@@ -65,6 +66,7 @@ add_gauge(char *name, size_t namelen, unsigned int value)
 int
 stats_setup(void)
 {
+       stat_rtr_ready = ADD_GAUGE("fort_rtr_ready");
        stat_rtr_connections = ADD_GAUGE("fort_rtr_current_connections");
        return 0;
 }
index 8d190301d59a48e2bb10b79a25bc6c62bd348862..74583b41dc522272c4feda965c1978176fdf17af 100644 (file)
@@ -2,6 +2,7 @@
 #define SRC_STATS_H_
 
 struct stats_gauge;
+extern struct stats_gauge *stat_rtr_ready;
 extern struct stats_gauge *stat_rtr_connections;
 
 int stats_setup(void);