C++ CSS HTML Java JavaScript MySQL Oracle PERL PHP SQL Unix VBScript XHTML XML Сети
Gathering System Information
 

Chapter 26. Gathering System Information

amount of available hard drive space, how your hard drive is partitioned, and what processes are running. This chapter discusses how to retrieve this type of information from your Red Hat Linux system using simple commands and a few simple programs.

26.1. System Processes

The ps axps aux. This list is a static list; in other words, it is a snapshot of what is running when you invoked the command. If you want a constantly updated list of running processes, use top as described below.

The ps output can be long. To prevent it from scrolling off the screen, you can pipe it through less:

ps aux | less

You can use the ps command in combination with the grep command to see if a process is running. For example, to determine if emacs is running, use the following command:

ps ax | grep emacs

The toptop's output is provided as follows:

 idle
Mem:  1030244k av,  985656k used,   44588k free,       0k shrd,  138692k buff
                    424252k actv,   23220k in_d,  252356k in_c
Swap: 2040212k av,  330132k used, 1710080k free                  521796k cached

  
17372 joe       11   0  1056 1056   840 R     0.5  0.4   0:00 top
17356 joe        2   0  4104 4104  3244 S     0.3  1.5   0:00 gnome-terminal
    1 root       0   0   544  544   476 S     0.0  0.2   0:06 init
    2 root       0   0     0    0     0 SW    0.0  0.0   0:00 kflushd
    3 root       1   0     0    0     0 SW    0.0  0.0   0:24 kupdate
    4 root       0   0     0    0     0 SW    0.0  0.0   0:00 kpiod
    5 root       0   0     0    0     0 SW    0.0  0.0   0:29 kswapd
  347 root       0   0   556  556   460 S     0.0  0.2   0:00 syslogd
  357 root       0   0   712  712   360 S     0.0  0.2   0:00 klogd
  372 bin        0   0   692  692   584 S     0.0  0.2   0:00 portmap
  388 root       0   0     0    0     0 SW    0.0  0.0   0:00 lockd
  389 root       0   0     0    0     0 SW    0.0  0.0   0:00 rpciod
  414 root       0   0   436  432   372 S     0.0  0.1   0:00 apmd
  476 root       0   0   592  592   496 S     0.0  0.2   0:00 automount

To exit top, press the [q] key.

Useful interactive commands that you can use with top include the following:

CommandDescription
[Space]Immediately refresh the display
[h]Display a help screen
[k]Kill a process. You will be prompted for the process ID and the signal to send to it.
[n]Change the number of processes displayed. You will be prompted to enter the number.
[u]Sort by user.
[M]Sort by memory usage.
[P]Sort by CPU usage.

Table 26-1. Interactive top commands

TipTip
 

Application such as Mozilla and Nautilus are thread-aware — multiple threads are created to handle multiple users or multiple requests, and each thread is given a process ID. By default, ps and top only display the main (initial) thread. To view all threads, use the command ps -m or type [Shift]-[H] in top.

If you prefer a graphical interface for top, you can use the GNOME System Monitor. To start it from the desktop, select Main Menu Button (on the Panel) => System Tools => System Monitor or type gnome-system-monitor at a shell prompt from within the X Window System. Then select the Process Listing tab.

The GNOME System Monitor allows you to search for process in the list of running process as well as view all processes, your processes, or active processes.

To learn more about a process, select it and click the More Info button. Details about the process will be displayed at the bottom of the window.

To stop a process, select it and click End Process. This function is useful for processes that have stopped responding to user input.

To sort by the information in a specific column, click on the name of the column. The column that the information is sorted by appears in a darker gray color.

By default, the GNOME System Monitor does not display threads. To change this preferences, select Edit => Preferences, click the Process Listing tab, and select Show Threads

Figure 26-1. GNOME System Monitor

Главная