Commit Graph

1705 Commits

Author SHA1 Message Date
Craig Small
f4cc9720ee Reduced partition type check
vmstat -p checks used to fail on systems with odd
partition tables, including some Debian buildd servers.
This change limits what sort of test partitions are used,
otherwise the test is skipped.

There probably are other valid partitions, these can be added
later, if known.
2014-05-27 20:49:16 +10:00
Jim Warner
444fa7102b top: miscellaneous accumulated changes to man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-05-13 16:39:49 +02:00
Jim Warner
0caa6d6e67 top: miscellaneous accumulated changes to program code
. prevent any input recall overrun if window downsized
. adjust translation notes for true column hdr maximum

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-05-13 16:39:49 +02:00
Jaromir Capik
2f96eef7f8 library: reverting tmpfs subtraction from cached (18-FEB-2014)
The subtraction was marked as reinforcing the misconception,
that memory in the page cache can be considered free.
The Cached value is not a sum of page cache and tmpfs,
as the tmpfs memory lives in the page cache and therefore
it's an inseparable part of it.
2014-04-30 13:59:34 +02:00
Jim Warner
bef6b0f025 top: standardize <Esc> key support with prompted input
In release 3.3.6, some commands were equipped with the
concept of a 'default pid'. The initial implementation
meant that the intuitive <Esc> key would not always be
treated as one would expect under any well behaved UI.

This patch ensures the expected <Esc> key behavior of:
terminating user input while still making possible the
necessary distinction between 'no input' & 'defaults'.

Reference(s):
http://www.freelists.org/post/procps/top-Escape-doesnt-abort-kill-command

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 20:56:48 +02:00
Jim Warner
fe37ad15cd top: avoid a 'nan' when the delay interval is very low
The granularity of /proc/uptime is fixed at hundredths
of a second. And, since we can cycle faster than that,
we are exposed to 'nan' when calculating elapsed time.

This commit will protect us from that outcome when the
delay interval has been set to an extremely low value.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 20:56:48 +02:00
Jim Warner
ada443268e misc: fix man doc spelling and grammar for translation
Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 20:56:48 +02:00
Jim Warner
2f4f175c59 top: swap opening quotes for back-tics in man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 20:56:48 +02:00
Jim Warner
c9f7cc7025 top: minimize the usage of apostrophes in man document
In addition to eliminating numerous single quote usage
this commit also escaped '\' a few overlooked hyphens.

And some 'unformatted' spacings were adjusted as well.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 20:56:48 +02:00
Jim Warner
f3e55ee661 top: refactor man document so as to allow translations
The majority of changes in this commit are intended to
enable translation of top's man page. There were three
kinds of errors as seen by that po4a-updatepo program.

. a valid but unrecognized request concerning no-break
. an internally defined macro with a groff .de request
. occasional apostrophe at the beginning of some lines

With respect to the apostrophe, some have been changed
to back-tic since line placement could not be assured.
And other parts were re-flowed to avoid temptations to
escape as \' (technically an acute accent). Of course,
the opening back-tic with closing apostrophe looks odd
when ASCII, but should be rendered correctly as UTF-8.

It may yet be necessary to change the remaining single
'opening' quotes to back-tics as translation proceeds.
Should that become necessary, I intend to reduce quote
usage to the bare minimum throughout the man document.

There were also some formatting changes to enhance the
man2html output and then to other formats via htmldoc.
And, I wish to acknowledge that my meager groff skills
do not serve those programs very well at all. In other
words groff yet remains mostly incomprehensible to me.

Lastly a few content plus copyright updates were made.

Message(s):
. Unknown macro '.c2 `'. Remove it from the document, or refer to the Locale::Po4a::Man manpage to see how po4a can handle new macros.
. This page defines a new macro with '.de'. Since po4a is not a real groff parser, this is not supported.
. Unknown macro ''real time' scheduling priority.'. Remove it from the document, or refer to the Locale::Po4a::Man manpage to see how po4a can handle new macros.

