先说明下,之所以同类内容分成多篇文章,不是为了凑篇数,而是为了便于自己和大家阅读,下面继续:

7、sar

The sar command is used to collect, report, and save system activity information. The sar command consists of three applications: sar, which displays the data, and sa1 and sa2, which are used for collecting and storing the data. The sar tool features a wide range of options so be sure to check the man page for it. The sar utility is part of the sysstat package.

To accomplish this, add the lines to /etc/crontab.Keep in mind that a default cron job running sar daily is set up automatically after installing sar on your system.

Example of starting automatic log reporting with cron

-------------------------------------------------------------------------------------------------------------

# 8am-7pm activity reports every 10 minutes during weekdays.
*/10 8-18 * * 1-5 /usr/lib/sa/sa1 600 6 &
# 7pm-8am activity reports every an hour during weekdays.
0 19-7 * * 1-5 /usr/lib/sa/sa1 &
# Activity reports every an hour on Saturday and Sunday.
0 * * * 0,6 /usr/lib/sa/sa1 &
# Daily summary prepared at 19:05
5 19 * * * /usr/lib/sa/sa2 -A &

----------------------------------------------------------------------------------------------------------------

The raw data for the sar tool is stored under /var/log/sa/ where the various files represent the days of the respective month. To examine your results, select the weekday of the month and he requested performance data. For example, to display the network counters from the 21st, use the command sar -n DEV -f sa21 and pipe it to less as in the following example:

---------------------------------------------------------------------------------------------------------------

root# sar -n DEV -f sa21 | less
Linux 2.6.9-5.ELsmp (linux.itso.ral.ibm.com) 04/21/2005
12:00:01 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
12:10:01 AM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 AM eth0 1.80 0.00 247.89 0.00 0.00 0.00 0.00
12:10:01 AM eth1 0.00 0.00 0.00 0.00 0.00 0.00 0.00

---------------------------------------------------------------------------------------------------------------

You can also use sar to run near-real-time reporting from the command line as the following example:
---------------------------------------------------------------------------------------------------------------

root# sar -u 3 10
Linux 2.4.21-9.0.3.EL (x232) 05/22/2004
02:10:40 PM CPU %user %nice %system %idle
02:10:43 PM all 0.00 0.00 0.00 100.00
02:10:46 PM all 0.33 0.00 0.00 99.67
02:10:49 PM all 0.00 0.00 0.00 100.00
02:10:52 PM all 7.14 0.00 18.57 74.29
02:10:55 PM all 71.43 0.00 28.57 0.00
02:10:58 PM all 0.00 0.00 100.00 0.00
02:11:01 PM all 0.00 0.00 0.00 0.00
02:11:04 PM all 0.00 0.00 100.00 0.00
02:11:07 PM all 50.00 0.00 50.00 0.00
02:11:10 PM all 0.00 0.00 100.00 0.00
Average: all 1.62 0.00 3.33 95.06

----------------------------------------------------------------------------------------------------------------

From the collected data, you see a detailed overview of CPU utilization (%user, %nice,%system, %idle), memory paging, network I/O and transfer statistics, process creation activity, activity for block devices, and interrupts/second over time.

8、mpstat

The mpstat command is used to report the activities of each of the available CPUs on a multiprocessor server. Global average activities among all CPUs are also reported. The mpstat utility is part of the sysstat package.for example:

root# mpstat -P ALL
Linux 2.6.9-5.ELsmp (linux.itso.ral.ibm.com) 04/22/2005
03:19:21 PM       CPU         %user         %nice         %system        %iowait            %irq              %soft              %idle              intr/s
03:19:21 PM       all              0.03             0.00            0.34                 0.06                  0.02               0.08                99.47             1124.22
03:19:21 PM       0                0.03             0.00            0.33                 0.03                  0.04               0.15                99.43              612.12
03:19:21 PM       1                0.03             0.00            0.36                 0.10                  0.01               0.01                99.51               512.09

root# mpstat -P ALL 1 2
Linux 2.6.9-5.ELsmp (linux.itso.ral.ibm.com) 04/22/2005
03:31:51 PM           CPU           %user             %nice            %system             %iowait                 %irq                   %soft                 %idle                      intr/s
03:31:52 PM           all                0.00                 0.00               0.00                      0.00                       0.00                    0.00                   100.00                   1018.81
03:31:52 PM           0                  0.00                 0.00               0.00                      0.00                       0.00                    0.00                   100.00                   991.09
03:31:52 PM           1                  0.00                 0.00               0.00                      0.00                       0.00                    0.00                    99.01                     27.72

Average:                  CPU           %user             %nice            %system             %iowait                 %irq                   %soft                 %idle                       intr/s
Average:                  all                0.00                 0.00                0.00                     0.00                        0.00                   0.00                   100.00                    1031.89
Average:                  0                  0.00                 0.00                0.00                     0.00                        0.00                   0.00                   100.00                    795.68
Average:                  1                  0.00                 0.00                0.00                     0.00                        0.00                   0.00                    99.67                      236.54

For the complete syntax of the mpstat command, issue:
mpstat -?

9、numastat

With Non-Uniform Memory Architecture (NUMA) systems such as the IBM System x 3950,NUMA architectures have become mainstream in enterprise data centers. However, NUMA systems introduce new challenges to the performance tuning process. Topics such as memory locality were of no interest until NUMA systems arrived. Luckily, Enterprise Linux distributions provide a tool for monitoring the behavior of NUMA architectures. The numastat command provides information about the ratio of local versus remote memory usage and the overall memory configuration of all nodes. Failed allocations of local memory, as displayed in the numa_miss column and allocations of remote memory (slower memory), as displayed in the numa_foreign column should be investigated. Excessive allocation of remote memory will increase system latency and likely decrease overall performance. Binding processes to a node with the memory map in the local RAM will most likely improve performance.for example:

root# numastat
                                node1                  node0
numa_hit              76557759           92126519
numa_miss         30772308           30827638
numa_foreign      30827638          30772308
interleave_hit       106507               103832
local_node           76502227           92086995
other_node          30827840            30867162

10、pmap

The pmap command reports the amount of memory that one or more processes are using. You can use this tool to determine which processes on the server are being allocated memory and whether this amount of memory is a cause of memory bottlenecks. For detailed information,use pmap -d option.

pmap -d <pid>

for example,

root# pmap -d 1
1: init [3]
Address                                Kbytes          Mode         Offset                                      Device                                  Mapping
0000000000400000          36                  r-x--            0000000000000000           0fd:00000                            init
0000000000508000          8                    rw---           0000000000008000           0fd:00000                            init
000000000050a000         132                rwx--           000000000050a000           000:00000                           [ anon ]
0000002a95556000          4                    rw---           0000002a95556000           000:00000                           [ anon ]
0000002a95574000          8                    rw---           0000002a95574000           000:00000                           [ anon ]
00000030c3000000          84                  r-x--            0000000000000000            0fd:00000                            ld-2.3.4.so
00000030c3114000          8                    rw---           0000000000014000            0fd:00000                            ld-2.3.4.so
00000030c3200000          1196             r-x--            0000000000000000            0fd:00000                            libc-2.3.4.so
00000030c332b000          1024             -----             000000000012b000            0fd:00000                           libc-2.3.4.so
00000030c342b000          8                    r----             000000000012b000            0fd:00000                           libc-2.3.4.so
00000030c342d000         12                  rw---            000000000012d000            0fd:00000                           libc-2.3.4.so
00000030c3430000         16                  rw---            00000030c3430000            000:00000                          [ anon ]
00000030c3700000          56                 r-x--             0000000000000000            0fd:00000                           libsepol.so.1
00000030c370e000         1020             -----              000000000000e000            0fd:00000                           libsepol.so.1
00000030c380d000          4                   rw---             000000000000d000           0fd:00000                           libsepol.so.1
00000030c380e000          32                 rw---             00000030c380e000           000:00000                          [ anon ]
00000030c4500000          56                 r-x--              0000000000000000           0fd:00000                           libselinux.so.1
00000030c450e000          1024            -----               000000000000e000           0fd:00000                           libselinux.so.1
00000030c460e000          4                   rw---              000000000000e000          0fd:00000                           libselinux.so.1
00000030c460f000           4                   rw---              00000030c460f000            000:00000                          [ anon ]
0000007fbfffc000               16                 rw---              0000007fbfffc000                000:00000                          [ stack ]
ffffffffff600000                       8192            -----                0000000000000000          000:00000                          [ anon ]
mapped: 12944K               writeable/private: 248K                  shared: 0K

For the complete syntax of the pmap command, issue:
pmap -?

11、netstat

常用选项:

-a Show all socket information
-r Show routing information
-i Show network interface statistics
-s Show network protocol statistics

例子:

root# netstat -natuw
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:36285 127.0.0.1:12865 TIME_WAIT
tcp 0 0 10.0.0.5:37322 10.0.0.4:33932 TIME_WAIT
tcp 0 1 10.0.0.5:55351 10.0.0.4:33932 SYN_SENT
tcp 0 1 10.0.0.5:55350 10.0.0.4:33932 LAST_ACK
tcp 0 0 10.0.0.5:64093 10.0.0.4:33932 TIME_WAIT
tcp 0 0 10.0.0.5:35122 10.0.0.4:12865 ESTABLISHED
tcp 0 0 10.0.0.5:17318 10.0.0.4:33932 TIME_WAIT
tcp 0 0 :::22 :::* LISTEN
tcp 0 2056 ::ffff:192.168.0.254:22 ::ffff:192.168.0.1:3020 ESTABLISHED
udp 0 0 0.0.0.0:111 0.0.0.0:*
udp 0 0 0.0.0.0:631 0.0.0.0:*
udp 0 0 :::5353 :::*

输出列说明:

Proto:The protocol (tcp, udp, raw) used by the socket.
Recv-Q:The count of bytes not copied by the user program connected to this socket.
Send-Q:The count of bytes not acknowledged by the remote host.
Local Address:Address and port number of the local end of the socket. Unless the --numeric (-n) option is specified, the socket address is resolved to its canonical host name (FQDN), and the port number is translated into the corresponding service name.
Foreign Address:Address and port number of the remote end of the socket.
State:The state of the socket. Since there are no states in raw mode and usually no states used in UDP, this column may be left blank.

至此,已经介绍了linux上常用的工具,此外,还有一些使用频率较低或者针对某个方面更专业的工具,例如:iptraf,tcpdump / ethereal,nmon,strace等,这了不再一一详述,仅供大家参考学习,禁止转载。

linux分析、诊断及调优必备的“杀器”之二的更多相关文章

  1. linux分析、诊断及调优的必备“杀器”之一

    下面分别列出linux分析.诊断及调优时用到的工具,并分别进行说明,以方便自己和其他同学参考学习,禁止转载. 1.top top - 02:06:59 up 4 days, 17:14, 2 user ...

  2. linux 内核参数VM调优 之 参数调节和场景分析

    1. pdflush刷新脏数据条件 (linux IO 内核参数调优 之 原理和参数介绍)上一章节讲述了IO内核调优介个重要参数参数. 总结可知cached中的脏数据满足如下几个条件中一个或者多个的时 ...

  3. (转)linux IO 内核参数调优 之 参数调节和场景分析

    1. pdflush刷新脏数据条件 (linux IO 内核参数调优 之 原理和参数介绍)上一章节讲述了IO内核调优介个重要参数参数. 总结可知cached中的脏数据满足如下几个条件中一个或者多个的时 ...

  4. MySQL性能诊断与调优 转

    http://www.cnblogs.com/preftest/ http://www.highperfmysql.com/     BOOK LAMP 系统性能调优,第 3 部分: MySQL 服务 ...

  5. MySQL性能诊断与调优

    LAMP 系统性能调优,第 3 部分: MySQL 服务器调优http://www.ibm.com/developerworks/cn/linux/l-tune-lamp-3.html LoadRun ...

  6. Perf Event :Linux下的系统性能调优工具

    Perf Event :Linux下的系统性能调优工具 2011-05-27 10:35 刘 明 IBMDW 字号:T | T Perf Event 是一款随 Linux 内核代码一同发布和维护的性能 ...

  7. linux概念之性能调优

    目前,对系统进行性能调试的工具有很多,这些可以两大类:一类是标准的分析工具,即所有的UNIX都会带的分析工具: 另一类是不同厂商的UNIX所特有的性能分析工具,比如HP-UX就有自己的增值性能分析工具 ...

  8. Perf -- Linux下的系统性能调优工具,第 2 部分 特殊用法以及内核调优示例

    https://www.ibm.com/developerworks/cn/linux/l-cn-perf2/ 本文内容简介 之前介绍了 perf 最常见的一些用法,关注于 Linux 系统上应用程序 ...

  9. Java垃圾收集器——Parallel、G1收集器日志分析及性能调优示范

    开发过程中,经常需要对GC的垃圾收集器参数不断的进行动态调整,从而更充分的压榨机器性能,提升应用效率.本文将从常见的Parallel/G1垃圾收集器的GC日志着手,分析GC日志的具体含义,以及示范如何 ...

随机推荐

  1. js拖拽分析

    js拖拽分析 思路 1.三个鼠标事件,mousedown,mousemove,mouseup 2.可移动性absolute 3.边界限制 得到鼠标点击处和div边界的距离,然后得出top 和 left ...

  2. [Luogu3242][HNOI2015]接水果

    Luogu 我今天做两道整体二分结果全都是BZOJ权限题??? sol 我们抓住"盘子的路径是水果的路径的子路径"这个条件. 考虑每一个盘子路径\((u,v)\),讨论它可以作为哪 ...

  3. Bzoj4872: [Shoi2017]分手是祝愿

    题面 Bzoj Sol 首先从大向小,能关就关显然是最优 然后 设\(f[i]\)表示剩下最优要按i个开关的期望步数,倒推过来就是 \[ f[i]=f[i-1]*i*inv[n]+f[i+1]*(n- ...

  4. 一个题目涉及到的50个Sql语句

    原博客地址 http://blog.csdn.net/maco_wang/article/details/6281484 Student(S#,Sname,Sage,Ssex) 学生表 Course( ...

  5. Redis进阶实践之十八 使用管道模式加速Redis查询

    一.引言             学习redis 也有一段时间了,该接触的也差不多了.后来有一天,以为同事问我,如何向redis中批量的增加数据,肯定是大批量的,为了这主题,我从新找起了解决方案.目前 ...

  6. ubuntu16.04 安装常见问题解决方案------输入法黑框

    我的系统是 lubuntu 16.04 刚安装输入法候选字的地方全是黑框,然后百度查到了 compton 和 xcompmgr 这两个说是窗口微调 透明 ,这两个方法对我的系统不管用 .各位如果遇到黑 ...

  7. repo 和git的用法

    1. 服务器版本下载: repo init -u git@192.168.1.11:i700t_60501010/platform/manifest.git-b froyo_almond -m M76 ...

  8. 深入解析条件变量(condition variables)

    深入解析条件变量 什么是条件变量(condition variables) 引用APUE中的一句话: Condition variables are another synchronization m ...

  9. 云计算之路-阿里云上:针对 docker swarm 故障的部署调整以及应急措施

    针对这周 docker swarm 集群的频繁故障(详见故障一 .故障二.故障三),我们今天对 docker swarm 集群的部署进行了如下调整. 将 docker engine 由  “17.12 ...

  10. 进程优化工具Process Lasso Pro 8.4官方版+激活破解方法

    Process Lasso是一款来自美国的系统进程优化工具,基于特殊算法动态调整进程的优先级别,通过合理的设置进程优先级来实现降低系统负担的功能.可有效避免蓝 屏.假死.进程停止响应.进程占用 CPU ...