Hi,
On Tue, May 12, 2015 at 03:49:49AM -0700, Eden wrote:
> Hi all,
> I am trying to write my own resource agent service,
> I have corosync + pacemaker + lcmc
>
> When I load the service it shows that it's running, Then after a few seconds
> it stops,
> I checked with a default resource agent (Dummy, sshd etc) and they work.
Did you check out the Resource agents developer's guide?
Cheers,
Dejan
> I'm running centos6.6 and these are the packages version:
> corosync-1.4.7-1.el6.x86_64
> corosynclib-1.4.7-1.el6.x86_64
> pacemaker-1.1.12-4.el6.x86_64
> pacemaker-cli-1.1.12-4.el6.x86_64
> pacemaker-cluster-libs-1.1.12-4.el6.x86_64
> pacemaker-libs-1.1.12-4.el6.x86_64
>
> When I look in ps I can see it actually starts the server but then it fall
> again,
>
> This is my resource agent:
>
>
> #!/bin/bash
>
> #######################################################################
> # Initialization:
> : ${OCF_FUNCTIONS=${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs}
> . ${OCF_FUNCTIONS}
> : ${__OCF_ACTION=$1}
>
> #######################################################################
>
> meta_data() {
> cat <<END
> <?xml version="1.0"?>
> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> <resource-agent name="Sqream" version="1.0">
> <version>1.0</version>
>
> <longdesc lang="en">
> sqream
> </longdesc>
> <shortdesc lang="en">sqream</shortdesc>
> <parameters>
>
> <parameter name="pidfile" unique="0">
> <longdesc lang="en">PID file</longdesc>
> <shortdesc lang="en">PID file</shortdesc>
> <content type="string" default="$HA_VARRUN/sqream-${OCF_RESOURCE_INSTANCE}"
> />
> </parameter>
> </parameters>
>
> <actions>
> <action name="start" timeout="20" />
> <action name="stop" timeout="20" />
> <action name="monitor" timeout="20" interval="10" depth="0"/>
> <action name="meta-data" timeout="5" />
> </actions>
> </resource-agent>
> END
> }
>
> #######################################################################
>
> trap sigterm_handler TERM
> sigterm_handler() {
> echo sigterm_handler >> /tmp/sqream_cluster.log
> ocf_log info "They use TERM to bring us down. No such luck."
> return
> }
>
> sqream_usage() {
> cat <<END
> usage: $0
> {start|stop|monitor|migrate_to|migrate_from|validate-all|meta-data}
>
> END
> }
>
> sqream_start() {
> sqream_monitor
> sleep 4
> /etc/init.d/sqream start
> if [ $? = $OCF_SUCCESS ]; then
> return $OCF_SUCCESS
> fi
> }
>
> sqream_stop() {
> sqream_monitor
> sleep 2
> /etc/init.d/sqream stop
> return $OCF_SUCCESS
> }
>
> sqream_monitor() {
>
> if pgrep "sqreamd" > /dev/null
> then
> return 0
> else
> return 7
> fi
> return $OCF_NOT_RUNNING
> }
>
> sqream_validate() {
> date >> /tmp/sqream_cluster.log
> echo Validating >> /tmp/sqream_cluster.log
> # Is the state directory writable?
> state_dir=`dirname "$OCF_RESKEY_state"`
> touch "$state_dir/$$"
> if [ $? != 0 ]; then
> return $OCF_ERR_ARGS
> fi
> rm "$state_dir/$$"
>
> return $OCF_SUCCESS
> }
>
> : ${OCF_RESKEY_fake=sqream}
> : ${OCF_RESKEY_op_sleep=0}
> : ${OCF_RESKEY_CRM_meta_interval=0}
> : ${OCF_RESKEY_CRM_meta_globally_unique:="true"}
>
> if [ "x$OCF_RESKEY_state" = "x" ]; then
> if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then
> state="${HA_VARRUN}/Sqream-${OCF_RESOURCE_INSTANCE}.state"
>
> # Strip off the trailing clone marker
> OCF_RESKEY_state=`echo $state | sed s/:[0-9][0-9]*\.state/.state/`
> else
> OCF_RESKEY_state="${HA_VARRUN}/Sqream-${OCF_RESOURCE_INSTANCE}.state"
> fi
> fi
>
> case $__OCF_ACTION in
> meta-data) meta_data
> exit $OCF_SUCCESS
> ;;
> start) sqream_start;;
> stop) sqream_stop;;
> monitor) sqream_monitor;;
> migrate_to) ocf_log info "Migrating ${OCF_RESOURCE_INSTANCE} to
> ${OCF_RESKEY_CRM_meta_migrate_target}."
> sqream_stop
> ;;
> migrate_from) ocf_log info "Migrating ${OCF_RESOURCE_INSTANCE} to
> ${OCF_RESKEY_CRM_meta_migrate_source}."
> sqream_start
> ;;
> reload) ocf_log err "Reloading..."
> sqream_start
> ;;
> validate-all) sqream_validate;;
> usage|help) sqream_usage
> exit $OCF_SUCCESS
> ;;
> *) sqream_usage
> exit $OCF_ERR_UNIMPLEMENTED
> ;;
> esac
> rc=$?
> #ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
> exit $rc
>
>
>
>
> I would love some help,
> Thanks a lot
> Eden.
>
>
>
> --
> View this message in context:
> http://linux-ha.996297.n3.nabble.com/Creating-A-resource-agent-tp16196.html
> Sent from the Linux-HA mailing list archive at Nabble.com.
> _______________________________________________
> Linux-HA mailing list is closing down.
> Please subscribe to [email protected] instead.
> http://clusterlabs.org/mailman/listinfo/users
> _______________________________________________
> [email protected]
> http://lists.linux-ha.org/mailman/listinfo/linux-ha
_______________________________________________
Linux-HA mailing list is closing down.
Please subscribe to [email protected] instead.
http://clusterlabs.org/mailman/listinfo/users
_______________________________________________
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha