Commit Graph

71 Commits

Author SHA1 Message Date
Craig Small
a68d628adf vmstat: Add NEWS and revert comment from prev
Reverted the translation hint as the fields are used for both
normal and wide modes, so need to fit the smaller of the two.

Added NEWS item

References:
 commit 01c1b2345e
2020-05-12 18:57:26 +10:00
Ivan Skytte Jørgensen
01c1b2345e Use wide columns for r/b too in wide mode
2 digits are not enough for number of runnable/blocked processes on modern
systems. Changed to 4 digits with given the -w option.
2020-05-12 18:51:41 +10:00
Qualys Security Advisory
0bfe708c4b vmstat: Prevent out-of-bounds writes in new_header() and diskheader().
This does not happen with the default string (" -----timestamp-----"),
but this string is translated (to unknown lengths).
2018-06-13 22:06:51 +10:00
Qualys Security Advisory
0b55f0dc80 vmstat: Check return values of localtime() and strftime().
Otherwise it leads to NULL-pointer dereferences (in case of localtime()
errors) and indeterminate contents of timebuf (in case of strftime()
errors).
2018-06-13 22:06:30 +10:00
Qualys Security Advisory
b4f4718481 vmstat: Replace memcmp() with strncmp().
Otherwise this may read out-of-bounds (there is no guarantee that 5
bytes are actually available at partition/optarg).
2018-06-13 22:06:14 +10:00
Qualys Security Advisory
4ce81d4dcc vmstat: getopt*() returns -1 when done, not EOF.
Luckily, EOF is usually -1, but this is not guaranteed by the standard.
2018-06-13 22:05:57 +10:00
Craig Small
cae3f1438f vmstat: Fix alignment for disk partition format
The disk partition format translation hint, the actual text and the
printf statements were all diagreeing with each other. This meant
the disk partition output from vmstat was a mess.

Now all the titles and values line up and everything is right-aligned
which looks better than some half-hearted attempt at center-aligned
for titles and right-aligned for values.

Thanks to @goeran for the heads-up in #69
2017-09-25 09:09:57 +10:00
Fredrik Fornwall
00279d692a Use <dirent.h> instead of <sys/dir.h>
Using <dirent.h> and struct dirent instead of <sys/dir.h> and struct direct
is preferred and works on Android which lacks sys/dir.h.

See:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
2014-08-26 16:01:57 +02:00
Jaromir Capik
dc072aced7 vmstat: Fixing format-security flaws
Previously the headers were printed directly without
the format specifier. That way is considered insecure
and leads to build errors with -Werror=format-security
flag set.
2014-02-05 17:09:45 +01:00
Jaromir Capik
4fcd56bf58 vmstat: Support for timestamps with '-t' & fix for '-wd'
From now the vmstat can append a timestamp to each line in the
VMSTAT and DISKSTAT mode. You can achieve that with the '-t'
switch.
The '-w' switch now works in the DISKSTAT mode too.
2014-02-04 19:10:42 +01:00
Jaromir Capik
1baf31be9b vmstat: wide output still not wide enough?
8 digits per memory column is apparently still too low
for systems with 128TB of RAM. Anyway, setting the limit
to 999TB (12 digits) must be sufficient for now as it
produces wide gaps on "regular" computers.
This commit also increases the number of digits per cpu
columns from 2 to 3 as some of them can hit the 100%
maximum in corner cases.
2014-01-20 19:59:39 +01:00
Jaromir Capik
a8a4a4f595 vmstat: support for time stolen from virtual machines
Surprisingly the code for the 'st' column was added in the past,
but wasn't enabled. The vmstat manual already contains the 'st'
column and this commit finally enables the feature.
2013-11-25 17:39:14 +01:00
Jaromir Capik
1b97942c8e vmstat: -w switch for wider output
This is a rework of the merge request #5 that unconditionally
forced the output to cross the 80 chars border.
With this commit users can switch to the wide output mode
with the -w option.
2013-11-25 16:56:10 +01:00
Craig Small
6437aa08d4 Update options to single strings
To assist the translators, each option is a separate string.
This means if we add/change/delete an option the remaining ones
will just keep working and only the impacted option needs some
translation work on it.
2013-10-11 10:07:10 +11:00
Rainer Müller
042776e04c configure: check for program_invocation_name
For portabiliy, check for program_invocation_name during configure and
define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is
now enclosed with the appropriate #ifdef block.

The symbol program_invocation_name is only used for error message
handling using error(), so it's safe to omit this if it is not
available.
2013-03-20 16:32:06 +01:00
Sami Kerola
ac97321851 vmstat: fix compiler warnings
vmstat.c:817:7: warning: declaration of 'tmp' shadows a previous local [-Wshadow]
vmstat.c:708:7: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:30:02 +11:00
Craig Small
64fa889816 Stop SIGFPE on vmstat at times
Certain setups can crash vmstat with a SIGFPE, this small patch
catches those events

Bug-Debian: http://bugs.debian.org/677903
2012-10-30 21:48:34 +11:00
Jaromir Capik
00d7d4e37a vmstat si and so fields zero with -S mM 1
'si' and 'so' values depend on the result of the unitConvert
function where the output is a fixed-point size of kb_per_page
after the conversion. It gives 4 for kB units and 0 for MB units.
This also causes problems when switching between 'K' and 'k'
since the output value is 4 in both cases and the result for
'k' and 'K' then doesn't differ ... I swapped the conversion with
multiplication in order to make the number higher so it doesn't
lose precision. Since the unitConvert now accepts long instead
of int, I had to change the input type from int to long.

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-07-28 17:50:00 +10:00
Sami Kerola
52269d22f3 all: check stdout and stderr status at exit
If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code.  The uptime is just an
example same was true with all commands of the project.

