From 77c279b3a9d9db472f5010b29635092baa9b8207 Mon Sep 17 00:00:00 2001 From: Unbit Date: Wed, 18 Dec 2013 07:31:53 +0100 Subject: [PATCH] added rx and tx to subscription nodes --- core/subscription.c | 6 ++++-- plugins/corerouter/corerouter.c | 3 ++- plugins/corerouter/cr.h | 4 ++++ plugins/tuntap/tuntap.c | 3 +++ uwsgi.h | 3 ++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/subscription.c b/core/subscription.c index 081b3182..40c9ee5b 100644 --- a/core/subscription.c +++ b/core/subscription.c @@ -454,7 +454,8 @@ struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slo node->modifier2 = usr->modifier2; node->requests = 0; node->last_requests = 0; - node->transferred = 0; + node->tx = 0; + node->rx = 0; node->reference = 0; node->death_mark = 0; node->failcnt = 0; @@ -541,7 +542,8 @@ struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slo current_slot->nodes->reference = 0; current_slot->nodes->requests = 0; current_slot->nodes->last_requests = 0; - current_slot->nodes->transferred = 0; + current_slot->nodes->tx = 0; + current_slot->nodes->rx = 0; current_slot->nodes->death_mark = 0; current_slot->nodes->failcnt = 0; current_slot->nodes->modifier1 = usr->modifier1; diff --git a/plugins/corerouter/corerouter.c b/plugins/corerouter/corerouter.c index def5b1b2..25d87177 100644 --- a/plugins/corerouter/corerouter.c +++ b/plugins/corerouter/corerouter.c @@ -1054,7 +1054,8 @@ void corerouter_send_stats(struct uwsgi_corerouter *ucr) { if (uwsgi_stats_keylong_comma(us, "last_check", (unsigned long long) s_node->last_check)) goto end0; if (uwsgi_stats_keylong_comma(us, "requests", (unsigned long long) s_node->requests)) goto end0; if (uwsgi_stats_keylong_comma(us, "last_requests", (unsigned long long) s_node->last_requests)) goto end0; - if (uwsgi_stats_keylong_comma(us, "tx", (unsigned long long) s_node->transferred)) goto end0; + if (uwsgi_stats_keylong_comma(us, "tx", (unsigned long long) s_node->tx)) goto end0; + if (uwsgi_stats_keylong_comma(us, "rx", (unsigned long long) s_node->rx)) goto end0; if (uwsgi_stats_keylong_comma(us, "cores", (unsigned long long) s_node->cores)) goto end0; if (uwsgi_stats_keylong_comma(us, "load", (unsigned long long) s_node->load)) goto end0; if (uwsgi_stats_keylong_comma(us, "weight", (unsigned long long) s_node->weight)) goto end0; diff --git a/plugins/corerouter/cr.h b/plugins/corerouter/cr.h index 512d9d2a..f6f90380 100644 --- a/plugins/corerouter/cr.h +++ b/plugins/corerouter/cr.h @@ -21,6 +21,7 @@ uwsgi_cr_error(peer, f);\ return -1;\ }\ + if (peer != peer->session->main_peer && peer->un) peer->un->rx+=len;\ peer->out_pos += len; #define cr_write_buf(peer, ubuf, f) write(peer->fd, ubuf->buf + ubuf##_pos, ubuf->pos - ubuf##_pos);\ @@ -29,6 +30,7 @@ uwsgi_cr_error(peer, f);\ return -1;\ }\ + if (peer != peer->session->main_peer && peer->un) peer->un->rx+=len;\ ubuf##_pos += len; #define cr_write_complete(peer) peer->out_pos == peer->out->pos @@ -51,6 +53,7 @@ uwsgi_cr_error(peer, f);\ return -1;\ }\ + if (peer != peer->session->main_peer && peer->un) peer->un->tx+=len;\ peer->in->pos += len;\ #define cr_read_exact(peer, l, f) read(peer->fd, peer->in->buf + peer->in->pos, (l - peer->in->pos));\ @@ -59,6 +62,7 @@ uwsgi_cr_error(peer, f);\ return -1;\ }\ + if (peer != peer->session->main_peer && peer->un) peer->un->tx+=len;\ peer->in->pos += len;\ #define cr_reset_hooks(peer) if(!peer->session->main_peer->disabled) {\ diff --git a/plugins/tuntap/tuntap.c b/plugins/tuntap/tuntap.c index 2f9bbecd..9807cea1 100644 --- a/plugins/tuntap/tuntap.c +++ b/plugins/tuntap/tuntap.c @@ -480,6 +480,9 @@ void tuntaprouter_send_stats(struct uwsgi_tuntap_router *uttr) { if (uwsgi_stats_object_open(us)) goto end0; if (uwsgi_stats_keyval_comma(us, "addr", uttp->ip)) goto end0; if (uwsgi_stats_keylong_comma(us, "addr_32", uttp->addr)) goto end0; + if (uwsgi_stats_keylong_comma(us, "uid", uttp->uid)) goto end0; + if (uwsgi_stats_keylong_comma(us, "gid", uttp->gid)) goto end0; + if (uwsgi_stats_keylong_comma(us, "pid", uttp->pid)) goto end0; if (uwsgi_stats_keylong_comma(us, "tx", uttp->tx)) goto end0; if (uwsgi_stats_keylong_comma(us, "rx", uttp->rx)) goto end0; if (uwsgi_stats_keylong(us, "dropped", uttp->dropped)) goto end0; diff --git a/uwsgi.h b/uwsgi.h index e2eba121..c9a875d0 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -3466,7 +3466,8 @@ struct uwsgi_subscribe_node { // number of requests since last subscription ping uint64_t last_requests; - uint64_t transferred; + uint64_t tx; + uint64_t rx; int death_mark; uint64_t reference;