Skip to content

Commit

Permalink
Merge pull request #2768 from waltdisgrace/t147
Browse files Browse the repository at this point in the history
T147
  • Loading branch information
kgaillot authored Aug 18, 2022
2 parents ad32bc5 + 7311336 commit c14102d
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions extra/resources/ClusterMon.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
meta_data() {
cat <<END
<?xml version="1.0"?>
<resource-agent name="ClusterMon" version="1.1">
<version>1.0</version>
<resource-agent name="ClusterMon" version="1.2">
<version>1.1</version>
<longdesc lang="en">
This is a ClusterMon Resource Agent.
Expand All @@ -43,15 +43,15 @@ It outputs current cluster status to the html.
<parameters>
<parameter name="user" unique="0">
<parameter name="user">
<longdesc lang="en">
The user we want to run crm_mon as
</longdesc>
<shortdesc lang="en">The user we want to run crm_mon as</shortdesc>
<content type="string" default="root" />
</parameter>
<parameter name="update" unique="0">
<parameter name="update">
<longdesc lang="en">
How frequently should we update the cluster status (in milliseconds).
For compatibility with old documentation, values less than 1000 will be treated
Expand All @@ -61,23 +61,23 @@ as seconds.
<content type="integer" default="15000" />
</parameter>
<parameter name="extra_options" unique="0">
<parameter name="extra_options">
<longdesc lang="en">
Additional options to pass to crm_mon. Eg. -n -r
</longdesc>
<shortdesc lang="en">Extra options</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="pidfile" unique="1">
<parameter name="pidfile" unique-group="pidfile">
<longdesc lang="en">
PID file location to ensure only one instance is running
</longdesc>
<shortdesc lang="en">PID file</shortdesc>
<content type="string" default="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid" />
</parameter>
<parameter name="htmlfile" unique="1" required="0">
<parameter name="htmlfile" unique-group="htmlfile" required="0">
<longdesc lang="en">
Location to write HTML output to.
</longdesc>
Expand Down Expand Up @@ -173,6 +173,11 @@ do
p) ocf_log warn "You should not have specified the -p option, since OCF_RESKEY_pidfile is set already!";;
*) return $OCF_ERR_ARGS;;
esac

case "$OCF_RESKEY_extra_options" in
*--output-as*) ocf_log warn "You should not have specified the -output-as option, since OCF_RESKEY_htmlfile is set already!";;
*--output-to*) ocf_log warn "You should not have specified the -output-to option, since OCF_RESKEY_htmlfile is set already!";;
esac
done

if [ $? -ne 0 ]; then
Expand All @@ -189,16 +194,21 @@ fi
}

ClusterMon_validate() {
# Existence of the user
if [ -n "$OCF_RESKEY_user" ]; then
getent passwd "$OCF_RESKEY_user" >/dev/null
if [ $? -eq 0 ]; then
: Yes, user exists. We can further check his permission on crm_mon if necessary
else
ocf_log err "The user $OCF_RESKEY_user does not exist!"
exit $OCF_ERR_ARGS
# Host-specific checks
if [ "$OCF_CHECK_LEVEL" = "10" ]; then

# Existence of the user
if [ -n "$OCF_RESKEY_user" ]; then
getent passwd "$OCF_RESKEY_user" >/dev/null
if [ $? -eq 0 ]; then
: Yes, user exists. We can further check his permission on crm_mon if necessary
else
ocf_log err "The user $OCF_RESKEY_user does not exist!"
exit $OCF_ERR_ARGS
fi
fi
fi

fi

# Pidfile better be an absolute path
case "$OCF_RESKEY_pidfile" in
Expand Down Expand Up @@ -240,7 +250,7 @@ if [ ${OCF_RESKEY_update} -ge 1000 ]; then
OCF_RESKEY_update=$(( $OCF_RESKEY_update / 1000 ))
fi

CMON_CMD="${HA_SBIN_DIR}/crm_mon -p \"$OCF_RESKEY_pidfile\" -d -i $OCF_RESKEY_update $OCF_RESKEY_extra_options -h \"$OCF_RESKEY_htmlfile\""
CMON_CMD="${HA_SBIN_DIR}/crm_mon -p \"$OCF_RESKEY_pidfile\" -d -i $OCF_RESKEY_update $OCF_RESKEY_extra_options --output-as=html --output-to=\"$OCF_RESKEY_htmlfile\""

case "$__OCF_ACTION" in
meta-data) meta_data
Expand Down

0 comments on commit c14102d

Please sign in to comment.