From 41eba2b486cd7a3ee7f3c35ba21e715d9e2ac9d3 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Sat, 10 Nov 2012 11:51:19 +0100 Subject: [PATCH] report static nodes in corerouters stats --- core/utils.c | 1 + plugins/corerouter/corerouter.c | 23 +++++++++++++++++++++++ plugins/fastrouter/fastrouter.c | 1 + plugins/http/http.c | 1 + plugins/rawrouter/rawrouter.c | 1 + uwsgi.h | 1 + 6 files changed, 28 insertions(+) diff --git a/core/utils.c b/core/utils.c index f0453792..fb724cfc 100644 --- a/core/utils.c +++ b/core/utils.c @@ -3101,6 +3101,7 @@ struct uwsgi_string_list *uwsgi_string_new_list(struct uwsgi_string_list **list, } uwsgi_string->next = NULL; uwsgi_string->custom = 0; + uwsgi_string->custom2 = 0; return uwsgi_string; } diff --git a/plugins/corerouter/corerouter.c b/plugins/corerouter/corerouter.c index cb2fac91..4298d904 100644 --- a/plugins/corerouter/corerouter.c +++ b/plugins/corerouter/corerouter.c @@ -970,6 +970,29 @@ void corerouter_send_stats(struct uwsgi_corerouter *ucr) { if (uwsgi_stats_list_close(us)) goto end0; if (uwsgi_stats_comma(us)) goto end0; + if (ucr->static_nodes) { + if (uwsgi_stats_key(us , "static_nodes")) goto end0; + if (uwsgi_stats_list_open(us)) goto end0; + + struct uwsgi_string_list *usl = ucr->static_nodes; + while(usl) { + if (uwsgi_stats_object_open(us)) goto end0; + if (uwsgi_stats_keyvaln_comma(us, "name", usl->value, usl->len)) goto end0; + + if (uwsgi_stats_keylong_comma(us, "hits", (unsigned long long) usl->custom2)) goto end0; + if (uwsgi_stats_keylong(us, "grace", (unsigned long long) usl->custom)) goto end0; + + if (uwsgi_stats_object_close(us)) goto end0; + usl = usl->next; + if (usl) { + if (uwsgi_stats_comma(us)) goto end0; + } + } + + if (uwsgi_stats_list_close(us)) goto end0; + if (uwsgi_stats_comma(us)) goto end0; + } + if (ucr->has_subscription_sockets) { if (uwsgi_stats_key(us , "subscriptions")) goto end0; if (uwsgi_stats_list_open(us)) goto end0; diff --git a/plugins/fastrouter/fastrouter.c b/plugins/fastrouter/fastrouter.c index a5865d85..cc87201a 100644 --- a/plugins/fastrouter/fastrouter.c +++ b/plugins/fastrouter/fastrouter.c @@ -252,6 +252,7 @@ ssize_t fr_instance_connected(struct corerouter_session * cs) { cs->buffer_pos = 0; // ok instance is connected, wait for write again + if (cs->static_node) cs->static_node->custom2++; if (cs->un) cs->un->requests++; uwsgi_cr_hook_instance_write(cs, fr_instance_send_request_header); // return a value > 0 diff --git a/plugins/http/http.c b/plugins/http/http.c index ff6b2b34..f819a879 100644 --- a/plugins/http/http.c +++ b/plugins/http/http.c @@ -884,6 +884,7 @@ ssize_t hr_instance_connected(struct corerouter_session * cs) { return 1; } // ok instance is connected, wait for write again + if (cs->static_node) cs->static_node->custom2++; if (cs->un) cs->un->requests++; uwsgi_cr_hook_instance_write(cs, hr_instance_send_request_header); // return a value > 0 diff --git a/plugins/rawrouter/rawrouter.c b/plugins/rawrouter/rawrouter.c index e2170cbf..c9aa4ca6 100644 --- a/plugins/rawrouter/rawrouter.c +++ b/plugins/rawrouter/rawrouter.c @@ -209,6 +209,7 @@ ssize_t rr_instance_connected(struct corerouter_session * cs) { cs->buffer_pos = 0; // ok instance is connected, begin... + if (cs->static_node) cs->static_node->custom2++; if (cs->un) cs->un->requests++; uwsgi_cr_hook_instance_write(cs, NULL); diff --git a/uwsgi.h b/uwsgi.h index 09499ad9..ab8b185e 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -308,6 +308,7 @@ struct uwsgi_string_list { char *value; size_t len; uint64_t custom; + uint64_t custom2; struct uwsgi_string_list *next; };