[sheepdog] [PATCH] sheep: add RPS (request per second) to sd_stat

Liu Yuan namei.unix at gmail.com
Wed Jan 8 03:40:41 CET 2014


This is useful to determine the transaction per second the sheep daemon perform.
Also fixed a bug that READ and WRITE column name are reverse.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 dog/common.c |  2 +-
 dog/dog.h    |  1 +
 dog/node.c   | 18 +++++++++++-------
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/dog/common.c b/dog/common.c
index 0535a44..93adb85 100644
--- a/dog/common.c
+++ b/dog/common.c
@@ -14,7 +14,7 @@
 #include "sockfd_cache.h"
 #include "fec.h"
 
-static char *strnumber_raw(uint64_t _size, bool raw)
+char *strnumber_raw(uint64_t _size, bool raw)
 {
 	const char *units[] = {"MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
 	static __thread struct size_str {
diff --git a/dog/dog.h b/dog/dog.h
index 73518d4..12dfc52 100644
--- a/dog/dog.h
+++ b/dog/dog.h
@@ -66,6 +66,7 @@ extern int sd_nodes_nr;
 
 bool is_current(const struct sd_inode *i);
 char *strnumber(uint64_t _size);
+char *strnumber_raw(uint64_t _size, bool raw);
 typedef void (*vdi_parser_func_t)(uint32_t vid, const char *name,
 				  const char *tag, uint32_t snapid,
 				  uint32_t flags,
diff --git a/dog/node.c b/dog/node.c
index 71486a0..b2b1c86 100644
--- a/dog/node.c
+++ b/dog/node.c
@@ -298,27 +298,31 @@ again:
 			first = false;
 		}
 		printf("%s%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t"
-		       "%"PRIu64"\t%"PRIu64"\t%s\t%s\t%s\t%s\n",
+		       "%"PRIu64"\t%"PRIu64"\t%s\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",
+		       "All WR\tAll RD\tWRBW\tRDBW\tRPS\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_write_nr, stat.r.gway_total_read_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));
+		       strnumber(stat.r.gway_total_tx - last.r.gway_total_tx),
+		       strnumber_raw(stat.r.gway_total_nr -
+				     last.r.gway_total_nr, true));
 		printf("%s%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t"
-		       "%"PRIu64"\t%"PRIu64"\t%s\t%s\t%s\t%s\n",
+		       "%"PRIu64"\t%"PRIu64"\t%s\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_write_nr, stat.r.peer_total_read_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));
+		       strnumber(stat.r.peer_total_tx - last.r.peer_total_tx),
+		       strnumber_raw(stat.r.peer_total_nr -
+				     last.r.peer_total_nr, true));
 		last = stat;
 		sleep(1);
 		goto again;
-- 
1.8.1.2




More information about the sheepdog mailing list