new /proc/vmstat fields

This commit is contained in:
albert 2004-08-27 14:23:36 +00:00
parent 1754df6025
commit af2077f22d
6 changed files with 99 additions and 18 deletions

3
NEWS
View File

@ -1,6 +1,9 @@
procps-3.2.3 --> procps-3.2.4 procps-3.2.3 --> procps-3.2.4
support 64-bit MIPS with n32 binary
sparc32 optimized for sparc32 again
ps: more room for some columns ps: more room for some columns
watch: passes COLUMNS and LINES in environment
procps-3.2.2 --> procps-3.2.3 procps-3.2.2 --> procps-3.2.3

View File

@ -44,6 +44,8 @@ ifeq ($(SHARED),1)
ALL += proc/$(SONAME) ALL += proc/$(SONAME)
INSTALL += ldconfig INSTALL += ldconfig
LIBFLAGS := -DSHARED=1 $(FPIC) LIBFLAGS := -DSHARED=1 $(FPIC)
# This is in gcc 3.5, but exported functions must be marked.
#LIBFLAGS += $(call check_gcc,-fvisibility=hidden,)
LIBPROC := proc/$(SONAME) LIBPROC := proc/$(SONAME)
else else
ALL += proc/$(ANAME) ALL += proc/$(ANAME)

View File

@ -90,10 +90,13 @@
// so no need to do dynamic linking at run-time. // so no need to do dynamic linking at run-time.
// This might work with slightly older compilers too. // This might work with slightly older compilers too.
#define HIDDEN __attribute__((visibility("hidden"))) #define HIDDEN __attribute__((visibility("hidden")))
// The opposite, in case -fvisibility=hidden used
#define EXPORT __attribute__((visibility("default")))
// Tell g++ that a function won't throw exceptions. // Tell g++ that a function won't throw exceptions.
#define NOTHROW __attribute__((__nothrow__)) #define NOTHROW __attribute__((__nothrow__))
#else #else
#define HIDDEN #define HIDDEN
#define EXPORT
#define NOTHROW #define NOTHROW
#endif #endif

View File