$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-23 15:57:53 +01:00
Sami Kerola
94fa402d4b slabtop, vmstat, watch: remove file descriptor constants
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-16 13:18:43 +01:00
Jim Warner
42380330d7 misc: update remaining memory references to IEC standard
This commit brings the few remaining occurances
of kB, etc. into line with the IEC binary naming
standard.

Comments containing any such references have been
left unchanged.

Reference(s):
commit 2fc3f15770

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-16 07:06:58 +11:00
Sami Kerola
ce61089059 docs: clarification to license headers in files
Add license header to all files.  The summary of licensing is below,
taken from Craig Small's email which is referred in commit message
tail.

sysctl and pgrep are GPL 2+
The rest is LGPL 2.1+

Reference: http://www.freelists.org/post/procps/Incorrect-FSF-address-in-the-license-files,8
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=797962
CC: Craig Small <csmall@enc.com.au>
CC: Jaromir Capik <jcapik@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:41:11 +11:00
Sami Kerola
afa45f0da0 vmstat: fix compiler warnings
vmstat.c:408:10: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'long long unsigned int' [-Wformat]
vmstat.c:644:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:645:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:646:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:647:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:648:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:649:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:650:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:651:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:28:52 +11:00
Craig Small
502a79e02f Merge remote-tracking branch 'sami/to-craig' into sami-merge
Conflicts:
	pgrep.c
	w.c
2012-03-03 13:56:32 +11:00
Sami Kerola
30b3c4958c vmstat: open file should be closed, not freed
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-05 23:15:54 +01:00
Mike Frysinger
0da6537c5f fix printf format warnings
pgrep.c: In function 'main':
pgrep.c:793:4: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat]

vmstat.c: In function 'diskpartition_format':
vmstat.c:382:9: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'long long unsigned int' [-Wformat]
vmstat.c:408:10: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'long long unsigned int' [-Wformat]

w.c: In function 'main':
w.c:394:4: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Wformat]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-01-26 21:15:42 +01:00
Sami Kerola
79ceb30b5c ps: unify cases and remove trailing dots in messages
Strings with lower caps & no trailing dots have greater change to
have multiple occurences, meaning less effort for translators, than
strings with them.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-15 20:52:58 +01:00
Craig Small
fb11e1fe0a Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
2012-01-03 18:48:43 +11:00
Sami Kerola
c3405fab1a translations: group usage texts
Reference: http://www.freelists.org/post/procps/backporting,5
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-02 16:29:03 +11:00
Sami Kerola
032f2ed674 vmstat: validate numeric user input and allow infinte updates
The vmstat used ULONG_MAX as definition of infinite updates.  On a
computer with mighty uptime one will find that after 136 years
(assuming 1 second update interval) the vmstat exits, which is in
conflict with a promise of infinite.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
0022b6ec5d nls: improve translations and provide translator help comments
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
c862a4caa5 nls: add functions which take translations to be used
Add the following three functions to most of the commands.

setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
72e37c7d11 vmstats: fix coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
f70cdd0666 vmstat: use libc error printing facilities
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:50 +01:00
Sami Kerola
3465901ffb vmstat: add gettext support
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:04 +01:00
Sami Kerola
1ddb5a3ae4 vmstat: add long options & new usage function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:03 +01:00
Craig Small
20463f1a13 vmstat -p <part> works and updated version to 3.3.1
configure.ac now set to 3.3.1
vmstat -p has not worked for a long time, this applies Debian patch
vmstat_part_format, the details:

Author: Daniel Novotny
Description: The contents of /proc/diskstats have changed since 2.6.25
 Changed PATH_MAX to 32 because its missing on hurd
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=485243
Bug-Debian: http://bugs.debian.org/588677
Last-Update: 2010-11-17
2011-11-27 22:47:17 +11:00
Jim Warner
415c593ad5 redhat analysis: vmstat 2011-10-15 08:26:28 +02:00
Jan Görig
8f466aa21d Headers for disk and slab info and getopt replacement
Author: Liu Xing <liuxing@cn.fujitsu.com>
Author: Michael Tokarev <mjt@corpit.ru>
Bug-Debian: http://bugs.debian.org/436805
Bug-Debian: http://bugs.debian.org/408088
2010-12-16 10:19:14 +01:00
albert
805d426d07 vmstat: use EXIT_FAILURE -- thanks Yoshio Nakamura #425492 2007-05-28 00:20:13 +00:00
albert
9278134e49 top: show CPU time stolen from a virtual machine 2006-06-25 02:15:36 +00:00
albert
29cbc63561 fputs instead of fprintf 2005-10-30 23:45:47 +00:00
albert
36524ac0fd vmstat: -p handles /dev/ and does not overflow #319523 #330969 2005-10-30 06:03:28 +00:00
albert
7767733812 dietlibc needs termios.h for struct winsize -- thanks Thomas Ogrisegg 2005-10-30 00:04:21 +00:00
albert
c8a8290ef2 fix vmstat -d 2004-05-04 23:29:40 +00:00
albert
e54c8239b1 new Linux 2.6.0-test4 CPU stats shown 2003-09-08 01:39:49 +00:00
albert
360e6533c9 misc 2003-08-16 21:15:53 +00:00
albert
6ba229fa4c alignment 2003-08-11 01:59:53 +00:00
albert
8618adeaaf got most of procps-3.1.11ff2.diff 2003-08-10 23:40:41 +00:00
albert
5c99a21b72 diskstats and slabinfo 2003-06-08 17:28:06 +00:00