Linux monitoring tools. Linux commands to monitor system; to check CPU utilization in Linux. These also help in Linux network traffic monitoring. Read more to know about these command line tools to monitor Linux system.
5 Must Know Commands
- top
- vmstat
- netstat
- htop
- ps
top
top commands displays Linux processes in real-time. top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. It can display system summary information as well as a list of processes or threads currently being managed by the Linux Kernel. It can sort the tasks by CPU usage, memory usage and runtime.
When operating top, the two most important keys are the help (‘h’ or ‘?’) key and quit (‘q’) key. Alternatively, you could simply use the traditional interrupt key (‘^C’) when you’re done.
The top program provides a dynamic real-time view of a running system.
vmstat
vmstat reports virtual memory statistics. vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu activity. The first report produced gives averages since the last reboot. Additional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case.
The commans takes the following sytnax:
vmstat [options] [delay [count]
- options are the command line arguments, such as
a {display active and inactive memory}, f {displays the number of forks since boot}, m {displays slabinfo}, s {displays event counters and memory statistics}, d {report disk statistics} and many others. - delay is the delay between updates in seconds. If no delay is specified, only one report is printed with the average values since boot.
- count is the number of updates. In absence of count, when delay is defined, default is infinite.
netstat
netstat prints information about the network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
The type of information printed is controlled by the first argument, as follows:
(none): If you don’t specify any address families, then the active sockets of all configured address families will be printed.
- route or r: Display the kernel routing tables.
- groups or g: Display multicast group membership information for IPv4 and IPv6.
- interfaces or i: Display a table of all network interfaces.
- masquerade or M: Display a list of masqueraded connections.
- statistics or s: Display summary statistics for each protocol.
The command has an elaborate syntax format. For any help use netstat –help|-h argument.
htop
htop is an interactive process viewer command. It is similar to top, but allows you to scroll vertically and horizontally, so you can see all the processes running on the system, along with their full command lines. Using htop command, tasks related to processes (killing, renicing) can be done without entering their PIDs.
ps
ps display the status of current processes. This command, only those processes that are running with your effective user ID and are attached to a controlling terminal are shown. Additional categories of processes can be added to the display using various options.
ps displays in tabular form the process ID, under PID; the controlling terminal (if any), under TT; the cpu time used by the process so far, including both user and system time, under TIME; the state of the process, under S; and finally, an indication of the COMMAND that is running.