CPU가 100%에 도달하면 Linux 서비스를 다시 시작하는 방법은 무엇입니까?

CPU가 100%에 도달하면 Linux 서비스를 다시 시작하는 방법은 무엇입니까?

saslauthd가 포함된 postfix 이메일 서버가 있습니다. saslauthd 데몬이 CPU를 100% 잡아먹는 경우가 많습니다. 이러한 서비스를 다시 시작하면 정상적인 CPU 사용량으로 돌아갑니다.

CPU 사용량이 높은 서비스를 확인하고 자동으로 다시 시작하는 적절한 스크립트가 있습니까?

미리 감사드립니다.

답변1

다음을 살펴보고 싶을 수도 있습니다 monit(공식 사이트).

높은 CPU 사용량을 감시하고 필요할 때 프로세스를 다시 시작하도록 쉽게 구성할 수 있습니다.

간단한 예(시스템 경로 및 필요에 따라 구성해야 함):

check process saslauth with pidfile /var/run/saslauthd/saslauthd.pid
    group mail
    start program = "/etc/init.d/saslauthd start"
    stop program = "/etc/init.d/saslauthd stop"
    if cpu > 90% for 2 cycles then restart

여기서 (매뉴얼에서 따옴):

CPU([user|system|wait]) is the percent of time the system spend in user or 
kernel space and I/O. The user/system/wait modifier is optional, if not 
used, the total system cpu usage is tested

그리고주기is는 구성 옵션의 초 수와 같습니다 set daemon.

관련 정보