diff --git a/doc/Makefile.am b/doc/Makefile.am index 3659544a6..f6437bf0d 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,160 +1,161 @@ # # doc: Linux-HA resource agents # # Copyright (C) 2009 Florian Haas # # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = $(doc_DATA) $(REFENTRY_STYLESHEET) \ mkappendix.sh ralist.sh CLEANFILES = $(man_MANS) $(xmlfiles) metadata-*.xml doc_DATA = README.webapps STYLESHEET_PREFIX ?= http://docbook.sourceforge.net/release/xsl/current MANPAGES_STYLESHEET ?= $(STYLESHEET_PREFIX)/manpages/docbook.xsl HTML_STYLESHEET ?= $(STYLESHEET_PREFIX)/xhtml/docbook.xsl FO_STYLESHEET ?= $(STYLESHEET_PREFIX)/fo/docbook.xsl REFENTRY_STYLESHEET ?= ra2refentry.xsl XSLTPROC_OPTIONS ?= --xinclude XSLTPROC_MANPAGES_OPTIONS ?= $(XSLTPROC_OPTIONS) XSLTPROC_HTML_OPTIONS ?= $(XSLTPROC_OPTIONS) XSLTPROC_FO_OPTIONS ?= $(XSLTPROC_OPTIONS) radir = $(top_srcdir)/heartbeat # OCF_ROOT=. is necessary due to a sanity check in ocf-shellfuncs # (which tests whether $OCF_ROOT points to a directory metadata-%.xml: $(radir)/% OCF_ROOT=. OCF_FUNCTIONS_DIR=$(radir) $< meta-data > $@ metadata-IPv6addr.xml: ../heartbeat/IPv6addr OCF_ROOT=. OCF_FUNCTIONS_DIR=$(radir) $< meta-data > $@ # Please note: we can't name the man pages # ocf:heartbeat:. Believe me, I've tried. It looks like it # works, but then it doesn't. While make can deal correctly with # colons in target names (when properly escaped), it royally messes up # when it is deals with _dependencies_ that contain colons. See Bug # 12126 on savannah.gnu.org. But, maybe it gets fixed soon, it was # first reported in 1995 and added to Savannah in in 2005... if BUILD_DOC man_MANS = ocf_heartbeat_AoEtarget.7 \ ocf_heartbeat_AudibleAlarm.7 \ ocf_heartbeat_ClusterMon.7 \ ocf_heartbeat_CTDB.7 \ ocf_heartbeat_Delay.7 \ ocf_heartbeat_Dummy.7 \ ocf_heartbeat_EvmsSCC.7 \ ocf_heartbeat_Evmsd.7 \ ocf_heartbeat_Filesystem.7 \ ocf_heartbeat_ICP.7 \ ocf_heartbeat_IPaddr.7 \ ocf_heartbeat_IPaddr2.7 \ ocf_heartbeat_IPsrcaddr.7 \ ocf_heartbeat_LVM.7 \ ocf_heartbeat_LinuxSCSI.7 \ ocf_heartbeat_MailTo.7 \ ocf_heartbeat_ManageRAID.7 \ ocf_heartbeat_ManageVE.7 \ ocf_heartbeat_Pure-FTPd.7 \ ocf_heartbeat_Raid1.7 \ ocf_heartbeat_Route.7 \ ocf_heartbeat_SAPDatabase.7 \ ocf_heartbeat_SAPInstance.7 \ ocf_heartbeat_SendArp.7 \ ocf_heartbeat_ServeRAID.7 \ ocf_heartbeat_SphinxSearchDaemon.7 \ ocf_heartbeat_Squid.7 \ ocf_heartbeat_Stateful.7 \ ocf_heartbeat_SysInfo.7 \ ocf_heartbeat_VIPArip.7 \ ocf_heartbeat_VirtualDomain.7 \ ocf_heartbeat_WAS.7 \ ocf_heartbeat_WAS6.7 \ ocf_heartbeat_WinPopup.7 \ ocf_heartbeat_Xen.7 \ ocf_heartbeat_Xinetd.7 \ ocf_heartbeat_anything.7 \ ocf_heartbeat_apache.7 \ ocf_heartbeat_conntrackd.7 \ ocf_heartbeat_db2.7 \ ocf_heartbeat_drbd.7 \ ocf_heartbeat_eDir88.7 \ ocf_heartbeat_ethmonitor.7 \ ocf_heartbeat_exportfs.7 \ ocf_heartbeat_fio.7 \ ocf_heartbeat_iSCSILogicalUnit.7 \ ocf_heartbeat_iSCSITarget.7 \ ocf_heartbeat_ids.7 \ ocf_heartbeat_iscsi.7 \ ocf_heartbeat_jboss.7 \ ocf_heartbeat_lxc.7 \ ocf_heartbeat_mysql.7 \ ocf_heartbeat_mysql-proxy.7 \ ocf_heartbeat_named.7 \ ocf_heartbeat_nfsserver.7 \ ocf_heartbeat_nginx.7 \ ocf_heartbeat_oracle.7 \ ocf_heartbeat_oralsnr.7 \ ocf_heartbeat_pgsql.7 \ ocf_heartbeat_pingd.7 \ ocf_heartbeat_portblock.7 \ ocf_heartbeat_postfix.7 \ ocf_heartbeat_proftpd.7 \ ocf_heartbeat_rsyncd.7 \ + ocf_heartbeat_rsyslog.7 \ ocf_heartbeat_scsi2reservation.7 \ ocf_heartbeat_sfex.7 \ ocf_heartbeat_slapd.7 \ ocf_heartbeat_symlink.7 \ ocf_heartbeat_syslog-ng.7 \ ocf_heartbeat_tomcat.7 \ ocf_heartbeat_vmware.7 if USE_IPV6ADDR man_MANS += ocf_heartbeat_IPv6addr.7 endif xmlfiles = $(man_MANS:.7=.xml) %.1 %.5 %.7 %.8: %.xml $(XSLTPROC) \ $(XSLTPROC_MANPAGES_OPTIONS) \ $(MANPAGES_STYLESHEET) $< ocf_heartbeat_%.xml: metadata-%.xml $(srcdir)/$(REFENTRY_STYLESHEET) $(XSLTPROC) --novalid \ --stringparam package $(PACKAGE_NAME) \ --stringparam version $(VERSION) \ --output $@ \ $(srcdir)/$(REFENTRY_STYLESHEET) $< ocf_resource_agents.xml: $(xmlfiles) mkappendix.sh ./mkappendix.sh $(xmlfiles) > $@ %.html: %.xml $(XSLTPROC) \ $(XSLTPROC_HTML_OPTIONS) \ --output $@ \ $(HTML_STYLESHEET) $< xml: ocf_resource_agents.xml endif diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am index f2ecf6fed..9a91de51d 100644 --- a/heartbeat/Makefile.am +++ b/heartbeat/Makefile.am @@ -1,125 +1,126 @@ # Makefile.am for OCF RAs # # Author: Sun Jing Dong # Copyright (C) 2004 IBM # # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = $(ocf_SCRIPTS) $(ocfcommon_DATA) \ $(common_DATA) $(hb_DATA) $(dtd_DATA) \ README INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/linux-ha ocfdir = $(OCF_RA_DIR_PREFIX)/heartbeat dtddir = $(datadir)/$(PACKAGE_NAME) dtd_DATA = ra-api-1.dtd if USE_IPV6ADDR ocf_PROGRAMS = IPv6addr else ocf_PROGRAMS = endif IPv6addr_SOURCES = IPv6addr.c IPv6addr_LDADD = -lplumb $(LIBNETLIBS) ocf_SCRIPTS = ClusterMon \ CTDB \ Dummy \ IPaddr \ IPaddr2 \ drbd \ anything \ AoEtarget \ apache \ nginx \ AudibleAlarm \ conntrackd \ db2 \ Delay \ eDir88 \ EvmsSCC \ Evmsd \ ethmonitor \ exportfs \ Filesystem \ fio \ ids \ iscsi \ ICP \ IPsrcaddr \ iSCSITarget \ iSCSILogicalUnit \ jboss \ LinuxSCSI \ LVM \ lxc \ MailTo \ ManageRAID \ ManageVE \ mysql \ mysql-proxy \ named \ nfsserver \ oracle \ oralsnr \ pingd \ portblock \ postfix \ pgsql \ proftpd \ Pure-FTPd \ Raid1 \ Route \ rsyncd \ + rsyslog \ SAPDatabase \ SAPInstance \ SendArp \ ServeRAID \ slapd \ SphinxSearchDaemon \ Squid \ Stateful \ SysInfo \ scsi2reservation \ sfex \ symlink \ syslog-ng \ tomcat \ VIPArip \ VirtualDomain \ vmware \ WAS \ WAS6 \ WinPopup \ Xen \ Xinetd ocfcommondir = $(OCF_LIB_DIR_PREFIX)/heartbeat ocfcommon_DATA = ocf-shellfuncs \ ocf-binaries \ ocf-directories \ ocf-returncodes \ apache-conf.sh \ http-mon.sh # Legacy locations hbdir = $(sysconfdir)/ha.d hb_DATA = shellfuncs diff --git a/heartbeat/rsyslog b/heartbeat/rsyslog new file mode 100755 index 000000000..0fde4bc89 --- /dev/null +++ b/heartbeat/rsyslog @@ -0,0 +1,238 @@ +#!/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 +# +############################################################################## +# 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 +# OCF_RESKEY_kill_term_timeout: Number of seconds to await to confirm a +# normal stop method +# +# 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 < + + +1.0 + + +This script manages a rsyslog instance as an HA resource. + +rsyslog resource agent + + + + + +This parameter specifies a configuration file +for a rsyslog instance managed by this RA. + +Configuration file + + + + + +This parameter specifies rsyslog's executable file. + +rsyslog executable + + + + + +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. + +Start options + + + + + + + + + + + + + + +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 + + ocf_run "$RSYSLOG_EXE" -f "$CONFIGFILE" $START_OPTS + 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 + +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