[sheepdog] [PATCH v2] sheep: make sheep request stat finer
Liu Yuan
namei.unix at gmail.com
Sat Jan 4 18:11:32 CET 2014
With this patch we can poke more information about the node stat:
$ dog node stat -w
...
Client 12 340681 100459 233694 0 6528 44 GB 26 GB 95 MB 0.0 MB
Peer 6 41013 4008 37005 0 0 8.6 GB 3.9 GB 23 MB 0.0 MB
Request Active Total Write Read Remove Flush All WR All RD WRBW RDBW
Client 5 341362 100459 234375 0 6528 44 GB 26 GB 98 MB 0.0 MB
Peer 0 41128 4008 37120 0 0 8.6 GB 3.9 GB 24 MB 0.0 MB
Request Active Total Write Read Remove Flush All WR All RD WRBW RDBW
Client 0 341969 100459 234982 0 6528 44 GB 26 GB 92 MB 0.0 MB
Peer 0 41220 4008 37212 0 0 8.6 GB 3.9 GB 24 MB 0.0 MB
Request Active Total Write Read Remove Flush All WR All RD WRBW RDBW
Client 8 342584 100459 235597 0 6528 44 GB 26 GB 113 MB 0.0 MB
Peer 0 41335 4008 37327 0 0 8.6 GB 3.9 GB 23 MB 0.0 MB
Request Active Total Write Read Remove Flush All WR All RD WRBW RDBW
Client 6 343069 100460 236081 0 6528 44 GB 26 GB 86 MB 4.0 MB
Peer 2 41429 4009 37420 0 0 8.7 GB 3.9 GB 26 MB 1.0 MB
...
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
dog/node.c | 64 ++++++++++++++++++++++++++++++++++++------------
include/internal_proto.h | 7 ++++++
sheep/request.c | 34 +++++++++++++++++++++++++
3 files changed, 90 insertions(+), 15 deletions(-)
diff --git a/dog/node.c b/dog/node.c
index f896078..71486a0 100644
--- a/dog/node.c
+++ b/dog/node.c
@@ -275,9 +275,9 @@ static int node_stat(int argc, char **argv)
{
struct sd_req hdr;
struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
- struct sd_stat stat;
+ struct sd_stat stat, last;
int ret;
- uint32_t i = node_cmd_data.watch ? UINT32_MAX : 0;
+ bool watch = node_cmd_data.watch ? true : false, first = true;
again:
sd_init_req(&hdr, SD_OP_STAT);
@@ -292,21 +292,55 @@ again:
return EXIT_FAILURE;
}
- printf("%s%"PRIu64"\t%"PRIu64"\t%s\t%s\n",
- raw_output ? "" :
- "Request\tActive\tTotal\tIn\tOut\nClient\t",
- stat.r.gway_active_nr, stat.r.gway_total_nr,
- strnumber(stat.r.gway_total_rx),
- strnumber(stat.r.gway_total_tx));
- printf("%s%"PRIu64"\t%"PRIu64"\t%s\t%s\n",
- raw_output ? "" : "Peer\t",
- stat.r.peer_active_nr, stat.r.peer_total_nr,
- strnumber(stat.r.peer_total_rx),
- strnumber(stat.r.peer_total_tx));
- if (i > 0) {
- clear_screen();
+ if (watch) {
+ if (first) {
+ last = stat;
+ first = false;
+ }
+ printf("%s%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t"
+ "%"PRIu64"\t%"PRIu64"\t%s\t%s\t%s\t%s\n",
+ raw_output ? "" :
+ "Request\tActive\tTotal\tWrite\tRead\tRemove\tFlush\t"
+ "All WR\tAll RD\tWRBW\tRDBW\nClient\t",
+ stat.r.gway_active_nr, stat.r.gway_total_nr,
+ stat.r.gway_total_read_nr, stat.r.gway_total_write_nr,
+ stat.r.gway_total_remove_nr, stat.r.gway_total_flush_nr,
+ strnumber(stat.r.gway_total_rx),
+ strnumber(stat.r.gway_total_tx),
+ strnumber(stat.r.gway_total_rx - last.r.gway_total_rx),
+ strnumber(stat.r.gway_total_tx - last.r.gway_total_tx));
+ printf("%s%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t"
+ "%"PRIu64"\t%"PRIu64"\t%s\t%s\t%s\t%s\n",
+ raw_output ? "" : "Peer\t",
+ stat.r.peer_active_nr, stat.r.peer_total_nr,
+ stat.r.peer_total_read_nr, stat.r.peer_total_write_nr,
+ stat.r.peer_total_remove_nr, 0UL,
+ strnumber(stat.r.peer_total_rx),
+ strnumber(stat.r.peer_total_tx),
+ strnumber(stat.r.peer_total_rx - last.r.peer_total_rx),
+ strnumber(stat.r.peer_total_tx - last.r.peer_total_tx));
+ last = stat;
sleep(1);
goto again;
+ } else {
+ printf("%s%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t"
+ "%"PRIu64"\t%"PRIu64"\t%s\t%s\n",
+ raw_output ? "" :
+ "Request\tActive\tTotal\tWrite\tRead\tRemove\tFlush\t"
+ "All WR\tAll RD\nClient\t",
+ stat.r.gway_active_nr, stat.r.gway_total_nr,
+ stat.r.gway_total_read_nr, stat.r.gway_total_write_nr,
+ stat.r.gway_total_remove_nr, stat.r.gway_total_flush_nr,
+ strnumber(stat.r.gway_total_rx),
+ strnumber(stat.r.gway_total_tx));
+ printf("%s%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t"
+ "%"PRIu64"\t%"PRIu64"\t%s\t%s\n",
+ raw_output ? "" : "Peer\t",
+ stat.r.peer_active_nr, stat.r.peer_total_nr,
+ stat.r.peer_total_read_nr, stat.r.peer_total_write_nr,
+ stat.r.peer_total_remove_nr, 0UL,
+ strnumber(stat.r.peer_total_rx),
+ strnumber(stat.r.peer_total_tx));
}
return EXIT_SUCCESS;
diff --git a/include/internal_proto.h b/include/internal_proto.h
index 2aefb2d..d32cea7 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -250,6 +250,13 @@ struct sd_stat {
uint64_t gway_total_tx; /* Data out */
uint64_t peer_total_rx;
uint64_t peer_total_tx;
+ uint64_t gway_total_remove_nr;
+ uint64_t gway_total_read_nr;
+ uint64_t gway_total_write_nr;
+ uint64_t gway_total_flush_nr;
+ uint64_t peer_total_remove_nr;
+ uint64_t peer_total_read_nr;
+ uint64_t peer_total_write_nr;
} r;
};
diff --git a/sheep/request.c b/sheep/request.c
index e7d6947..9f3f110 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -367,6 +367,19 @@ static main_fn inline void stat_request_begin(struct request *req)
sys->stat.r.peer_total_rx += hdr->data_length;
else
sys->stat.r.peer_total_tx += hdr->data_length;
+
+ switch (hdr->opcode) {
+ case SD_OP_READ_PEER:
+ sys->stat.r.peer_total_read_nr++;
+ break;
+ case SD_OP_WRITE_PEER:
+ case SD_OP_CREATE_AND_WRITE_PEER:
+ sys->stat.r.peer_total_write_nr++;
+ break;
+ case SD_OP_REMOVE_PEER:
+ sys->stat.r.peer_total_remove_nr++;
+ break;
+ }
} else if (is_gateway_op(req->op)) {
sys->stat.r.gway_total_nr++;
sys->stat.r.gway_active_nr++;
@@ -374,11 +387,30 @@ static main_fn inline void stat_request_begin(struct request *req)
sys->stat.r.gway_total_rx += hdr->data_length;
else
sys->stat.r.gway_total_tx += hdr->data_length;
+
+ switch (hdr->opcode) {
+ case SD_OP_READ_OBJ:
+ sys->stat.r.gway_total_read_nr++;
+ break;
+ case SD_OP_WRITE_OBJ:
+ case SD_OP_CREATE_AND_WRITE_OBJ:
+ sys->stat.r.gway_total_write_nr++;
+ break;
+ case SD_OP_DISCARD_OBJ:
+ sys->stat.r.gway_total_remove_nr++;
+ break;
+ }
+ } else if (hdr->opcode == SD_OP_FLUSH_VDI) {
+ sys->stat.r.gway_total_nr++;
+ sys->stat.r.gway_active_nr++;
+ sys->stat.r.gway_total_flush_nr++;
}
}
static main_fn inline void stat_request_end(struct request *req)
{
+ struct sd_req *hdr = &req->rq;
+
if (!req->stat)
return;
@@ -386,6 +418,8 @@ static main_fn inline void stat_request_end(struct request *req)
sys->stat.r.peer_active_nr--;
else if (is_gateway_op(req->op))
sys->stat.r.gway_active_nr--;
+ else if (hdr->opcode == SD_OP_FLUSH_VDI)
+ sys->stat.r.gway_active_nr--;
}
static void queue_request(struct request *req)
--
1.8.1.2
More information about the sheepdog
mailing list