/usr/lib/ocf/resource.d/heartbeat/AudibleAlarm is in resource-agents 1:4.0.0~rc1-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | #!/bin/sh
#
# Startup script for the Audible Alarm
#
# author: Kirk Lawson <lklawson@heapy.com>
# Horms <horms@vergenet.net>
#
# description: sets an audible alarm running by beeping at a set interval
# processname: alarm
# config: /etc/AudibleAlarm/AudibleAlarm.conf - not yet implemented
#
# OCF parameters are as below:
# OCF_RESKEY_nodelist
#
# License: GNU General Public License (GPL)
#######################################################################
# Source function library.
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
PIDFILE=${HA_VARRUN}/heartbeat-bell
#For testing
#PIDFILE=/tmp/heartbeat-bell
# What host are we running on?
us=`uname -n`
usage() {
echo "Usage: $0 {start|stop|restart|status|monitor|meta-data|validate-all}"
echo " The node list is an optional space delimited"
echo " list of hosts that should never sound the alarm."
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="AudibleAlarm">
<version>1.0</version>
<longdesc lang="en">
Resource script for AudibleAlarm. It sets an audible alarm running by beeping
at a set interval.
</longdesc>
<shortdesc lang="en">Emits audible beeps at a configurable interval</shortdesc>
<parameters>
<parameter name="nodelist" unique="0">
<longdesc lang="en">
The node list that should never sound the alarm.
</longdesc>
<shortdesc lang="en">Node list</shortdesc>
<content type="string" default="" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="10" />
<action name="stop" timeout="10" />
<action name="restart" timeout="10" />
<action name="status" depth="0" timeout="10" interval="10" />
<action name="monitor" depth="0" timeout="10" interval="10" />
<action name="meta-data" timeout="5" />
<action name="validate-all" timeout="5" />
</actions>
</resource-agent>
END
}
audiblealarm_start () {
ocf_log info "$0: Starting"
if [ -f $PIDFILE ]; then
PID=`head -n 1 $PIDFILE`
if [ -n "$PID" ]; then
ocf_log info "$0: Appears to already be running, killing [$PID]"
kill $PID > /dev/null
fi
fi
# Use () to create a subshell to make the redirection be synchronized.
( while [ 1 ]; do
sleep 1 #Sleep first, incase we bail out
printf "\a" > /dev/console
# Uncomment this line to cause floppy drive light
# to flash (requires fdutils package).
# /usr/bin/floppycontrol --pollstate > /dev/null
#
# To avoid issues when called by lrmd, redirect stdout->stderr.
done &
if echo $! > $PIDFILE; then
:
else
ocf_log info "$0: Could not write to pid file \"$PIDFILE\", bailing"
kill $!
return $OCF_ERR_GENERIC
fi) >&2
return $?
}
audiblealarm_stop () {
ocf_log info "$0: Shutting down"
if [ -f $PIDFILE ]; then
PID=`head -n 1 $PIDFILE`
# ocf_log info "$0: Appears to already be running, killing [$PID]"
# commented by Phost, since the confusion in the log.
if [ -n "$PID" ]; then
# Donnot remove PIDFILE in case the `kill` fails.
kill $PID > /dev/null && rm -f $PIDFILE
fi
fi
return $?
}
audiblealarm_restart () {
audiblealarm_stop
audiblealarm_start
return $?
}
audiblealarm_status () {
if [ -f $PIDFILE ]; then
PID=`head -n 1 $PIDFILE`
if [ -n "$PID" ]; then
echo running
return $OCF_SUCCESS
fi
fi
echo stopped
return $OCF_NOT_RUNNING
}
audiblealarm_validate_all () {
check_binary printf
echo "Validate OK"
return $OCF_SUCCESS
}
if [ $# -ne 1 ]; then
usage
exit $OCF_ERR_ARGS
fi
case "$1" in
meta-data)
meta_data
exit $OCF_SUCCESS
;;
start)
for arg in $OCF_RESKEY_nodelist
do
if [ "$us" = "$arg" ]; then
# We should not start because we are on a host
# listed in our argument list.
exit $OCF_SUCCESS
fi
done
audiblealarm_start
;;
stop)
audiblealarm_stop
;;
restart)
audiblealarm_restart
;;
status|monitor)
audiblealarm_status
;;
validate-all)
audiblealarm_validate_all
;;
usage)
usage
exit $OCF_SUCCESS
;;
*)
usage
exit $OCF_ERR_ARGS
;;
esac
exit $?
|