@ -488,7 +488,7 @@ unsigned long kb_inact_laundry;
unsigned long kb_inact_dirty; unsigned long kb_inact_dirty;
unsigned long kb_inact_clean; unsigned long kb_inact_clean;
unsigned long kb_inact_target; unsigned long kb_inact_target;
unsigned long kb_swap_cached; /* late 2.4 only */ unsigned long kb_swap_cached; /* late 2.4 and 2.6+ only */
/* derived values */ /* derived values */
unsigned long kb_swap_used; unsigned long kb_swap_used;
unsigned long kb_main_used; unsigned long kb_main_used;
@ -501,6 +501,10 @@ unsigned long kb_dirty;
unsigned long kb_inactive; unsigned long kb_inactive;
unsigned long kb_mapped; unsigned long kb_mapped;
unsigned long kb_pagetables; unsigned long kb_pagetables;
// seen on a 2.6.x kernel:
unsigned long kb_vmalloc_chunk;
unsigned long kb_vmalloc_total;
unsigned long kb_vmalloc_used;
void meminfo(void){ void meminfo(void){
char namebuf[16]; /* big enough to hold any row name */ char namebuf[16]; /* big enough to hold any row name */
@ -525,7 +529,7 @@ void meminfo(void){
{"LowTotal", &kb_low_total}, {"LowTotal", &kb_low_total},
{"Mapped", &kb_mapped}, // kB version of vmstat nr_mapped {"Mapped", &kb_mapped}, // kB version of vmstat nr_mapped
{"MemFree", &kb_main_free}, // important {"MemFree", &kb_main_free}, // important
{"MemShared", &kb_main_shared}, // important {"MemShared", &kb_main_shared}, // important, but now gone!
{"MemTotal", &kb_main_total}, // important {"MemTotal", &kb_main_total}, // important
{"PageTables", &kb_pagetables}, // kB version of vmstat nr_page_table_pages {"PageTables", &kb_pagetables}, // kB version of vmstat nr_page_table_pages
{"ReverseMaps", &nr_reversemaps}, // same as vmstat nr_page_table_pages {"ReverseMaps", &nr_reversemaps}, // same as vmstat nr_page_table_pages
@ -533,6 +537,9 @@ void meminfo(void){
{"SwapCached", &kb_swap_cached}, {"SwapCached", &kb_swap_cached},
{"SwapFree", &kb_swap_free}, // important {"SwapFree", &kb_swap_free}, // important
{"SwapTotal", &kb_swap_total}, // important {"SwapTotal", &kb_swap_total}, // important
{"VmallocChunk", &kb_vmalloc_chunk},
{"VmallocTotal", &kb_vmalloc_total},
{"VmallocUsed", &kb_vmalloc_used},
{"Writeback", &kb_writeback}, // kB version of vmstat nr_writeback {"Writeback", &kb_writeback}, // kB version of vmstat nr_writeback
}; };
const int mem_table_count = sizeof(mem_table)/sizeof(mem_table_struct); const int mem_table_count = sizeof(mem_table)/sizeof(mem_table_struct);
@ -621,29 +628,48 @@ void vminfo(void){
char *tail; char *tail;
static const vm_table_struct vm_table[] = { static const vm_table_struct vm_table[] = {
{"allocstall", &vm_allocstall}, {"allocstall", &vm_allocstall},
{"kswapd_inodesteal", &vm_},
{"kswapd_steal", &vm_kswapd_steal}, {"kswapd_steal", &vm_kswapd_steal},
{"nr_dirty", &vm_nr_dirty}, // page version of meminfo Dirty {"nr_dirty", &vm_nr_dirty}, // page version of meminfo Dirty
{"nr_mapped", &vm_nr_mapped}, // page version of meminfo Mapped {"nr_mapped", &vm_nr_mapped}, // page version of meminfo Mapped
{"nr_page_table_pages", &vm_nr_page_table_pages},// same as meminfo PageTables {"nr_page_table_pages", &vm_nr_page_table_pages},// same as meminfo PageTables
{"nr_pagecache", &vm_nr_pagecache}, // gone in 2.5.66+ kernels {"nr_pagecache", &vm_nr_pagecache}, // gone in 2.5.66+ kernels
{"nr_reverse_maps", &vm_nr_reverse_maps}, // page version of meminfo ReverseMaps {"nr_reverse_maps", &vm_nr_reverse_maps}, // page version of meminfo ReverseMaps GONE
{"nr_slab", &vm_nr_slab}, // page version of meminfo Slab {"nr_slab", &vm_nr_slab}, // page version of meminfo Slab
{"nr_unstable", &vm_},
{"nr_writeback", &vm_nr_writeback}, // page version of meminfo Writeback {"nr_writeback", &vm_nr_writeback}, // page version of meminfo Writeback
{"pageoutrun", &vm_pageoutrun}, {"pageoutrun", &vm_pageoutrun},
{"pgactivate", &vm_pgactivate}, {"pgactivate", &vm_pgactivate},
{"pgalloc", &vm_pgalloc}, {"pgalloc", &vm_pgalloc}, // GONE (now separate dma,high,normal)
{"pgalloc_dma", &vm_},
{"pgalloc_high", &vm_},
{"pgalloc_normal", &vm_},
{"pgdeactivate", &vm_pgdeactivate}, {"pgdeactivate", &vm_pgdeactivate},
{"pgfault", &vm_pgfault}, {"pgfault", &vm_pgfault},
{"pgfree", &vm_pgfree}, {"pgfree", &vm_pgfree},
{"pginodesteal", &vm_},
{"pgmajfault", &vm_pgmajfault}, {"pgmajfault", &vm_pgmajfault},
{"pgpgin", &vm_pgpgin}, // important {"pgpgin", &vm_pgpgin}, // important
{"pgpgout", &vm_pgpgout}, // important {"pgpgout", &vm_pgpgout}, // important
{"pgrefill", &vm_pgrefill}, {"pgrefill", &vm_pgrefill}, // GONE (now separate dma,high,normal)
{"pgrefill_dma", &vm_},
{"pgrefill_high", &vm_},
{"pgrefill_normal", &vm_},
{"pgrotated", &vm_pgrotated}, {"pgrotated", &vm_pgrotated},
{"pgscan", &vm_pgscan}, {"pgscan", &vm_pgscan}, // GONE (now separate direct,kswapd and dma,high,normal)
{"pgsteal", &vm_pgsteal}, {"pgscan_direct_dma", &vm_},
{"pgscan_direct_high", &vm_},
{"pgscan_direct_normal", &vm_},
{"pgscan_kswapd_dma", &vm_},
{"pgscan_kswapd_high", &vm_},
{"pgscan_kswapd_normal", &vm_},
{"pgsteal", &vm_pgsteal}, // GONE (now separate dma,high,normal)
{"pgsteal_dma", &vm_},
{"pgsteal_high", &vm_},
{"pgsteal_normal", &vm_},
{"pswpin", &vm_pswpin}, // important {"pswpin", &vm_pswpin}, // important
{"pswpout", &vm_pswpout} // important {"pswpout", &vm_pswpout} // important
{"slabs_scanned", &vm_},
}; };
const int vm_table_count = sizeof(vm_table)/sizeof(vm_table_struct); const int vm_table_count = sizeof(vm_table)/sizeof(vm_table_struct);

15
ps/ps.1
View File

@ -550,8 +550,13 @@ parent process repeatedly forks off short\-lived children to do work.
.TP .TP
.B c .B c
Show the true command name. This is derived from the name of the Show the true command name. This is derived from the name of the
executable file, rather than from the argv value which could be executable file, rather than from the argv value. Command arguments
modified by a user. Command arguments are not shown. and any modifications to them (see\ \fIsetproctitle\fR(3)) are
thus not shown. This option
effectively turns the \fBargs\fR format keyword into the \fBcomm\fR
format keyword; it is useful with the \fB\-f\fR format option and with
the various BSD\-style format options, which all normally
display the command arguments.
See the \fB\-f\fR option, the format keyword \fBargs\fR, and the See the \fB\-f\fR option, the format keyword \fBargs\fR, and the
format keyword \fBcomm\fR. format keyword \fBcomm\fR.
@ -745,10 +750,6 @@ This is not ideal, and\ it does not conform to the
standards that \fBps\fR otherwise conforms\ to. standards that \fBps\fR otherwise conforms\ to.
CPU\ usage is unlikely to add up to exactly\ 100%. CPU\ usage is unlikely to add up to exactly\ 100%.
Programs swapped out to disk will be shown without command line arguments,
and unless the \fBc\fR option is given,
in\ brackets.
The SIZE and RSS fields don't count some parts of a process including the The SIZE and RSS fields don't count some parts of a process including the
page tables, kernel stack, struct thread_info, and struct task_struct. page tables, kernel stack, struct thread_info, and struct task_struct.
This is usually at least 20\ KiB of memory that is always resident. This is usually at least 20\ KiB of memory that is always resident.
@ -946,6 +947,7 @@ keyword, the \fB\-f\fR option, and the \fBc\fR option.
When specified last, this column will extend to the edge of the display. When specified last, this column will extend to the edge of the display.
If \fBps\fR can not determine display width, as when output is redirected If \fBps\fR can not determine display width, as when output is redirected
(piped) into a file or another command, the width of this column is undefined. (piped) into a file or another command, the width of this column is undefined.
(it may be 80, unlimited, determined by the \fBTERM\fR variable, and so on)
The \fBCOLUMNS\fR environment variable or \fB\-\-cols\fR option may The \fBCOLUMNS\fR environment variable or \fB\-\-cols\fR option may
be used to exactly determine the width in this case. be used to exactly determine the width in this case.
The \fBw\fR or \fB\-w\fR option may be also be used to adjust width. The \fBw\fR or \fB\-w\fR option may be also be used to adjust width.
@ -1026,6 +1028,7 @@ keyword, the \fB\-f\fR option, and the \fBc\fR option.
When specified last, this column will extend to the edge of the display. When specified last, this column will extend to the edge of the display.
If \fBps\fR can not determine display width, as when output is redirected If \fBps\fR can not determine display width, as when output is redirected
(piped) into a file or another command, the width of this column is undefined. (piped) into a file or another command, the width of this column is undefined.
(it may be 80, unlimited, determined by the \fBTERM\fR variable, and so on)
The \fBCOLUMNS\fR environment variable or \fB\-\-cols\fR option may The \fBCOLUMNS\fR environment variable or \fB\-\-cols\fR option may
be used to exactly determine the width in this case. be used to exactly determine the width in this case.
The \fBw\fR or \fB\-w\fR option may be also be used to adjust width. The \fBw\fR or \fB\-w\fR option may be also be used to adjust width.

48
watch.c
View File

@ -25,6 +25,11 @@
#include <locale.h> #include <locale.h>
#include "proc/procps.h" #include "proc/procps.h"
#ifdef FORCE_8BIT
#undef isprint
#define isprint(x) ( (x>=' '&&x<='~') || (x>=0xa0) )
#endif
static struct option longopts[] = { static struct option longopts[] = {
{"differences", optional_argument, 0, 'd'}, {"differences", optional_argument, 0, 'd'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
@ -77,15 +82,54 @@ winch_handler(int notused)
screen_size_changed = 1; screen_size_changed = 1;
} }
static char env_col_buf[24];
static char env_row_buf[24];
static int incoming_cols;
static int incoming_rows;
static void static void
get_terminal_size(void) get_terminal_size(void)
{ {
struct winsize w; struct winsize w;
if(!incoming_cols){ // have we checked COLUMNS?
const char *s = getenv("COLUMNS");
incoming_cols = -1;
if(s && *s){
long t;
char *endptr;
t = strtol(s, &endptr, 0);
if(!*endptr && (t>0) && (t<(long)666)) incoming_cols = (int)t;
width = incoming_cols;
snprintf(env_col_buf, sizeof env_col_buf, "COLUMNS=%d", width);
putenv(env_col_buf);
}
}
if(!incoming_rows){ // have we checked LINES?
const char *s = getenv("LINES");
incoming_rows = -1;
if(s && *s){
long t;
char *endptr;
t = strtol(s, &endptr, 0);
if(!*endptr && (t>0) && (t<(long)666)) incoming_rows = (int)t;
height = incoming_rows;
snprintf(env_row_buf, sizeof env_row_buf, "LINES=%d", height);
putenv(env_row_buf);
}
}
if (incoming_cols<0 || incoming_rows<0){
if (ioctl(2, TIOCGWINSZ, &w) == 0) { if (ioctl(2, TIOCGWINSZ, &w) == 0) {
if (w.ws_row > 0) if (incoming_rows<0 && w.ws_row > 0){
height = w.ws_row; height = w.ws_row;
if (w.ws_col > 0) snprintf(env_row_buf, sizeof env_row_buf, "LINES=%d", height);
putenv(env_row_buf);
}
if (incoming_cols<0 && w.ws_col > 0){
width = w.ws_col; width = w.ws_col;
snprintf(env_col_buf, sizeof env_col_buf, "COLUMNS=%d", width);
putenv(env_col_buf);
}
}
} }
} }