diff options
author | Christian Hesse <mail@eworm.de> | 2017-10-19 15:01:41 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2017-10-19 15:01:41 +0200 |
commit | a152505d8a22f9e2a56509b933118be0f0ebe818 (patch) | |
tree | 07dc18ad7ae3f137a9fb92319955552d22d018bb | |
parent | 74377fb5e1043c6c5141f096b66f225878c9e249 (diff) | |
download | pacredir-a152505d8a22f9e2a56509b933118be0f0ebe818.tar.gz pacredir-a152505d8a22f9e2a56509b933118be0f0ebe818.tar.zst |
implement simple counters for systemctl status
-rw-r--r-- | pacredir.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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); |