diff options
author | Allan Jude <allanjude@FreeBSD.org> | 2017-03-17 00:46:50 +0000 |
---|---|---|
committer | Allan Jude <allanjude@FreeBSD.org> | 2017-03-17 00:46:50 +0000 |
commit | 1dbfa4b5305d35ebfc9e6b9f1d2e8e53a928722b (patch) | |
tree | 5a89c04969fdf260142e883c4243673c974bc67f /contrib/top | |
parent | 9dbf8c467ec84aa5ec5e61125d111220562b364c (diff) | |
download | src-1dbfa4b5305d35ebfc9e6b9f1d2e8e53a928722b.tar.gz src-1dbfa4b5305d35ebfc9e6b9f1d2e8e53a928722b.zip |
Add ZFS compressed ARC stats to top(1)
Provides:
amount of compressed data
logical size of compressed data (how much it would have taken uncompressed)
compression ratio (logical size : total ARC size)
Overhead (space consumed for compression headers)
Example output:
ARC: 31G Total, 18G MFU, 9067M MRU, 2236K Anon, 615M Header, 2947M Other
25G Compressed, 54G Uncompressed, 1.76:1 Ratio, 2265M Overhead
Reviewed by: jpaetzel, smh, imp, jhb (previous version)
MFC after: 2 week
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D9829
Notes
Notes:
svn path=/head/; revision=315435
Diffstat (limited to 'contrib/top')
-rw-r--r-- | contrib/top/display.c | 54 | ||||
-rw-r--r-- | contrib/top/display.h | 2 | ||||
-rw-r--r-- | contrib/top/layout.h | 2 | ||||
-rw-r--r-- | contrib/top/machine.h | 2 | ||||
-rw-r--r-- | contrib/top/top.c | 4 |
5 files changed, 64 insertions, 0 deletions
diff --git a/contrib/top/display.c b/contrib/top/display.c index ade61d660726..abf3ef5ece7a 100644 --- a/contrib/top/display.c +++ b/contrib/top/display.c @@ -69,6 +69,7 @@ static char **procstate_names; static char **cpustate_names; static char **memory_names; static char **arc_names; +static char **carc_names; static char **swap_names; static int num_procstates; @@ -105,6 +106,8 @@ int x_mem = 5; int y_mem = 3; int x_arc = 5; int y_arc = 4; +int x_carc = 5; +int y_carc = 5; int x_swap = 6; int y_swap = 4; int y_message = 5; @@ -222,6 +225,7 @@ struct statics *statics; lmemory = (int *)malloc(num_memory * sizeof(int)); arc_names = statics->arc_names; + carc_names = statics->carc_names; /* calculate starting columns where needed */ cpustate_total_length = 0; @@ -684,6 +688,47 @@ int *stats; line_update(arc_buffer, new, x_arc, y_arc); } + +/* + * *_carc(stats) - print "Compressed ARC: " followed by the summary string + * + * Assumptions: cursor is on "lastline" + * for i_carc ONLY: cursor is on the previous line + */ +char carc_buffer[MAX_COLS]; + +void +i_carc(stats) + +int *stats; + +{ + if (carc_names == NULL) + return; + + fputs("\n ", stdout); + lastline++; + + /* format and print the memory summary */ + summary_format(carc_buffer, stats, carc_names); + fputs(carc_buffer, stdout); +} + +void +u_carc(stats) + +int *stats; + +{ + static char new[MAX_COLS]; + + if (carc_names == NULL) + return; + + /* format the new line */ + summary_format(new, stats, carc_names); + line_update(carc_buffer, new, x_carc, y_carc); +} /* * *_swap(stats) - print "Swap: " followed by the swap summary string @@ -1174,6 +1219,7 @@ register char **names; register int num; register char *thisname; register int useM = No; + char rbuf[6]; /* format each number followed by its string */ p = str; @@ -1194,6 +1240,14 @@ register char **names; /* skip over the K, since it was included by format_k */ p = strecpy(p, thisname+1); } + /* is this number a ratio? */ + else if (thisname[0] == ':') + { + (void) snprintf(rbuf, sizeof(rbuf), "%.2f", + (float)*(numbers - 2) / (float)num); + p = strecpy(p, rbuf); + p = strecpy(p, thisname); + } else { p = strecpy(p, itoa(num)); diff --git a/contrib/top/display.h b/contrib/top/display.h index 5d5a07a1aece..a34fb348ac7f 100644 --- a/contrib/top/display.h +++ b/contrib/top/display.h @@ -16,6 +16,7 @@ char *cpustates_tag(void); void display_header(int t); int display_init(struct statics *statics); void i_arc(int *stats); +void i_carc(int *stats); void i_cpustates(int *states); void i_loadave(int mpid, double *avenrun); void i_memory(int *stats); @@ -29,6 +30,7 @@ void new_message(); int readline(char *buffer, int size, int numeric); char *trim_header(char *text); void u_arc(int *stats); +void u_carc(int *stats); void u_cpustates(int *states); void u_endscreen(int hi); void u_header(char *text); diff --git a/contrib/top/layout.h b/contrib/top/layout.h index a04fce215b07..ac2fa4780c31 100644 --- a/contrib/top/layout.h +++ b/contrib/top/layout.h @@ -21,6 +21,8 @@ extern int x_mem; /* 5 */ extern int y_mem; /* 3 */ extern int x_arc; /* 5 */ extern int y_arc; /* 4 */ +extern int x_carc; /* 5 */ +extern int y_carc; /* 5 */ extern int x_swap; /* 6 */ extern int y_swap; /* 4 */ extern int y_message; /* 5 */ diff --git a/contrib/top/machine.h b/contrib/top/machine.h index 6f2844d387b1..8d00ab89fdbe 100644 --- a/contrib/top/machine.h +++ b/contrib/top/machine.h @@ -21,6 +21,7 @@ struct statics char **cpustate_names; char **memory_names; char **arc_names; + char **carc_names; char **swap_names; #ifdef ORDER char **order_names; @@ -48,6 +49,7 @@ struct system_info int *cpustates; int *memory; int *arc; + int *carc; int *swap; struct timeval boottime; int ncpus; diff --git a/contrib/top/top.c b/contrib/top/top.c index c74c1d1aa595..cf2f5e7c6f3b 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -125,6 +125,7 @@ void (*d_procstates)() = i_procstates; void (*d_cpustates)() = i_cpustates; void (*d_memory)() = i_memory; void (*d_arc)() = i_arc; +void (*d_carc)() = i_carc; void (*d_swap)() = i_swap; void (*d_message)() = i_message; void (*d_header)() = i_header; @@ -658,6 +659,7 @@ restart: /* display memory stats */ (*d_memory)(system_info.memory); (*d_arc)(system_info.arc); + (*d_carc)(system_info.carc); /* display swap stats */ (*d_swap)(system_info.swap); @@ -724,6 +726,7 @@ restart: d_cpustates = u_cpustates; d_memory = u_memory; d_arc = u_arc; + d_carc = u_carc; d_swap = u_swap; d_message = u_message; d_header = u_header; @@ -1190,6 +1193,7 @@ reset_display() d_cpustates = i_cpustates; d_memory = i_memory; d_arc = i_arc; + d_carc = i_carc; d_swap = i_swap; d_message = i_message; d_header = i_header; |