Êíèãà: Embedded Linux Primer: A Practical, Real-World Approach
13.4.5. top
13.4.5. top
Whereas ps is a one-time snapshot of the current system, top takes periodic snapshots of the state of the system and its processes. Similar to ps, top has numerous command line and configuration options. It is interactive and can be reconfigured while operating to customize the display to your particular needs.
Entered without options, top displays all running processes in a fashion very similar to the ps aux command presented in Listing 13-9, updated every 3 seconds. Of course, this and many other aspects of top are user configurable. The first few lines of the top screen display system information, also updated every 3 seconds. This includes the system uptime, the number of users, information on the number of processes and their state, and much more.
Listing 13-10 shows top in its default configuration, resulting from executing top from the command line without parameters.
Listing 13-10. top
top - 06:23:14 up 6:23, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 24 total, 1 running, 23 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0% us, 0.3% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 62060k total, 17292k used, 44768k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 11840k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
978 root 16 0 1924 952 780 R 0.3 1.5 0:01.22 top
1 root 16 0 1416 508 452 S 0.0 0.8 0:00.47 init
2 root 5 -10 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
3 root 5 -10 0 0 0 S 0.0 0.0 0:00.00 desched/0
4 root -2 -5 0 0 0 S 0.0 0.0 0:00.00 events/0
5 root 10 -5 0 0 0 S 0.0 0.0 0:00.09 khelper
10 root 18 -5 0 0 0 S 0.0 0.0 0:00.00 kthread
21 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 kblockd/0
62 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pdflush
63 root 15 0 0 0 0 S 0.0 0.0 0:00.00 pdflush
65 root 19 -5 0 0 0 S 0.0 0.0 0:00.00 aio/0
36 root 25 0 0 0 0 S 0.0 0.0 0:00.00 kapmd
64 root 25 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0
617 root 25 0 0 0 0 S 0.0 0.0 0:00.00 mtdblockd
638 root 15 0 0 0 0 S 0.0 0.0 0:00.34 rpciod
834 bin 15 0 1568 444 364 S 0.0 0.7 0:00.00 portmap
861 root 20 0 0 0 0 S 0.0 0.0 0:00.00 lockd
868 root 16 0 1488 596 504 S 0.0 1.0 0:00.11 syslogd
876 root 19 0 1416 456 396 S 0.0 0.7 0:00.00 klogd
884 root 18 0 1660 700 612 S 0.0 1.1 0:00.02 rpc.statd
896 root 16 0 1668 584 504 S 0.0 0.9 0:00.00 inetd
909 root 15 0 2412 1372 1092 S 0.0 2.2 0:00.34 bash
953 telnetd 16 0 1736 736 616 S 0.0 1.2 0:00.27 in.telnetd
954 root 15 0 2384 1348 1096 S 0.0 2.2 0:00.16 bash
The default columns from Listing 13-10 are the PID, the user, the process priority, the process nice value, the virtual memory used by the process, the resident memory footprint, the amount of shared memory used by the task, and other fields that are identical to those described in the previous ps example.
Space permits only a cursory introduction to these useful utilities. You are encouraged to spend an afternoon with the man pages for top and ps to explore the richness of their capabilities.
- 2.1.3. Ôóíêöèÿ getopt_long()
- The Fedora Desktop
- The GNOME Desktop Environment
- Starting and Stopping Services Manually
- Starting and Stopping Apache
- Printing Resource Usage with top
- Linux on Laptops and PDAs
- 4.2.1. Top-Level Source Directory
- 9.10.1 CANSetOperationMode
- 9.10.2 CANGetOperationMode
- Ethernet Autoprobing
- Desktop’èçàöèÿ BSD