ports/119095: [PATCH] sysutils/ganglia-monitor-core: allow to run multiple gmond

Jui-Nan Lin jnlin at csie.nctu.edu.tw
Fri Dec 28 10:20:02 UTC 2007


>Number:         119095
>Category:       ports
>Synopsis:       [PATCH] sysutils/ganglia-monitor-core: allow to run multiple gmond
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 28 10:20:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Jui-Nan Lin
>Release:        FreeBSD 6.2-RELEASE-p9 i386
>Organization:
>Environment:
System: FreeBSD Florence.tamama.org 6.2-RELEASE-p9 FreeBSD 6.2-RELEASE-p9 #0: Fri Nov 30 03:13:43 CST 2007
>Description:

In our environment, we needed to gather data of multiple clusters in one node. 
Since a gmond reports only 1 cluster name to gmetad, we have to run multiple gmond instances.
I have modified the rc script to allow this feature. The old usage is also work correctly.

Port maintainer (brooks at FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.77
>How-To-Repeat:
>Fix:

--- ganglia-monitor-core-3.0.6_1.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/sysutils/ganglia-monitor-core/Makefile /home/jnlin/ports/ganglia-monitor-core/Makefile
--- /usr/ports/sysutils/ganglia-monitor-core/Makefile	Tue Dec 18 06:24:48 2007
+++ /home/jnlin/ports/ganglia-monitor-core/Makefile	Fri Dec 28 15:44:27 2007
@@ -7,6 +7,7 @@
 
 PORTNAME=	monitor-core
 PORTVERSION=	3.0.6
+PORTREVISION=	1
 CATEGORIES=	sysutils net parallel
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	ganglia
diff -ruN --exclude=CVS /usr/ports/sysutils/ganglia-monitor-core/files/gmond.sh.in /home/jnlin/ports/ganglia-monitor-core/files/gmond.sh.in
--- /usr/ports/sysutils/ganglia-monitor-core/files/gmond.sh.in	Fri Jul 14 05:52:02 2006
+++ /home/jnlin/ports/ganglia-monitor-core/files/gmond.sh.in	Fri Dec 28 15:44:26 2007
@@ -11,15 +11,107 @@
 name=gmond
 rcvar=`set_rcvar`
 command="%%PREFIX%%/sbin/${name}"
+start_cmd="gmond_start"
+stop_cmd="gmond_stop"
+
+# init_variables _j
+#       Initialize the various gmond variables for gmond _j.
+#
+init_variables()
+{
+	_j="$1"
+
+	if [ -z "$_j" ]; then
+		warn "init_variables: you must specify a gmond"
+		return
+	fi
+
+	eval _conf=\"\$gmond_${_j}_conf\"
+	if [ -z "$_conf" ]; then
+		_conf="%%PREFIX%%/etc/gmond.conf"
+	fi		
+}
+
+start_instance()
+{
+        if [ "0`check_pidfile ${pidfile} ${command}`" -gt 1 ]; then
+		echo -n " [${_gmond} already running (${pidfile} exists)]"
+                continue
+        fi
+	if [ ! -f $_conf ]; then
+		echo -n " [Cannot found ${_conf}]"
+                continue
+	fi	
+
+	echo -n " $_gmond"
+	${command} -c ${_conf} -p ${pidfile}
+}
+
+stop_instance()
+{
+      if [ -f $pidfile ]; then
+		pid=`cat $pidfile`
+		kill $pid	
+		rm $pidfile
+		echo -n " $_gmond"
+      fi
+}
+
+gmond_start()
+{
+	# For Backward Compatability
+	if [ -z "${gmond_list}" ]; then
+		_conf="$gmond_conf"
+		if [ -z "$_conf" ]; then
+			_conf="%%PREFIX%%/etc/gmond.conf"
+		fi		
+		echo -n 'Starting gmond'
+		_gmond=""
+		pidfile="/var/run/gmond.pid"
+		start_instance
+	else	
+		echo -n 'Starting gmonds:'
+		for _gmond in ${gmond_list}
+		do
+			init_variables $_gmond
+			pidfile="/var/run/gmond_${_gmond}.pid"	
+			start_instance	
+		done	
+	fi
+	echo '.'	
+}	
+
+gmond_stop()
+{
+	# For Backward Compatability
+	if [ -z "${gmond_list}" ]; then
+		echo -n 'Stopping gmond'
+		_gmond="."
+		pidfile="/var/run/gmond.pid"
+		stop_instance
+	else	
+		echo -n 'Stopping gmonds:'
+		for _gmond in ${gmond_list}
+		do
+			pidfile="/var/run/gmond_${_gmond}.pid"	
+			stop_instance	
+		done	
+	fi	
+	echo '.'	
+}	
+
 
 load_rc_config ganglia
 
 load_rc_config $name
+cmd="$1"
 
-gmond_enable=${gmond_enable-NO}
-gmond_conf=${gmond_conf-%%PREFIX%%/etc/gmond.conf}
+if [ $# -gt 0 ]; then
+	shift
+fi
 
-command_args="-c ${gmond_conf}"
-required_files=${gmond_conf}
+if [ -n "$*" ]; then
+	gmond_list="$*"
+fi
+run_rc_command "${cmd}"
 
-run_rc_command $*
--- ganglia-monitor-core-3.0.6_1.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list