quinta-feira, 5 de setembro de 2013

8 Helpful Linux System Monitoring Commands


Linux, open source, Linux command, Linux command line, Linux system monitoring, Linux administrator, Linux system monitoring tools

From finding out bottleneck in storage to CPU to memory and network, these commands are a must know for Linux monitoring. 

Thursday, September 05, 2013:  Other than the add-on tools that can help the administrators manage their Linux server performance, we bring to you some built-in commands that can help you with information about system activities. These tools can be used to find possible causes of a performance glitch. The commands mentioned below are some of the most basic commands in system analysis and debugging server issues. Have a look: 


1. top (display Linux tasks )

The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. The types of system summary information shown and the types, order and size of information displayed for tasks are all user configurable and that configuration can be made persistent across restarts. 

The program provides a limited interactive interface for process manipulation as well as a much more extensive interface for personal configuration -- encompassing every aspect of its operation. And while top is referred to throughout this document, you are free to name the program anything you wish. That new name, possibly an alias, will then be reflected on top's display and used when reading and writing a configuration file.

Common hot keys:

t Displays summary information off and on.
m Displays memory information off and on.
A Sorts the display by top consumers of various system resources. Useful for quick identification of performance-hungry tasks on a system.
f Enters an interactive configuration screen for top. Helpful for setting up top for a specific task.
o Enables you to interactively select the ordering within top.
r Issues renice command.
k Issues kill command.
z Turn on or off color/mono

2. vmstat (Report 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.



-f switch displays the number of forks since boot. This includes the fork, vfork, and clone system calls, and is equivalent to the total number of tasks created. Each process is represented by one or more tasks, depending on thread usage. This display does not repeat. 
-m displays slabinfo. 
-n switch causes the header to be displayed only once rather than periodically. 
-s displays a table of various event counters and memory statistics. This display does not repeat. 

3. w (Show who is logged on and what they are doing)
w displays information about the users currently on the machine, and their processes. The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes. 

The following entries are displayed for each user: login name, the tty name, the remote host, login time, idle time, JCPU, PCPU, and the command line of their current process. 

The JCPU time is the time used by all processes attached to the tty. It does not include past background jobs, but does include currently running background jobs.

-h Don't print the header. 
-u Ignores the username while figuring out the current process and cpu times. To demonstrate this, do a "su" and do a "w" and a "w -u".
-s Use the short format. Don't print the login time, JCPU or PCPU times. 
-f Toggle printing the from (remote hostname) field. The default as released is for the from field to not be printed, although your system administrator or distribution maintainer may have compiled a version in which the from field is shown by default. 
-V Display version information. 
-o Old style output. Prints blank space for idle times less than one minute. 
user Show information about the specified user only. 

4. uptime (Tell How Long The System Has Been Running)

uptime gives a one line display of the following information. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.



5. ps (Report a snapshot of the current processes. )

ps command will report a snapshot of the current processes. To select all processes use the -A or -e option.

To see every process on the system using standard syntax: 
$ ps -e 
$ ps -ef 
$ ps -eF 
$ ps -ely 

To see every process on the system using BSD syntax: 
$ ps ax 
$ ps axu 

To print a process tree: 
$ ps -ejH 
$ ps axjf 

To get info about threads: 
$ ps -eLf 
$ ps axms 

To get security info: 
$ ps -eo euser,ruser,suser,fuser,f,comm,label 
$ ps axZ 
$ ps -eM 

To see every process running as root (real & effective ID) in user format: 
$ ps -U root -u root u 

To see every process with a user-defined format: 
$ ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm 
$ ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm 
$ ps -eopid,tt,user,fname,tmout,f,wchan 

Find Out The Top 10 Memory Consuming Process
$ ps -auxf | sort -nr -k 4 | head -10
Find Out top 10 CPU Consuming Process
$ ps -auxf | sort -nr -k 3 | head -10

6. free - (Display amount of free and used memory in the system )

free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The shared memory column should be ignored; it is obsolete. 



-b Display the amount of memory in bytes. 
-c count Display the result count times. Requires the -s option. 
-g Display the amount of memory in gigabytes. 
-k Display the amount of memory in kilobytes. This is the default. 
-l Show detailed low and high memory statistics. 
-m Display the amount of memory in megabytes. 
-o Display the output in old format, the only difference being this option will disable the display of the "buffer adjusted" line. 
-s Continuously display the result delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times. 
-t Display a line showing the column totals. 
-V Display version information. 

7. mpstat (Report processors related statistics.
)


The mpstat command writes to standard output activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. The mpstat command can be used both on SMP and UP machines, but in the latter, only global average activities will be printed. If no activity has been selected, then the default report is the CPU utilization report.
Use mpstat -P ALL to display average CPU utilization per processor.



8. iostat (Report Central Processing Unit (CPU) statistics and input/out‐put statistics for devices and partitions.)

The iostat command is used for monitoring system input/output device
loading by observing the time the devices are active in relation to
their average transfer rates. The iostat command generates reports that
can be used to change system configuration to better balance the
input/output load between physical disks.

 

Atithya Amaresh, EFYTIMES News Network 

Fonte: 8 Helpful Linux System Monitoring Commands

Nenhum comentário:

Postar um comentário