debugging突然的负载峰值

我需要自动debugging突然的负载峰值。 我们已经像检查脚本一样监视着Nagios,但是负载峰值很less。

我search一个守护进程,每N秒检查一次负载,如果有麻烦,报告类似ps aux --forest (和iotop –batch)

用munin创build的graphics在这里没有帮助,因为我需要确定导致负载的过程。

在本地进程监视( select你的毒药 )的许多可能性是monit ,我在/ /etc/monit.d/system.conf /

 check system localhost if loadavg (1min) > 6 then alert if loadavg (5min) > 6 then alert if memory usage > 90% then alert if cpu usage (user) > 90% then alert if cpu usage (system) > 75% then alert if cpu usage (wait) > 75% then alert 

我想你可能希望对检查更加积极,因此你可能希望设置守护进程更频繁地运行检查,也许每隔30秒,直到你确定了问题,因此会使用/etc/monit.conf像这样的东西;

 set daemon 30 set mailserver localhost #set alert [email protected] but not on { instance } set alert [email protected] include /etc/monit.d/* set httpd port 2812 allow 127.0.0.1 

如果monit在默认邮件警报中没有提供足够的信息,那么您可以在警报条件下监听自定义脚本,例如:

 check system localhost if loadavg (1min) > 6 then exec "/bin/bash -c '/usr/bin/top -n1 -b | /bin/mail -s top-output [email protected]'" if loadavg (5min) > 6 then exec "/bin/bash -c '/usr/bin/top -n1 -b | /bin/mail -s top-output [email protected]'" if cpu usage (user) > 90% then exec "/bin/bash -c '/usr/bin/top -n1 -b | /bin/mail -s top-output [email protected]'" 

(显然依赖于正在设置的邮件命令,但你可以使用本地的根,而只是手动检查)

perf是要走的路,它通常默认安装(Debian上的linux-tools )。

使用perf top交互式地查看你的问题,然后使用perf stat -p PID按PID进行优化。 看看维基find更多: https : //perf.wiki.kernel.org/index.php/Main_Page