/usr/lib/ocf/resource.d/heartbeat/rsyslog 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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | #!/bin/bash
#
# Description: Manages a rsyslog instance, provided by NTT OSSC as an
# OCF High-Availability resource under Heartbeat/LinuxHA control
#
# Copyright (c) 2011 NIPPON TELEGRAPH AND TELEPHONE CORPORATION
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
##############################################################################
# OCF parameters:
# OCF_RESKEY_rsyslog_binary : Path to rsyslog binary.
# Default is "/sbin/rsyslogd"
# OCF_RESKEY_configfile : Configuration file
# OCF_RESKEY_start_opts : Startup options
#
# Only OCF_RESKEY_configfile must be specified. Each of the rests
# has its default value or refers OCF_RESKEY_configfile to make
# its value when no explicit value is given.
#
# Further infomation for setup:
# There are sample configurations at the end of this file.
#
###############################################################################
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
usage()
{
cat <<-!
usage: $0 action
action:
start : start a new rsyslog instance
stop : stop the running rsyslog instance
status : return the status of rsyslog, run or down
monitor : return TRUE if the rsyslog appears to be working.
meta-data : show meta data message
validate-all: validate the instance parameters
!
return $OCF_ERR_UNIMPLEMENTED
}
metadata_rsyslog()
{
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="rsyslog">
<version>1.0</version>
<longdesc lang="en">
This script manages a rsyslog instance as an HA resource.
</longdesc>
<shortdesc lang="en">rsyslog resource agent</shortdesc>
<parameters>
<parameter name="configfile" unique="1" required="1">
<longdesc lang="en">
This parameter specifies a configuration file
for a rsyslog instance managed by this RA.
</longdesc>
<shortdesc lang="en">Configuration file</shortdesc>
<content type="string" default=""/>
</parameter>
<parameter name="rsyslog_binary" unique="0">
<longdesc lang="en">
This parameter specifies rsyslog's executable file.
</longdesc>
<shortdesc lang="en">rsyslog executable</shortdesc>
<content type="string" default="/sbin/rsyslogd"/>
</parameter>
<parameter name="start_opts" unique="0">
<longdesc lang="en">
This parameter specifies startup options for a
rsyslog instance managed by this RA. When no value is given, no startup
options is used. Don't use option '-F'. It causes a stuck of a start action.
</longdesc>
<shortdesc lang="en">Start options</shortdesc>
<content type="string" default=""/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="60s" />
<action name="status" timeout="20s" />
<action name="monitor" depth="0" timeout="20s" interval="20s" />
<action name="meta-data" timeout="5s" />
<action name="validate-all" timeout="5"/>
</actions>
</resource-agent>
END
return $OCF_SUCCESS
}
monitor_rsyslog()
{
set -- $(pgrep -f "$PROCESS_PATTERN" 2>/dev/null)
case $# in
0) ocf_log debug "No rsyslog process for $CONFIGFILE"
return $OCF_NOT_RUNNING;;
1) return $OCF_SUCCESS;;
esac
ocf_log warn "Multiple rsyslog process for $CONFIGFILE"
return $OCF_SUCCESS
}
start_rsyslog()
{
local ocf_status
monitor_rsyslog
if [ $? = "$OCF_SUCCESS" ]; then
return $OCF_SUCCESS
fi
$RSYSLOG_EXE -f $CONFIGFILE $START_OPTS 2>&1
ocf_status=$?
if [ "$ocf_status" != "$OCF_SUCCESS" ]; then
return $OCF_ERR_GENERIC
fi
while true; do
monitor_rsyslog
if [ $? = "$OCF_SUCCESS" ]; then
return $OCF_SUCCESS
fi
sleep 1
done
}
stop_rsyslog()
{
pkill -TERM -f "$PROCESS_PATTERN"
typeset lapse_sec=0
while pgrep -f "$PROCESS_PATTERN" > /dev/null; do
sleep 1
lapse_sec=$(( lapse_sec + 1 ))
ocf_log debug "stop_rsyslog[${OCF_RESOURCE_INSTANCE}]: stop NORM $lapse_sec/$OCF_RESKEY_CRM_meta_timeout"
if [ $lapse_sec -ge $OCF_RESKEY_CRM_meta_timeout ]; then
break
fi
done
lapse_sec=0
while pgrep -f "$PROCESS_PATTERN" > /dev/null; do
pkill -KILL -f "$PROCESS_PATTERN"
sleep 1
lapse_sec=$(( lapse_sec + 1 ))
ocf_log debug "stop_rsyslog[${OCF_RESOURCE_INSTANCE}]: suspend rsyslog by SIGKILL ($lapse_sec/@@@)"
done
return $OCF_SUCCESS
}
status_rsyslog()
{
monitor_rsyslog
rc=$?
if [ $rc = $OCF_SUCCESS ]; then
echo "rsyslog service is running."
elif [ $rc = $OCF_NOT_RUNNING ]; then
echo "rsyslog service is stopped."
fi
return $rc
}
validate_all_rsyslog()
{
ocf_log info "validate_all_rsyslog[${OCF_RESOURCE_INSTANCE}]"
return $OCF_SUCCESS
}
if [[ "$1" = "meta-data" ]]; then
metadata_rsyslog
exit $?
fi
CONFIGFILE="${OCF_RESKEY_configfile}"
if [[ -z "$CONFIGFILE" ]]; then
ocf_log err "undefined parameter:configfile"
exit $OCF_ERR_CONFIGURED
fi
if [[ ! -f "$CONFIGFILE" ]]; then
ocf_log err "Config file $CONFIGFILE does not exist."
exit $OCF_ERR_CONFIGURED
fi
RSYSLOG_EXE="${OCF_RESKEY_rsyslog_binary-/sbin/rsyslogd}"
if [[ ! -x "$RSYSLOG_EXE" ]]; then
ocf_log err "Invalid value:rsyslog_binary:$RSYSLOG_EXE"
exit $OCF_ERR_CONFIGURED
fi
START_OPTS=${OCF_RESKEY_start_opts}
PROCESS_PATTERN="$RSYSLOG_EXE -f $CONFIGFILE"
COMMAND=$1
case "$COMMAND" in
start)
ocf_log debug "[${OCF_RESOURCE_INSTANCE}] Enter rsyslog start"
start_rsyslog
func_status=$?
ocf_log debug "[${OCF_RESOURCE_INSTANCE}] Leave rsyslog start $func_status"
exit $func_status
;;
stop)
ocf_log debug "[${OCF_RESOURCE_INSTANCE}] Enter rsyslog stop"
stop_rsyslog
func_status=$?
ocf_log debug "[${OCF_RESOURCE_INSTANCE}] Leave rsyslog stop $func_status"
exit $func_status
;;
status)
status_rsyslog
exit $?
;;
monitor)
monitor_rsyslog
func_status=$?
exit $func_status
;;
validate-all)
validate_all_rsyslog
exit $?
;;
*)
usage
;;
esac
|