0

I have postfix email server with saslauthd. Time and again saslauthd daemon eats 100% CPU. Restarting these services returns to normal cpu usage.

Is there any proper script to determine services with high CPU usage and restart it automatically.

Thanks in advance.

closed as off-topic by Jenny D, Sven Sep 7 '18 at 7:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • Don't fix the symptom. Find the cause and fix that – Sven Sep 7 '18 at 7:53
  • Thanks for suggestion. But there seems issue with saslauthd latest version. bugs.launchpad.net/ubuntu/+source/cyrus-sasl2/+bug/997217 And I haven't found proper way to fix it. – Anand Shrestha Sep 7 '18 at 8:06
  • 1
    That bug has been fixed five years ago. If you are affected by it, apply an update. – Sven Sep 7 '18 at 8:09
  • I have latest version of Cyrus-Sasl. 2.1.26. same issue. – Anand Shrestha Sep 8 '18 at 9:46
1

You might want to take a look at monit (official site).

It's easily configurable to watch for high CPU usage and restart processes when needed.

A simple example (you should configure it according to your system paths and needs):

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

Where (taken from the manual):

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

And a cycle is is equal to the number of seconds in the set daemon config options.

  • Is there any script to automate it ? I just want to run "systemctl restart saslauthd" as soon as it reaches 100% CPU. I am just slightly uncomfortable with monit. – Anand Shrestha Sep 7 '18 at 7:42
  • @AnandShrestha see my edits. It's all automatic if monit is configured right. You obviously need to use the correct paths and commands for your system. – Mr Shunz Sep 7 '18 at 7:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.