![CPU 使用率が 100% に達した場合に Linux サービスを再起動するにはどうすればよいでしょうか?](https://rvso.com/image/726829/CPU%20%E4%BD%BF%E7%94%A8%E7%8E%87%E3%81%8C%20100%25%20%E3%81%AB%E9%81%94%E3%81%97%E3%81%9F%E5%A0%B4%E5%90%88%E3%81%AB%20Linux%20%E3%82%B5%E3%83%BC%E3%83%93%E3%82%B9%E3%82%92%E5%86%8D%E8%B5%B7%E5%8B%95%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%3F%20.png)
私は 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
そしてサイクルこれは設定オプションの秒数と同じですset daemon
。