The monitor action queries the current status of a resource. It must
discern between three different states:
$OCF_SUCCESS);
$OCF_NOT_RUNNING);
$OCF_ERR_ code to indicate the nature of the
problem).
foobar_monitor() {
local rc
# exit immediately if configuration is not valid
foobar_validate_all || exit $?
ocf_run frobnicate --test
# This example assumes the following exit code convention
# for frobnicate:
# 0: running, and fully caught up with master
# 1: gracefully stopped
# any other: error
case "$?" in
0)
rc=$OCF_SUCCESS
ocf_log debug "Resource is running"
;;
1)
rc=$OCF_NOT_RUNNING
ocf_log debug "Resource is not running"
;;
*)
ocf_log err "Resource has failed"
exit $OCF_ERR_GENERIC
esac
return $rc
}Stateful (master/slave) resource agents may use a more elaborate
monitoring scheme where they can provide "hints" to the cluster
manager identifying which instance is best suited to assume the
Master role. Section 9.4, “Specifying a master preference” explains the
details.
![]() | Note |
|---|---|
The cluster manager may invoke the |