Date: Tue, 3 Jun 2008 15:22:08 GMT From: Piotr Rybicki <meritus@innervision.pl> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/124238: [ports: heartbeat] patch request Message-ID: <200806031522.m53FM8ba074923@www.freebsd.org> Resent-Message-ID: <200806031530.m53FU1D7067616@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 124238 >Category: ports >Synopsis: [ports: heartbeat] patch request >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Jun 03 15:30:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Piotr Rybicki >Release: 7.0-R1 >Organization: Innervision >Environment: I believe this is not needed >Description: #1 port sysutils/heartbeat has problem when trying to find an interface for ip address. To fetch this interface, following line is applied (shell script): $IFCONFIG | grep "$ipaddr" -B4 | grep "UP," | cut -d ":" -f 1 This usability is limited to one alias per interface (grep -B4). I provide here a patch which drops this limitation. #2 heartbeat lacks a proper 'resource' for starting/stopping rc.d scripts upon moving through the nodes. I provide here a script (BSDService) which allows this functionality. This file should be installed in /usr/local/etc/ha.d/resource.d Please update this port by adding my 2 patches. Best regards & have a good day! >How-To-Repeat: #1 - try using more than one IP alias as a cluster resource #2 - try to use rc.d service as a cluster resource (in an easy way) >Fix: #1 - patch # diff -u ~ryba/_ha_orig/IPaddr /usr/local/etc/ha.d/resource.d/IPaddr --- /home/ryba/_ha_orig/IPaddr 2008-06-03 13:48:41.000000000 +0200 +++ /usr/local/etc/ha.d/resource.d/IPaddr 2008-06-03 14:24:26.000000000 +0200 @@ -80,6 +80,28 @@ } # +# Find out which alias serves the given IP address +# The argument is an IP address, and its output +# is an aliased interface name (e.g., "eth0:0"). +# +find_interface_bsd() { + + ipaddr="$1"; + + for ifname in `$IFCONFIG -l` + do +# echo "IFNAME:$ifname" + $IFCONFIG $ifname | grep "inet.*[: ]$ipaddr " >/dev/null 2>&1 + if [ $? -eq 0 ] + then + echo $ifname + return 0 + fi + done + return 1 +} + +# # Find out which alias serves the given IP address # The argument is an IP address, and its output # is an aliased interface name (e.g., "eth0:0"). @@ -131,6 +153,9 @@ SunOS) IF=`find_interface_solaris $BASEIP` ;; + *BSD) + IF=`find_interface_bsd $BASEIP` + ;; *) IF=`find_interface_generic $BASEIP` ;; @@ -461,6 +486,9 @@ SunOS) j=1 ;; + *BSD) + j=1 + ;; *) j=0 TRYADRCNT=`ls "${NICBASE}:"* | wc -l | tr -d ' ' 2>/dev/null` #2) - BSDService resource file: # cat BSDService #!/bin/sh # # Created VI 2008 by Piotr Rybicki (meritus@innervision.pl) # # This script can be used do start/stop FreeBSD's # /usr/local/etc/rc.d/* services. # # One MUST NOT enable service (in /etc/rc.conf # there cannot be SERVICE_enable"YES" line) # # usage: $0 {start|stop|status} # # An example usage in /usr/local/etc/ha.d/haresources: # node1 10.0.0.170 BSDService::mysql-server # usage() { cat <<-! usage: $0 SERVICE {start|stop|status}"; ! exit 1 } . /usr/local/etc/ha.d/shellfuncs RCD=/usr/local/etc/rc.d #VARLIB=/var/lib/heartbeat #VLFILE=$VARLIB/rsctmp/Delay BSDService_Status() { if [ ! -f $RCD/$1 ] then echo "There is no $RCD/$1 script!. Fatal" fi $RCD/$1 onestatus 2>&1 1>/dev/null if [ $? -eq 0 ] then if [ $2 = 'verbose' ] then echo "Service $1 is running OK" fi return 0 else if [ $2 = 'verbose' ] then echo "Service $1 is NOT running" fi return 1 fi } BSDService_Start() { BSDService_Status $1 noverbose if [ $? -eq 0 ] then echo "Service $1 already running" return 0 else $RCD/$1 onestart return $? fi } BSDService_Stop() { BSDService_Status $1 noverbose if [ $? -eq 0 ] then $RCD/$1 onestop return $? else echo "Service $1 already stopped" return 0 fi } if [ $# -ne 2 ] then usage; exit 1; fi case $2 in start) BSDService_Start $1 ;; stop) BSDService_Stop $1 ;; status) BSDService_Status $1 verbose ;; *) usage exit 1;; esac exit $? >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806031522.m53FM8ba074923>