linux – 如何监控内核执行的系统调用次数?

我需要监视Linux执行的系统调用量.
我知道vmstat能够为BSD和AIX系统显示它,但对于Linux它不能(根据手册页).

/ proc中有任何计数器吗?或者有没有其他方法来监控它?

解决方法:

我写了一个简单的SystemTap脚本(基于syscalls_by_pid.stp).
它产生如下输出:

ProcessName          #SysCalls

munin-graph          38609 
munin-cron           8160  
fping                4502  
check_http_demo      2584  
check_nrpe           2045  
sh                   1836  
nagios               886   
sendmail             747   
smokeping            649   
check_http           571   
check_nt             376   
pcscd                216   
ping                 108   
check_ping           100   
crond                87    
stapio               69    
init                 56    
syslog-ng            27    
sshd                 17    
ntpd                 9     
hp-asrd              8     
hald-addon-stor      7     
automount            6     
httpd                4     
stap                 3     
flow-capture         2     
gam_server           2     

Total                61686

脚本本身:

#! /usr/bin/env stap

#
# Print the system call count by process name in descending order.
#

global syscalls

probe begin {
  print ("Collecting data... Type Ctrl-C to exit and display results\n")
}

probe syscall.* {
  syscalls[execname()]++
}

probe end {
  printf ("%-20s %-s\n\n", "ProcessName", "#SysCalls")
  summary = 0
  foreach (procname in syscalls-) {
    printf("%-20s %-10d\n", procname, syscalls[procname])
    summary = summary + syscalls[procname]
  }
  printf ("\n%-20s %-d\n", "Total", summary)
}
上一篇:mysql插入监控


下一篇:To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to th