aboutsummaryrefslogtreecommitdiff
path: root/contrib/top/display.c
diff options
context:
space:
mode:
authorAllan Jude <allanjude@FreeBSD.org>2017-03-17 00:46:50 +0000
committerAllan Jude <allanjude@FreeBSD.org>2017-03-17 00:46:50 +0000
commit1dbfa4b5305d35ebfc9e6b9f1d2e8e53a928722b (patch)
tree5a89c04969fdf260142e883c4243673c974bc67f /contrib/top/display.c
parent9dbf8c467ec84aa5ec5e61125d111220562b364c (diff)
downloadsrc-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/display.c')
-rw-r--r--contrib/top/display.c54
1 files changed, 54 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));