4
# ClusterMon OCF RA. Does nothing but wait a few seconds, can be
5
# configured to fail occassionally.
7
# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Br�e
10
# This program is free software; you can redistribute it and/or modify
11
# it under the terms of version 2 of the GNU General Public License as
12
# published by the Free Software Foundation.
14
# This program is distributed in the hope that it would be useful, but
15
# WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
# Further, this software is distributed without any warranty that it is
19
# free of the rightful claim of any third person regarding infringement
20
# or the like. Any license provided herein, whether implied or
21
# otherwise, applies only to this software file. Patent licenses, if
22
# any, provided herein do not apply to combinations of this program with
23
# other software, or any other product whatsoever.
25
# You should have received a copy of the GNU General Public License
26
# along with this program; if not, write the Free Software Foundation,
27
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
29
# OCF instance parameters:
33
# OCF_RESKEY_extra_options
36
#######################################################################
39
. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
41
#######################################################################
46
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
47
<resource-agent name="ClusterMon">
48
<version>1.0</version>
51
This is a ClusterMon Resource Agent.
52
It outputs current cluster status to the html.
54
<shortdesc lang="en">ClusterMon resource agent</shortdesc>
58
<parameter name="user" unique="0">
60
The user we want to run crm_mon as
62
<shortdesc lang="en">The user we want to run crm_mon as</shortdesc>
63
<content type="string" default="root" />
66
<parameter name="update" unique="0">
68
How frequently should we update the cluster status
70
<shortdesc lang="en">Update interval</shortdesc>
71
<content type="integer" default="15" />
74
<parameter name="extra_options" unique="0">
76
Additional options to pass to crm_mon. Eg. -n -r
78
<shortdesc lang="en">Extra options</shortdesc>
79
<content type="string" default="" />
82
<parameter name="pidfile" unique="1">
84
PID file location to ensure only one instance is running
86
<shortdesc lang="en">PID file</shortdesc>
87
<content type="string" default="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid" />
90
<parameter name="htmlfile" unique="1" required="1">
92
Location to write HTML output to.
94
<shortdesc lang="en">HTML output</shortdesc>
95
<content type="string" default="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.html" />
100
<action name="start" timeout="90" />
101
<action name="stop" timeout="100" />
102
<action name="monitor" depth="0" timeout="20" interval="10" start-delay="0" />
103
<action name="meta-data" timeout="5" />
104
<action name="validate-all" timeout="30" />
110
#######################################################################
114
usage: $0 {start|stop|monitor|validate-all|meta-data}
116
Expects to have a fully populated OCF RA-compliant environment set.
122
exit $OCF_ERR_GENERIC
131
if [ ! -z $OCF_RESKEY_user ]; then
132
su - $OCF_RESKEY_user -c "${HA_SBIN_DIR}/crm_mon -p $OCF_RESKEY_pidfile -d -i $OCF_RESKEY_update $OCF_RESKEY_extra_options -h $OCF_RESKEY_htmlfile"
134
${HA_SBIN_DIR}/crm_mon -p $OCF_RESKEY_pidfile -d -i $OCF_RESKEY_update $OCF_RESKEY_extra_options -h $OCF_RESKEY_htmlfile
140
if [ -f $OCF_RESKEY_pidfile ]; then
141
pid=`cat $OCF_RESKEY_pidfile`
143
if [ ! -z $pid ]; then
147
rm $OCF_RESKEY_pidfile
154
ClusterMon_monitor() {
155
if [ -f $OCF_RESKEY_pidfile ]; then
156
pid=`cat $OCF_RESKEY_pidfile`
158
if [ ! -z $pid ]; then
164
exit $OCF_NOT_RUNNING
168
while getopts Vi:nrh:cdp: OPTION
172
i) ocf_log warn "You should not have specified the -i option, since OCF_RESKEY_update is set already!";;
173
h) ocf_log warn "You should not have specified the -h option, since OCF_RESKEY_htmlfile is set already!";;
174
p) ocf_log warn "You should not have specified the -p option, since OCF_RESKEY_pidfile is set already!";;
175
*) return $OCF_ERR_ARGS;;
179
if [ $? -ne 0 ]; then
183
# We should have eaten all options at this stage
184
shift $(($OPTIND -1))
185
if [ $# -gt 0 ]; then
192
ClusterMon_validate() {
193
# Existence of the user
194
if [ ! -z $OCF_RESKEY_user ]; then
195
getent passwd "$OCF_RESKEY_user" >/dev/null
196
if [ $? -eq 0 ]; then
197
: Yes, user exists. We can further check his permission on crm_mon if necessary
199
ocf_log err "The user $OCF_RESKEY_user does not exist!"
204
# Pidfile better be an absolute path
205
case $OCF_RESKEY_pidfile in
207
*) ocf_log warn "You should have pidfile($OCF_RESKEY_pidfile) of absolute path!" ;;
210
# Check the update interval
211
if ocf_is_decimal "$OCF_RESKEY_update" && [ $OCF_RESKEY_update -gt 0 ]; then
214
ocf_log err "Invalid update interval $OCF_RESKEY_update. It should be positive integer!"
218
if CheckOptions $OCF_RESKEY_extra_options; then
221
ocf_log err "Invalid options $OCF_RESKEY_extra_options!"
225
# Htmlfile better be an absolute path
226
case $OCF_RESKEY_htmlfile in
228
*) ocf_log warn "You should have htmlfile($OCF_RESKEY_htmlfile) of absolute path!" ;;
236
if [ $# -ne 1 ]; then
241
: ${OCF_RESKEY_update:="15000"}
242
: ${OCF_RESKEY_pidfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid"}
243
: ${OCF_RESKEY_htmlfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.html"}
245
OCF_RESKEY_update=`expr $OCF_RESKEY_update / 1000`
247
case $__OCF_ACTION in
251
start) ClusterMon_start
253
stop) ClusterMon_stop
255
monitor) ClusterMon_monitor
257
validate-all) ClusterMon_validate
259
usage|help) ClusterMon_usage
263
exit $OCF_ERR_UNIMPLEMENTED