前言: 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]: