ITPub博客

首页 > IT职业 > IT职场 > DBA常用系统监控命令(之一)

DBA常用系统监控命令(之一)

IT职场 作者:达芬奇的梦 时间:2018-03-06 10:13:07 0 删除 编辑

1.  对cpu进行监控

1. 1利用sar 命令监控cpu使用情况

sar参数说明 

 选项    功能

-A    汇总所有的报告

-a    报告文件读写使用情况  

-B    报告附加的缓存的使用情况

-b    报告缓存的使用情况

-c    报告系统调用的使用情况

-d    报告磁盘的使用情况

-g    报告串口的使用情况

-h    报告关于buffer使用的统计数据

-m   报告IPC消息队列和信号量的使用情况

-n    报告命名cache的使用情况

-p    报告调页活动的使用情况

-q    报告运行队列和交换队列的平均长度

-R    报告进程的活动情况

-r    报告没有使用的内存页面和硬盘块

-u    报告CPU的利用率

-v    报告进程、i节点、文件和锁表状态

-w   报告系统交换活动状况

-y   报告TTY设备活动状况

sar是System Activity Reporter(系统活动情况报告)的缩写。顾名思义,sar工具将对系统当前的状态进行取样,然后通过计算数据和比例来表达系统的当前运行状态。它的特点是可以连续对系统取样,获得大量的取样数据;取样数据和分析的结果都可以存入文件,所需的负载很小。sar是目前Linux上最为全面的系统性能分析工具之一,可以从14个大方面对系统的活动进行报告,包括文件的读写情况、系统调用的使用情况、串口、CPU效率、内存使用状况、进程活动及IPC有关的活动等,使用也是较为复杂。

 

sar的语法如下:

sar [-option] [-o file] t [n]

 

  它的含义是每隔t秒取样一次,共取样n次。其中-o file表示取样结果将以二进制形式存入文件file中。

 

With the –u switch, sar can be used to monitor CPU utilization. The sar utility is an effective way to see a quick snapshot of how heavily the CPU is ‘bogged down’.

Report CPU utilization (10 seconds apart; 3 times)

#sar –u  10  3

Linux 2.4.21-15.ELsmp (mail.ciq.org.cn)         2005年03月15日

 

16时36分08       CPU     %user     %nice   %system     %idle

16时36分18       all      0.23      0.00      0.23     99.55

16时36分28       all      0.10      0.00      0.15     99.75

16时36分38       all      0.15      0.65      0.28     98.92

Average:            all      0.16      0.22      0.22     99.40

%usr : Percentage of CPU utilization that occurred while executing at the user level (application).

%nice: Percentage of CPU utilization that occurred while executing at the user level with nice priority.

%system: Percentage of CPU utilization that occurred while executing at the system level (kernel).

%idle: Percentage of time that the CPU or CPUs were idle.

 

A low %idle time could point to a CPU-intensive job or an underpowered CPU. Use the ps or top command to find a CPU-intensive job. A poorly written query requiring a large amount of disk access can also cause a large amount of CPU usage as well.

 

1.2 利用uptime监控CPU的负载

 

# uptime

 16:59:45   up 38 days,   3:15,  3 users,  load average: 2.10, 2.00, 3.20

 


  

 

      The uptime command is an excellent utility to find a quick 1,5 and 15 minute CPU load of all jobs(including those currently running). Note that this is not the percentage of CPU being used.

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31444259/viewspace-2151542/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2017-03-15

  • 博文量
    172
  • 访问量
    296703