From 976296766b80f6c1f853db0e217d47972405e1eb Mon Sep 17 00:00:00 2001 From: Can Erkin Acar Date: Sun, 2 Nov 2008 07:14:17 +0000 Subject: Add the option to sort by requests to the pool view, and document the hotkeys 'o' to select and 'r' to reverse column orderings. --- usr.bin/systat/pool.c | 25 +++++++++++++++++++++---- usr.bin/systat/systat.1 | 26 +++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 5 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/systat/pool.c b/usr.bin/systat/pool.c index c6bbede69dc..1f7500dc722 100644 --- a/usr.bin/systat/pool.c +++ b/usr.bin/systat/pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pool.c,v 1.1 2008/11/02 06:23:28 canacar Exp $ */ +/* $OpenBSD: pool.c,v 1.2 2008/11/02 07:14:16 canacar Exp $ */ /* * Copyright (c) 2008 Can Erkin Acar * @@ -32,6 +32,7 @@ void showpool(int k); /* qsort callbacks */ int sort_name_callback(const void *s1, const void *s2); +int sort_req_callback(const void *s1, const void *s2); struct pool_info { char name[32]; @@ -82,7 +83,8 @@ field_def *view_pool_0[] = { }; order_type pool_order_list[] = { - {"name", "name", 0, sort_name_callback}, + {"name", "name", 'N', sort_name_callback}, + {"requests", "requests", 'Q', sort_req_callback}, {NULL, NULL, 0, NULL} }; @@ -105,7 +107,22 @@ sort_name_callback(const void *s1, const void *s2) p1 = (struct pool_info *)s1; p2 = (struct pool_info *)s2; - return strcmp(p1->name, p2->name); + return strcmp(p1->name, p2->name) * sortdir; +} + +int +sort_req_callback(const void *s1, const void *s2) +{ + struct pool_info *p1, *p2; + p1 = (struct pool_info *)s1; + p2 = (struct pool_info *)s2; + + if (p1->pool.pr_nget < p2->pool.pr_nget) + return sortdir; + if (p1->pool.pr_nget > p2->pool.pr_nget) + return -sortdir; + + return sort_name_callback(s1, s2); } void @@ -127,7 +144,7 @@ sort_pool(void) if (num_pools <= 0) return; - qsort(pools, num_pools, sizeof(struct pool_info), ordering->func); + mergesort(pools, num_pools, sizeof(struct pool_info), ordering->func); } int diff --git a/usr.bin/systat/systat.1 b/usr.bin/systat/systat.1 index 151f3aee7d6..800933241e8 100644 --- a/usr.bin/systat/systat.1 +++ b/usr.bin/systat/systat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: systat.1,v 1.68 2008/11/02 06:23:28 canacar Exp $ +.\" $OpenBSD: systat.1,v 1.69 2008/11/02 07:14:16 canacar Exp $ .\" $NetBSD: systat.1,v 1.6 1996/05/10 23:16:39 thorpej Exp $ .\" .\" Copyright (c) 1985, 1990, 1993 @@ -153,12 +153,18 @@ line typed as a command. While entering a command the current character erase, word erase, and line kill characters may be used. +.It Ic o +Select the next ordering which sorts the rows according to a +combination of columns. Available orderings depend on the +view. Not all views support orderings. .It Ic p Pause .Nm . .It Ic q Exit .Nm . +.It Ic r +Reverse the selected ordering if supported by the view. .It Ic ^A \*(Ba Aq Ic Home Jump to the beginning of the current view. .It Ic ^B \*(Ba Aq Ic right arrow @@ -330,6 +336,10 @@ Display kernel .Xr pool 9 statistics similar to the output of .Cm vmstat Fl m . +Available orderings are: +.Ic name +and +.Ic requests . .It Ic queues Display statistics about the active .Xr altq 9 @@ -346,6 +356,20 @@ in a format similar to that of .It Ic states Display pf states statistics, similar to the output of .Cm pfctl Fl s Cm states . +Available orderings are: +.Ic none , +.Ic bytes , +.Ic expiry , +.Ic packets , +.Ic age , +.Ic source address , +.Ic source port , +.Ic destination address , +.Ic destination port , +.Ic rate , +and +.Ic peak +columns. .It Ic swap Show information about swap space usage on all the swap areas compiled into the kernel. -- cgit v1.2.3