Skip to content

Commit

Permalink
report static nodes in corerouters stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto De Ioris committed Nov 10, 2012
1 parent 24763fd commit 41eba2b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/utils.c
Expand Up @@ -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;
}
Expand Down
23 changes: 23 additions & 0 deletions plugins/corerouter/corerouter.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions plugins/fastrouter/fastrouter.c
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions plugins/http/http.c
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions plugins/rawrouter/rawrouter.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions uwsgi.h
Expand Up @@ -308,6 +308,7 @@ struct uwsgi_string_list {
char *value;
size_t len;
uint64_t custom;
uint64_t custom2;
struct uwsgi_string_list *next;
};

Expand Down

0 comments on commit 41eba2b

Please sign in to comment.