summaryrefslogtreecommitdiffstats
path: root/contrib/top
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2012-06-27 18:08:48 +0000
committerjhb <jhb@FreeBSD.org>2012-06-27 18:08:48 +0000
commita461bd15071993dd2121ed8ddfaee9fef880cd56 (patch)
tree35d3ccc9768fc207017486150335cd6c1e66bfc4 /contrib/top
parent31577c974349e71766902ec165bf02f12c744838 (diff)
downloadFreeBSD-src-a461bd15071993dd2121ed8ddfaee9fef880cd56.zip
FreeBSD-src-a461bd15071993dd2121ed8ddfaee9fef880cd56.tar.gz
Add a new line to top that provides a brief summary of the ZFS ARC memory
usage on hosts using ZFS. The new line displays the total amount of RAM used by the ARC along with the size of MFU, MRU, anonymous (in flight), headers, and other (miscellaneous) sub-categories. The line is not displayed on systems that are not using ZFS. Reviewed by: avg, fs@ MFC after: 3 days
Diffstat (limited to 'contrib/top')
-rw-r--r--contrib/top/display.c45
-rw-r--r--contrib/top/layout.h2
-rw-r--r--contrib/top/machine.h2
-rw-r--r--contrib/top/top.c6
4 files changed, 55 insertions, 0 deletions
diff --git a/contrib/top/display.c b/contrib/top/display.c
index 89795c0..e65ae24 100644
--- a/contrib/top/display.c
+++ b/contrib/top/display.c
@@ -66,6 +66,7 @@ char *screenbuf = NULL;
static char **procstate_names;
static char **cpustate_names;
static char **memory_names;
+static char **arc_names;
static char **swap_names;
static int num_procstates;
@@ -100,6 +101,8 @@ int x_brkdn = 15;
int y_brkdn = 1;
int x_mem = 5;
int y_mem = 3;
+int x_arc = 5;
+int y_arc = 4;
int x_swap = 6;
int y_swap = 4;
int y_message = 5;
@@ -216,6 +219,8 @@ struct statics *statics;
num_memory = string_count(memory_names);
lmemory = (int *)malloc(num_memory * sizeof(int));
+ arc_names = statics->arc_names;
+
/* calculate starting columns where needed */
cpustate_total_length = 0;
pp = cpustate_names;
@@ -627,6 +632,46 @@ int *stats;
}
/*
+ * *_arc(stats) - print "ARC: " followed by the ARC summary string
+ *
+ * Assumptions: cursor is on "lastline"
+ * for i_arc ONLY: cursor is on the previous line
+ */
+char arc_buffer[MAX_COLS];
+
+i_arc(stats)
+
+int *stats;
+
+{
+ if (arc_names == NULL)
+ return (0);
+
+ fputs("\nARC: ", stdout);
+ lastline++;
+
+ /* format and print the memory summary */
+ summary_format(arc_buffer, stats, arc_names);
+ fputs(arc_buffer, stdout);
+}
+
+u_arc(stats)
+
+int *stats;
+
+{
+ static char new[MAX_COLS];
+
+ if (arc_names == NULL)
+ return (0);
+
+ /* format the new line */
+ summary_format(new, stats, arc_names);
+ line_update(arc_buffer, new, x_arc, y_arc);
+}
+
+
+/*
* *_swap(stats) - print "Swap: " followed by the swap summary string
*
* Assumptions: cursor is on "lastline"
diff --git a/contrib/top/layout.h b/contrib/top/layout.h
index 1b2564e..a04fce2 100644
--- a/contrib/top/layout.h
+++ b/contrib/top/layout.h
@@ -19,6 +19,8 @@ extern int x_brkdn; /* 15 */
extern int y_brkdn; /* 1 */
extern int x_mem; /* 5 */
extern int y_mem; /* 3 */
+extern int x_arc; /* 5 */
+extern int y_arc; /* 4 */
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 3e1af16..699c755 100644
--- a/contrib/top/machine.h
+++ b/contrib/top/machine.h
@@ -16,6 +16,7 @@ struct statics
char **procstate_names;
char **cpustate_names;
char **memory_names;
+ char **arc_names;
char **swap_names;
#ifdef ORDER
char **order_names;
@@ -42,6 +43,7 @@ struct system_info
int *procstates;
int *cpustates;
int *memory;
+ int *arc;
int *swap;
struct timeval boottime;
int ncpus;
diff --git a/contrib/top/top.c b/contrib/top/top.c
index 50bc9b9..c2eb35d 100644
--- a/contrib/top/top.c
+++ b/contrib/top/top.c
@@ -121,6 +121,8 @@ int i_cpustates();
int u_cpustates();
int i_memory();
int u_memory();
+int i_arc();
+int u_arc();
int i_swap();
int u_swap();
int i_message();
@@ -135,6 +137,7 @@ int (*d_loadave)() = i_loadave;
int (*d_procstates)() = i_procstates;
int (*d_cpustates)() = i_cpustates;
int (*d_memory)() = i_memory;
+int (*d_arc)() = i_arc;
int (*d_swap)() = i_swap;
int (*d_message)() = i_message;
int (*d_header)() = i_header;
@@ -647,6 +650,7 @@ restart:
/* display memory stats */
(*d_memory)(system_info.memory);
+ (*d_arc)(system_info.arc);
/* display swap stats */
(*d_swap)(system_info.swap);
@@ -712,6 +716,7 @@ restart:
d_procstates = u_procstates;
d_cpustates = u_cpustates;
d_memory = u_memory;
+ d_arc = u_arc;
d_swap = u_swap;
d_message = u_message;
d_header = u_header;
@@ -1129,6 +1134,7 @@ reset_display()
d_procstates = i_procstates;
d_cpustates = i_cpustates;
d_memory = i_memory;
+ d_arc = i_arc;
d_swap = i_swap;
d_message = i_message;
d_header = i_header;
OpenPOWER on IntegriCloud