From a152505d8a22f9e2a56509b933118be0f0ebe818 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 19 Oct 2017 15:01:41 +0200 Subject: implement simple counters for systemctl status --- pacredir.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pacredir.c b/pacredir.c index 7a9be30..a079e31 100644 --- a/pacredir.c +++ b/pacredir.c @@ -23,6 +23,7 @@ struct ignore_interfaces * ignore_interfaces = NULL; int max_threads = 0; static AvahiSimplePoll *simple_poll = NULL; uint8_t verbose = 0; +unsigned int count_redirect = 0, count_not_found = 0; /*** write_log ***/ int write_log(FILE *stream, const char *format, ...) { @@ -544,6 +545,13 @@ static int ahc_echo(void * cls, free(request); } + /* increase counters before reponse label, + do not count redirects to project page */ + if (http_code == MHD_HTTP_OK) + count_redirect++; + else + count_not_found++; + response: /* give response */ if (http_code == MHD_HTTP_OK) { @@ -573,6 +581,10 @@ response: MHD_destroy_response(response); + /* report counts to systemd */ + sd_notifyf(0, "STATUS=%d redirects, %d not found, waiting...", + count_redirect, count_not_found); + free(page); if (req_count > -1) { free(tid); -- cgit v1.2.3-54-g00ecf