Reference(s):
. oriiginal post/patch
http://www.freelists.org/post/procps/Translations-for-man-pages

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 20:56:48 +02:00
Jim Warner
e2868da34e top: update copyright dates plus 1 preprocessor change
Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 13:46:06 +02:00
Jim Warner
22e6582974 top: protect against distortion when system time reset
If a system's time is adjusted backwards, then elapsed
time could appear as negative. This yielded a negative
%CPU value. Alternately if zeros were suppressed ('0')
the result was a blank %CPU column. In both cases that
distortion would last for one display cycle or until a
user forced a display refresh via some keyboard input.

The original recommendation was trading gettimeofday()
for clock_gettime() using CLOCK_MONOTONIC. But on some
systems that might not be possible, forcing the use of
CLOCK_REALTIME instead. Not only would that complicate
the build system, but it may leave us with minus %CPU.

Another approach was to ensure that elapsed time could
never be negative. Of course, this produced distortion
of %CPU values but it would be proportionally correct.
This wasn't dissimilar to a distortion already present
should the time be adjusted forward or backward within
any 'remaining' top delay intervals. These aberrations
would be avoided with clock_gettime & CLOCK_MONOTONIC,
but that is a less than ideal solution as noted above.

This final solution, which originated down under, will
simply rely on the /proc/uptime seconds, which will be
immune to *any* tampering with the system clock. Thus,
we now have a fix for the distortion we didn't know we
suffered plus a negative %CPU that began this odyssey.

Thanks to:
sk.alvin.x@gmail.com, for the original effort
jcapik@redhat.com, for a heads up on CLOCK_MONOTONIC
csmall-procps@enc.com.au, for the best suggestion of all

Reference(s):
. original post/patch
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday
. heads up on CLOCK_MONOTONIC
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday,2
. the final solution
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday,11

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 13:46:06 +02:00
Trần Ngọc Quân
0b3f63456a fix url for rsync
Signed-off-by: Trần Ngọc Quân <vnwildman@gmail.com>
2014-04-17 14:12:01 +07:00
Trần Ngọc Quân
f1a7b27921 l10n: po/update-potfile: add include/c.h
Signed-off-by: Trần Ngọc Quân <vnwildman@gmail.com>
2014-04-16 15:56:03 +07:00
Sami Farin
9c7e8b82f8 sysctl: increase max supported line length of the conf file
I ran into this limit with net.ipv4.ip_local_reserved_ports ,
sysctl complained about the line after the long line, further
slowing down my error hunting.

Due to fgets usage, increase buffer size to 4096 chars with
minimum amount of code changes.

