The Linux system administrator should know the monitoring tool.

Source: Internet
Author: User


The Linux system administrator should know the monitoring tool. If you want to monitor the performance of the Linux server, try the built-in shell commands and some additional tools. Many Linux distributions have "tons" of monitoring tools. These tools provide measurable information for observing system activities and identifying suspicious points that result in system performance. The tools we discuss below are some of the most basic www.2cto.com commands that can be used for system analysis and service debugging: 1. Identify system bottlenecks 2. Identify disk bottlenecks 3. Identify CPU and memory bottlenecks 4. network bottlenecks 1. top process activity command top provides dynamic and real-time viewing of the running system status, for example, the actual process activity. By default, the most CPU-intensive tasks are displayed every 5 seconds and once again. Top provides some of the most frequently used keys: Key Usaget is disabled or overview information is displayed. m is disabled or memory information is displayed. A is sorted to display the processes that consume the most resources, you can quickly identify the performance-hungry Process f to enter a top interactive configuration interface. o allows you to interactively select the top sequence r Issues renice command k Issues kill command z to open or disable color 2., vmstat system activity, hardware and system information vmstat Command reports process, memory, page, blocked IO, traps and cpu activity reference # vmstat 3 output: reference procs ---- memory -----swap--- io ---system--- cpu -- r B swpd free buff cache si so bi bo in cs us sy id wa st0 0 0 2540988 522188 0 0 2 32 4 2 4 1 96 0 01 0 0 2540988 522188 0 0 0 5130400 720 1 0 99 0 00 0 0 1199 665 0 0 0 2540956 522188 4 1 95 0 00 0 0 2540956 522188 5130500 0 0 0 6 1117 439 1 0 99 0 00 0 2540940 522188 5130512 0 0 536 1189 932 1 0 98 0 00 0 0 2538444 522188 0 0 0 0 0 0 0 1187 1417 4 1 96 0 00 0 0 2490060 522188 0 0 0 0 18 5130640 1253 5 1 94 0 0 Display memory: reference # vmstat-m get active/inactive Memory Page Information: Reference # Vmstat-a 3. w: Find out who has logged on to the system and what w command they are doing to display the user's current information and their process: Reference # w fuliang output: www.2cto.com reference 17:58:47 up 5 days, 2 users, load average: 0.36, 0.26, 0.24 user tty from login @ idle jcpu pcpu WHATroot pts/0 10.1.3.145 55 5.00 s 0.04 s 0.02 s vim/etc/resolv. confroot pts/1 10.1.3.145 0.00 s 0.03 s 0.00 s w 4. view how long the system has been running the uptime command to view the current server time, running time, and how many users have logged on, and the average load of the system in the past 1, 5, 15 minutes. Reference # uptime output: Reference 18:02:41 up 41 days, 1 user, load average: 0.00, 0.00, 0.00 five, ps display process: ps command to report information about the current process, select all processes and use the-A or-e Option to reference # ps-A output: Reference pid tty time cmd 1? 00:00:02 init 2? 00:00:02 migration/0 3? 00:00:01 ksoftirqd/0 4? 00:00:00 watchdog/0 5? 00:00:00 migration/1 6? 00:00:15 ksoftirqd/1 .... Www.2cto.com ..... 4881? 00:53:28 java4885 tty1 00:00:00 effectty2 00:00:00 mingetty4887 tty3 00:00:00 mingetty4888 tty4 00:00:00 mingetty4891 tty5 00:00:00 mingetty4892 tty6 00:00:00 mingetty4893 ttyS1 00:00:00 aget128ty53? 00:00:00 cifsoplockd12854? 00:00:00 cifsdnotifyd14231? 00:10:34 lighttpd14133? 00:00:00 php-cgi54981 pts/0 00:00:00 vim55465? 00:00:00 php-cgi55546? 00:00:00 bind9-snmp-stat55704 pts/1 00:00:00 ps display long format: Reference # ps-Al open additional full mode (display command line parameters passed to the process) www.2cto.com reference # ps-AlF view thread: reference # ps-AlFH display thread reference after process # ps-AlLm show all processes: Reference ps axps aux print process count reference # ps-ejH # ps axjf # pstree print Security Information: reference # ps-eo euser, ruser, suser, fuser, f, comm, label # ps axZ # ps-eM to view all processes of a user: reference # ps-U fuliang-u fuliang u is displayed in user-defined mode: www.2cto.com reference # ps-eo pid, tid, class, rtprio, ni, pri, psr, pcpu, stat, wcha N: 14, comm # ps axo stat, euid, ruid, tty, tpgid, sess, pgrp, ppid, pid, pcpu, comm # ps-eopid, tt, user, fname, tmout, f, wchan view the process id: Reference # ps-C lighttpd-o pid = # pgrep lighttpd view the process name: reference # ps-p 55988-0 comm = find the top 10 memory-consuming processes: reference # ps-auxf | sort-nr-k 4 | head-10 find the top 10 memory-consuming processes: reference # ps-auxf | sort-nr-k 3 | head-10 6. free view memory usage: Reference # free output: Reference total used free shared buffers cachedMem: 12302896 9739664 2563 232 0 523124 5154740-/+ buffers/cache: 4061800 8241096 Swap: 1052248 0 1052248 seven, iostat cup average load, disk activity www.2cto.com reference # iostat output: Reference Linux 2.6.18-128.1.14.el5 () 06/26/2009 avg-cpu: % user % nice % system % iowait % steal % idle 3.50 0.09 0.51 0.03 0.00 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnsda 22.04 31.88 512.03 16193351 0.00 260102868sda1 0.00 0.00 2166 22.04 180sda2 31.87 512.03 16189010 260102688sda3 0.00 0.00 0.00 0 8. sar collects and reports system activities: the sar command can be used to collect, report, and save system activity information, and view the network count: reference # sar-n DEV | more view the real time reference used # sar 4 5 output: Reference Linux 2.6.18-128.1.14.el5 () 06/26/200906: 45: 12 pm cpu % user % nice % system % iowait % steal % idle06: 45: 16 PM all 2.00 0.00 0.22 0.00 0.00: 45: 20 PM all 97.7806 2.07 0.00 0.38: 45: 24 PM all 0.94 0.00 0.28 0.00 0.00: 45: 28 PM all 98.7806 1.56 0.00 2 0.00 0.00 98.2206: 45: 32 PM all 3.53 0.00 0.25 0.03 0.00 96.19 Average: all 2.02 0.00 0.27 0.01 0.00 97.70 www.2cto.com 9. Use of mpstat multi-processor: reference # mpstat-p all output: Reference Linux 2.6.18-128.1.14.el5 () 06/26/200906: 48: 11 pm cpu % user % nice % sys % iowait % irq % soft % steal % idle intr/s06: 48: 11 PM all 3.50 0.09 0.34 0.03 0.01 0.17 0.00 95.86: 48: 11 PM 0 3.44 0.08 0.31 0.02 0.00 0.12 0.00 96.04 1000.3106: 48: 11 PM 1 3.10 0.08 0.32 0.09 0.02 0.11 0.00 96.28: 48: 11 PM 2 34.9306 4.16 0.11 0.36 0.02 0.00 0.11 0.00 95.25: 48: 11 PM 3 3.77 0.11 0.38 0.03 0.01 0.24 0.00 95.46: 48: 11 PM 4 44.8006 2.96 0.07 0.29 0.04 0.02 0.10 0.00 96.52: 48: 11 PM 5 3.26 0.08 0.28 0.03 0.01 0.10 0.00 96.23: 48: 11 PM 6 14.9806 4.00 0.10 0.34 0.01 0.00 0.13 0.00 & nbsp; 95.42: 48: 11 PM 7 3.30 0.11 0.39 0.03 0.01 0.46 0.00 95.69 76.89 www.2cto.com 10. pmap process memory usage: run the pmap command to report the memory image and use it to find the memory bottleneck: Reference # pmap-d PID output: Reference 47394: /usr/bin/php-cgiAddress Kbytes Mode Offset Device 000000r-x-2584 008:00002 php-cgi0000000000886000 0000000000000000 rw-140 008:00002 php-cgi00000000008a9000 52 rw-00000000008a9000 000:00000 [anon] 0000000000aa8000 76 rw-00000000002a8000 008:00002 php-cgi00 0000000f678000 1980 rw-000000000f678000 000:00000 [anon] 0000112 r-x-0000000000000000 008:00002 ld-2.5.so000000314a81b000 4 r -- 0000000000000001b000 008:00002 ld-2.5.so000000314a81c000 4 rw-0000008:00002 ld-2.5.so000000314aa00000 1328 r-x-0000000000000000 008:00002 libc-2.5.so000000314ab4c000 -- 2017100000014c000 008:00002 libc-2.5.so ..... ........ 4152af8d48fd000 4 rw-0000000000006000 008:00002 xsl. so00002af8d490c000 40 r-x-0000000000000000 008:00002 libnss_files-2.5.so00002af8d4916000 2044 -- 000000000000a000 008:00002 libnss_files-2.5.so00002af8d4b15000 4 r -- 0000000000009000 008:00002 libnss_files-2.5.so00002af8d4b16000 4 rw-000000000000a000 008:00002 libnss_files-2.5.so00002af8d4b17000 768000 rw-s-0000000000000000 000:%9 zero (de Leted) Listen 7fffc95fe000 84 rw-00007ffffea000 000:00000 [stack] ffffffff600000 8192 -- 0000000000000000 000:00000 [anon] mapped: 933712 K writeable/private: 4304 K shared: 768000K the last line is important: www.2cto.com * mapped: 933712 K file memory image size * writeable/private: 4304 K private address space size * shared: 768000 K process shared address space size 11 and 12, netstat and ss network statistics netstat shows network connections, route tables, interface statistics, masquerade connections, multicast member relationships. Ss used to dump socket statistics: Author flanet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.