前言:
Top命令是一个功能十分强大的监控系统的工具,它提供运行在系统上的与CPU关系最密切的进程列表,以及许多意义的统计值,例如负载平均、进程数量、使用的存储器和页面空间数量。它将显示系统中CPU最“敏感”的任务列表,该命令可以按CPU使用、内存使用和执行时间对任务进行排序,而且该命令的很多特性都可以通过交互式命令或者在个人定制文件中进行设定。
Top是一个动态显示过程,即可以通过用户按键来不断刷新当前状态。如果在前台执行该命令,它将独占前台,直到用户终止该程序为止。比较准确的说,Top命令提供了实时的对系统处理器的状态监视。Tru 64 UNIX 4.0f同样也支持这个命令,下面我将详细介绍如何把这个命令安装
一、 安装前的准备
1. 以root身份创建临时目录
#mkdir /freeware
#chown root /freeware
#chgrp bin /freeware
#cd /freeware
#mkdir bin
#mkdir man
#cd man
#mkdir man1
/freeware/bin为命令编译的命令目录;/freeware/man/man1为man命令来学习Top命令存放的信息的位置。
2.命令网址
http://www.funet.fi/pub/unix/tools/top/top-3.5beta9.tar.gz
将文件Top-3.5beta9.tar.gz下载并存放在/freeware下,这是一个压缩的tar文件,为此我们还要解压缩、解tar:
#cd /freeware
#gunzip Top-3.5beta9.tar.gz
#tar -xvf Top-3.5beta9.tar.gz
这样,在/freeware目录下,产生一个目录为:Top-3.5beta9
#chmod -R 755 Top-3.5beta9
二、安装过程
#cd /freeware/Top-3.5beta9
# ./Configure
Configuration for Top, version 3.5
One moment....
Reading configuration from last time...
You will be asked a series of questions. Each question will
have a default answer enclosed in brackets, such as "[5.0]". In most cases, the default answer will work well. To use that value, merely press return.
The following machine-dependent modules are available:
386bsd For a 386BSD system
aix32 POWER and POWER2 running AIX 3.2.5.0
aix41 PowerPC running AIX 4.1.2.0
aux3 a Mac running A/UX version 3.x
bsd386 For a BSD/386 system
bsd43 any generic 4.3BSD system
bsd44 For a 4.4BSD system
bsd44a For a pre-release 4.4BSD system
bsdos2 For a BSD/OS 2.X system (based on the 4.4BSD Lite
system)
convex any C2XX running Convex OS 11.X.
dcosx For Pyramid DC/OSX
decosf1 DEC Alpha AXP running OSF/1 or Digital Unix 4.0.
dgux for DG AViiON with DG/UX 5.4+
dynix any Sequent Running Dynix 3.0.x
dynix32 any Sequent Running Dynix 3.2.x
freebsd20 For a FreeBSD-2.0 (4.4BSD) system
ftx For FTX based System V Release 4
hpux10 any hp9000 running hpux version 10.x
hpux7 any hp9000 running hpux version 7 or earlier
hpux8 any hp9000 running hpux version 8 (may work with 9)
hpux9 any hp9000 running hpux version 9
irix5 any uniprocessor, 32 bit SGI machine running IRIX 5.3
irix62 any uniprocessor, SGI machine running IRIX 6.2
linux Linux 1.2.x, 1.3.x, using the /proc filesystem
mtxinu any VAX Running Mt. Xinu MORE/bsd
ncr3000 For NCR 3000 series systems Release 2.00.02 and above
netbsd08 For a NetBSD system
netbsd10 For a NetBSD-1.0 (4.4BSD) system
netbsd132 For a NetBSD-1.3.2 (4.4BSD) system
next32 any m68k or intel NEXTSTEP v3.x system
next40 any hppa or sparc NEXTSTEP v3.3 system
osmp41a any Solbourne running OS/MP 4.1A
sco SCO UNIX
sco5 SCO UNIX OpenServer5
sunos4 any Sun running SunOS version 4.x
sunos4mp any multi-processor Sun running SunOS versions 4.1.2
or later
sunos5 Any Sun running SunOS 5.x (Solaris 2.x)
svr4 Intel based System V Release 4
svr42 For Intel based System V Release 4.2 (DESTINY)
ultrix4 any DEC running ULTRIX V4.2 or later
umax Encore Multimax running any release of UMAX 4.3
utek Tektronix 43xx running UTek 4.1
What module is appropriate for this machine? [decosf1]:
This is the machine-dependent module for DEC OSF/1
It is known to work on OSF/1 1.2, 1.3, 2.0-T3, 3.0, and Digital Unix V4.0
WARNING: if you use optimization with the standard "cc" compiler
That comes with V3.0 the resulting executable may core dump.
If this happens, recompile without optimization.
Is this what you want to use? [yes]:
First we need to find out a little bit about the executables needed to compile top.
What is the full path name for the Bourne shell [/bin/sh]:
Please supply the name of the appropriate command. It need not be a full path name, but the named command does need to existsomewhere on the current path.
AWK Interpreter [awk]:
C Compiler [cc]:
The installer command needs to understand Berkeley-esque arguments:
"-o" for owner, "-g" for group, and "-m" for mode. A shell script called "install" is distributed with top and is suitable for use by top. You can specify a different program here if you like, or use the shell script (the default).
Installer [./install]:
What other options should be used with the cc command (use "none" to specify no options)?
Compiler options [-O]:
Now you need to answer some questions concerning the configuration of top itself.
The space command forces an immediate update. Sometimes, on loaded systems, this update will take a significant period of time (because all the output is buffered). So, if the short-term load average is above "LoadMax", then top will put the cursor home immediately after the space is pressed before the next update is attempted. This serves as a visual acknowledgement of the command. "LoadMax" should always be specified as a floating point number.
LoadMax [5.0]:
"Default TOPN" is the default number of processes to show. This is the number that will be used when the user does not specify the number of processes to show. If you want "all" (or infinity) as the default, use the value "-1".
Default TOPN [15]:
"Nominal_TOPN" is used as the default TOPN when Default_TOPN is Infinity and the output is a dumb terminal. If we didn't do this, then installations who use a default TOPN of Infinity will get every process in the system when running top on a dumb terminal (or redirected to a file).
Note that Nominal_TOPN is a default: it can still be overridden on the command line, even with the value "infinity".
Nominal TOPN [18]:
Default Delay is the default number of seconds to wait between screen updates.
Default Delay [5]:
It looks like you have a passwd file that can be accessed at random.
Do you want top to take advantage of this? [yes]:
Compiling prime.c
I found 82 entries in your passwd file. Top hashes the username To uid mappings as it goes along and it needs a good guess on the size of that hash table. This number should be the next highest prime number after 164.
I have calculated that to be 167.
Enter the hash table size [167]:
Uh oh! I see /proc out there. Some new Unix variants provide The /proc file system as a mechanism to get to a process's address space.
This directory is typically only accessible by root. However, There are a few systems (such as DG/UX) on which this directory exists, but isn't used. I'm going to assume that top needs to run setuid to root, but you should double check and use mode 2755 (set group id) if top doesn't really need root access. If you are running SunOS 5.0 -
SunOS 5.5.1 then you will need to install top setuid root (owner root And mode 4711). In SunOS 5.6 top only requires set-gid sys permissions.
Tell me how to set the following when top is installed:
Owner [root]:
Group owner [bin]:
Mode [4711]:
Install the executable in this directory [/freeware/bin]: