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

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. gplots heatmap.2和ggplot2 geom_tile实现数据聚类和热图plot

    主要步骤 ggplot2 数据处理成矩阵形式,给行名列名 hclust聚类,改变矩阵行列顺序为聚类后的顺序 melt数据,处理成ggplot2能够直接处理的数据结构,并加上列名 ggplot_tile ...

  2. 实例 编辑 .bashrc(不断更新)

    .bashrc 是/root下的隐藏文件,可按习惯编辑命令的别名. vi .bashrc alias rm='rm -i'#alias cp='cp -i'alias mv='mv -i'alias ...

  3. JQuery移动动画实现点击按钮切换图片--JQuery基础

    直接贴源码了哈,这些都是自己总结的……汗水几何?希望能帮到大家. <%@ Page Language="C#" AutoEventWireup="true" ...

  4. ES6常用知识点小结

    ECMAScript 6(以下简称ES6)是JavaScript语言的下一代标准. 因为当前版本的ES6是在2015年发布的,所以又称ECMAScript 2015(简称ES2015).虽然浏览器在不 ...

  5. Python--urllib3库详解1

    Python--urllib3库详解1 Urllib3是一个功能强大,条理清晰,用于HTTP客户端的Python库,许多Python的原生系统已经开始使用urllib3.Urllib3提供了很多pyt ...

  6. javaScript替换元素节点

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  7. Struts2如何实现MVC,与Spring MVC有什么不同?

    Struts2采用filter充当前端控制器处理请求,filter会根据Struts.xml的配置,将请求分发给不同的业务控制器Action,再由Action处理具体的业务逻辑.Action处理完业务 ...

  8. iOS开发——下载器的功能基本实现

    今天,做了一个下载器的Demo,即从本地配置的Apache服务器上,下载指定的文件.这次,我们下载服务器根目录下的html.mp4文件. 按照惯例,我们先创建一个URL对象和请求. NSURL *ur ...

  9. js与后台交互详述(入门篇)

    很多新手前端在初期学习的时候往往把注意力放在如何编写页面,如何编写效果上,群里有个朋友问我js是如何与后台交互的,我简单的说一下. 首先需要知道两个东西,一个是客户端,一个是服务器,客户端其实就是我们 ...

  10. ECharts组件应用样例代码

    一.从Echarts官网上下载最新版本组件 Echarts是百度开发的开源Web图表组件,界面美观,使用简单.组件下载地址:http://echarts.baidu.com/echarts2/doc/ ...