Signed-off-by: Sami Farin <hvtaifwkbgefbaei@gmail.com>
2014-03-14 18:55:14 +01:00
Yuri Chornoivan
2ec9f5c22e Minor i18n fixes
Minor fixes that the translator (Yuri) has found in some of the
strings. You only know how many typos and thinkos you have when
someone is trying to translate it.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-03-03 21:58:56 +11:00
Jakob Unterwurzacher
3569c0351f library: properly handle memory used by tmpfs
tmpfs has become much more widely used since distributions use it for
/tmp (Fedora 18+). In /proc/meminfo, memory used by tmpfs is accounted
into "Cached" (aka "NR_FILE_PAGES",
 http://lxr.free-electrons.com/source/mm/shmem.c#L301 ).

The tools just pass it on, so what top, free and vmstat report as
"cached" is the sum of page cache and tmpfs.

free has the extremely useful "-/+ buffers/cache" output. However, now
that tmpfs is accounted into "cached", those numbers are way off once
you have big files in /tmp.

Fortunately, kernel 2.6.32 introduces "Shmem", which makes tmpfs memory
usage accessible from userspace (
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4b02108ac1b3354a22b0d83c684797692efdc395 ).

This patch substracts Shmem from Cached to get the actual page cache
memory. This makes both issues mentioned above disappear. For older
kernels, Shmem is not available (hence zero) and this patch is no-op.

Additionally:
* Update the man pages of free and vmstat to explain what is happening
* Finally drop "MemShared" from the /proc/meminfo parser, it has been
  dead for 10+ years and is only causing confusion ( removed in kernel
  2.5.54, see
  https://git.kernel.org/cgit/linux/kernel/git/tglx/history.git/commit/?id=fe04e9451e5a159247cf9f03c615a4273ac0c571 )
2014-02-27 14:07:10 +01:00
Jim Warner
24f1fbd9d0 top: avoid name conflict in the next version of stdlib
Since its inception top has always used enumerators to
identify displayable fields. They've taken the form of
P_PID, etc. As it turns out, something has changed for
libc6-dev versions beyond 2.17-93 wherein 'P_PID' will
now be exposed via stdlib.h. I have not pinpointed the
exact cause but it may depend on header include order.

This patch just trades top's long standing 'P_' prefix
convention for that of 'EU_' (short for enumerator). I
cannot find *any* header under /usr/include/ currently
utilizing this particular three character combination.

And as a further safeguard top will henceforth include
'system' specific headers after the standard includes.

Reference(s):
http://www.freelists.org/post/procps/top-wont-compile-anymore

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-02-27 06:30:44 +11:00
Craig Small
2ade4b082b Added get-trans target to Makefile
The get-trans target rsyncs the latest copies of translation files
from the translation project. I put this target in because I always
forget the exact syntax of the command.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-02-22 11:34:53 +11:00
Jim Warner
bcf4f5a830 top: restore the former behavior after stderr redirect
When top originally responded to the potential libnuma
stderr write, the library was consistently called with
each refresh cycle. That, in turn, guaranteed that any
warning message would be seen at program end by virtue
of: 1) having been issued before the 2nd refresh cycle
and; 2) benefiting from inherited /dev/null buffering.

A later efficiency refactor meant the numa library may
not always be called with every refresh cycle. Rather,
it was only called if top was in one of two numa views
(the '2' or '3' toggles). That, in turn, resulted in a
loss of any warning message at program end unless numa
mode had been preserved in the rcfile. In other words,
if top was started normally then a single cycle stderr
redirect would have long passed by the time the '2' or
'3' toggle was activated. The warning message actually
was spewed but quickly lost to the full screen refresh
which follows all keyboard interactions with the user.

This commit simply moves the restoration of our stderr
redirect to program end (instead of that first display
refresh). Now, any libnuma stderr warning message will
appear as the concluding output line upon quitting top
without regard to when any numa mode view was invoked.

And since this technique might be useful in some other
context (as an example of how to 'buffer' stderr) it's
been generalized with its own #define. But to maximize
its usefulness, the original redirect should be issued
much earlier in pgm startup than top has chosen to do.

Reference(s):
. original libnuma stderr response (msg seen)
commit 35dc6dcc49
. numa refractoring for efficiency (msg lost)
commit f12c0d5c6e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-02-22 11:16:22 +11: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
Josh Stone
835b6294d1 watch: Don't leak extra fds to the child
Once the write side of the pipe has been duped to stdout for the child,
the original pipefd is no longer needed, so it can be closed to avoid
leaking to the child.

The leak can easily be seen with "watch ls -l /proc/self/fd", but I
found this due to "watch lvs" diagnosing itself:

    File descriptor 4 (pipe:[3163616]) leaked on lvs invocation.

Signed-off-by: Josh Stone <jistone@redhat.com>
2014-02-04 19:23:59 +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
Craig Small
8e7ef322e2 Update help files
Benno Schulenberg suggested some changes to the help messages
to provide some consistency and clarity for both the users and
translators of procps.

The test needed to be updated as the pmap output changed too.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-02-02 18:13:01 +11:00
Craig Small
ca99070012 Merge branch 'merge-requests/23' 2014-01-30 22:12:28 +11:00
Elliott Forney
6f1c04259d pgrep fails to show full command line with -au
pgrep does not show the full command line when the -a and -u flags are
combined. The -a flag is ignored when the -u flag is used as well.

