*Note: I have trouble deciding what should go in serverfault and what should go in superuser, if some kindly admin decides this is in the wrong place please move it for me - many thanks.

I am implementing a basic HA system with keepalived. I only want to be notified of the failover in the case of hardware failure.

I do, however, have the servers switch roles periodically. I have a track_script running on the backup that will vary it's return between 0 and 1 on an interval (once a week, once a month, whatever). Upon returning 0, the priority is raised above that of the master, upon returning 1 the priority is lowered again. This way they trade places on the configured interval.

The question: What can I do to tell the difference between a switch caused by my script, and a switch caused because one of the servers died? I certainly want to be notified when there is an actual problem, but not every time the servers change places because of the script.

I see that version 1.2.7 has snmp support and I may be able to use it to get some information that could tell me one way or another, but to be honest I've never used snmp before and I don't know how to get the information I want with it (my Google foo failed me).

1 Answer 1


You could do it by disabling the email notification in keepalived and creating notify_master and notify_fault scripts which will send emails when a servers gets promoted to a master, or if it has a fault.

The track_script could touch a file to update its modified time when it does the "planned" switchover and the notify_master and notify_fault scripts could read the timestamp of that file (with stat -c %Y file) and if that timestamp is older than e.g. 60 seconds, then it was a planned switchover and don't send an email, otherwise send it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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