In addition, the supplied patch by Elliot did not fix the problem
when invert flag ( -v ) was used; a very small tweak to the patch
fixed this problem as well. This problem existed before.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-01-30 21:36:26 +11:00
Craig Small
39210a89de PID -2 to -9 for kill too
Commit 4359cf0698 restored kill's ability
to kill PID -1. This however left PIDs -2 to -9 (or rather process
groups 2 to 9) still having this problem. The check is now generically
looking for a digit and parses it correctly.
2014-01-29 22:28:02 +11:00
Craig Small
5a34ff0a99 Check for presence of disks in vmstat
vmstat -d or vmstat -p would crash mysteriously under different
circumstances. The problem was eventually tracked down to /sys not
being mounted which meant is_disk() always returned false.
The partition would then be attempted to be linked to a non-existent
disk causing a segfault.

vmstat will now not link to a disk if none exists.
The change in testing will skip those tests when /sys/block doesn't
exist.

Many thanks to Daniel Schepler for his analysis and suggestions.

Bug-Debian: http://bugs.debian.org/736628
2014-01-29 22:22:11 +11:00
Craig Small
4359cf0698 kill for PID -1 restored
Both the man page and the shell builtin kill mention you can
use PID -1, which means nuke everything you can get at.
Alas this "fun" option was missing and the only way to get
around it was with "kill -HUP -- -1".

This small change means kill -HUP -1 is back for all those
destructive types. The error was introduced when the argument
parser was fixed for other problems.

Thanks to Mike for pointing this out.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-01-28 22:35:26 +11:00
Jaromir Capik
ae9676a337 library: skip replacement of trailing '\0' in read_unvectored()
Under some circumstances the ksh shell doesn't fork new processes
when executing scripts and the script is interpreted by the
parent process. That makes the execution faster, but it means
ksh needs to reuse the /proc/PID/cmdline for the new script name
and arguments while the file length needs to stay untouched.
The fork is skipped only when the new cmdline is shorter than
the parent's cmdline and the rest of the file is filled
with '\0'. This is perfectly ok until we try to read the cmdline
of such process. As the read_unvectored() function replaces
all zeros with chosen separator, these trailing zeros are replaced
with spaces in case of the ps tool. Consequently it appends
multiple spaces at the end of the arguments string even when these
zeros do not represent any separators and therefore shouldn't
be replaced.
With this commit the read_unvectored() function skips the
replacement of trailing zeros and separates valid content only.

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1057600
2014-01-24 18:32:20 +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
Jim Warner
b6fcb602ce top: provide for discontinuous (not active) NUMA nodes
Apparently there are occasions when NUMA nodes may not
always be contiguous. Under such conditions nodes that
were not used would still occupy precious Summary Area
space showing 100% idle, under the '2' command toggle.

With this commit top will no longer display numa nodes
that have no associated cpu when the '2' toggle is on.
But just in case we wish to return to former behavior,
a new #define called OFF_NUMASKIP has been introduced.

And as an aside, a recent refactor mentioned below set
the stage for this patch to be 'self-tuning'. In other
words, if an inactive/non-displayed node should become
active (if even possible), then top will begin showing
such a node automatically with the next screen update.

Unfortunately, all inactive nodes now 'suppressed' are
still accessible via the '3' command. Those nodes will
just be displayed as empty (no associated cpus shown).
This is not really a top problem but more of a libnuma
and/or user deficiency. The library lacks the means to
validate a node id and the user then input a node that
was not even shown under a '2' toggle Summary display.

( too bad libnuma does not offer an 'is_node_active' )
( type function so top could warn a user when such a )
( discontinuous node was requested using his '3' cmd )

( sure, top could achieve this objective himself but )
( that would require making yet another array global )
( which i'm just not in the mood to do - besides, we )
( have already made enough concessions to libnuma.so )

Lastly, an existing #define (PRETEND_NUMA) was changed
to 'disable' node #1 so as to simulate a discontinuous
node. This allows testing of the '2' and '3' commands.

Reference(s):
http://www.spinics.net/lists/util-linux-ng/msg08671.html
. set stage for self tuning
commit f12c0d5c6e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-01-20 19:10:22 +01:00
Craig Small
d06aaaaf2b ps: ignore SIGCONT
SIGCONT is a continue signal.  It seems that some zsh setups can send
this signal, causing ps to abort.  This is not what "continue" means.
This change just uses the default handler which will continue a stopped
process.

References:
  http://bugs.debian.org/732410
  http://www.zsh.org/cgi-bin/mla/redirect?WORKERNUMBER=32251

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-01-14 22:23:58 +11:00
Jaromir Capik
8622b582da sysctl: Fixing memory leaks in PreloadSystem() 2014-01-02 19:49:36 +01:00
Jaromir Capik
69de8db3e2 pgrep: Fixing memory leak in do_regcomp() 2014-01-02 18:39:27 +01:00
Jaromir Capik
38cbeedeb7 library: fixing uninitialized variable 'pos' in whattime.c 2014-01-02 18:21:31 +01:00
Craig Small
8a38cd5eb4 Split help lines to help translators
To assist translators, the help lines are split so that each translation
chunk has one option. This gives bonus of if we add or change an option,
only that option remains untranslated rather than the entire help block.

Reference:
  http://www.freelists.org/post/procps/procpsng-for-Translation-Project,1

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-12-28 09:25:39 +11:00
Craig Small
7f6efed9bb sysctl --system loads default config file
Commit cdca71e945 fixed
the loading the sysctl.conf file, but had the logic
for checking the file exists reversed incorrectly.
2013-12-27 23:08:14 +11:00
Jim Warner
14ef47af57 top: do not forget the fscanf %s terminating null byte
Reference(s):
http://www.freelists.org/post/procps/procpsng-339-defects-found

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-12-19 15:27:11 +01:00
Craig Small
85fff468fa Update the library version to 3:0:0
We have had some API changes which means the library version needs to
be incremented.
2013-12-03 22:16:18 +11:00
Craig Small
91ff7c6e22 Fixed check for vmstat with stolen time
Commit a8a4a4f added stolen time to vmstat, but broke the checks as
we have another column. This commit fixes the checks
2013-12-03 22:08:30 +11:00
Jim Warner
4c464acf28 top: follow usual name conventions for global variable
A recent change involving a one cycle stderr redirect,
to handle a libnuma potential transgression, failed to
follow normal global variable naming conventions. This
patch will capitalize the 1st letter of 'Stderr_save'.

Reference(s):
commit 35dc6dcc49

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-12-02 21:37:36 +01:00
Jim Warner
57ab5eed15 top: do not lie about purported alphabetical orderings
Excluding those special X_XON/X_XOF enums, which might
not even be present, restore strict collating order of
all the case labels in the task_show switch statement.

Also, adjust a few sort callbacks for the same reason.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-12-02 21:37:36 +01:00
Jaromir Capik
9f3cfd7c36 pmap: Including -p in the man page
Previously the pmap man page was missing the -p switch.
This commit fixes that.
2013-11-26 13:45:22 +01:00
Jaromir Capik
09594c8926 pmap: Including -c -C -n -N in the man page
Previously the pmap man page was missing the -c -C -n -N switches.
This commit fixes that.
2013-11-26 13:31:44 +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
Jim Warner
23dd0cec41 NEWS: updated with the next procps-ng release of 3.3.9
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-11-25 20:57:32 +11:00
Jim Warner
af4e6533ba top: increase the maximum number of displayable fields
The recent addition of namespaces, combined with those
potential suse out-of-memory fields, means that we are
close to the maximum number of fields poor ol' top can
display. Imagine, the really old top was limited to 26
fields (28 with the suse hack) and this top had neared
the version 'g' rcfile limits which were a healthy 55.

This patch adds another 15 fields to the maximum while
making it even easier to increase in the future. Also,
top still silently accommodates older config files all
the way back to the original pre-ng version top-3.2.8!

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-11-25 20:57:32 +11:00
Jim Warner
675200b20b top: expand the man page to include namespaces support
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-11-25 20:57:32 +11:00