freebsd-ports/sysutils/ganglia-monitor-core/files/ganglia.sh.in
Brooks Davis 2a56fd9001 - Upgrade to 3.0.3 eliminating the need for the cpufreq patch and fixing
some bugs.
- Spell REQUIRE correctly in ganglia.sh.in
- For systems where rcorder is run on LOCALBASE/etc/rc.d, split
  ganglia.sh into gmond.sh and gmetad.sh.
- Replace the patches changing user nobody to ganglia with REINPLACE_CMD
  in post-patch removing a maintance issue and decreasing the file
  count.  Also, expand the scope to include gmond.conf's documentation
  which was missed missed previously.
2006-07-13 21:52:02 +00:00

85 lines
1.8 KiB
Bash

#!/bin/sh
# $FreeBSD$
# PROVIDE: ganglia
# REQUIRE: DAEMON
# KEYWORD: shutdown
# XXX: This should really be two seperate scripts with rcorder
# dependencies, but we can't do that at the moment and gmetad doesn't
# work without a running gmond.
gmond_enable="${gmond_enable-NO}"
gmond_conf="%%PREFIX%%/etc/gmond.conf"
gmetad_enable="${gmetad_enable-NO}"
gmetad_conf="%%PREFIX%%/etc/gmetad.conf"
gmetasnap_enable="${gmetasnap_enable-NO}"
gmetasnap_rrddir="/var/db/ganglia/rrds"
gmetasnap_snapdir="/var/db/ganglia/snaps"
gmetasnap_snapname="snap"
gmetasnap_flags=""
gmetasnap_command="%%PREFIX%%/sbin/gmetasnap"
### gmond ###
. %%RC_SUBR%%
name=gmond
rcvar=`set_rcvar`
command="%%PREFIX%%/sbin/${name}"
load_rc_config ganglia
load_rc_config $name
command_args="-c ${gmond_conf}"
required_files=${gmond_conf}
run_rc_command $*
### gmetad ###
# Don't continue if we didn't run gmond
if ! checkyesno ${rcvar}; then
return 0
fi
name=gmetad
rcvar=`set_rcvar`
command="%%PREFIX%%/sbin/${name}"
start_precmd="gmetad_prestart"
stop_postcmd="gmetad_poststop"
gmetad_prestart()
{
if [ ! -d ${gmetasnap_rrddir} ]; then
mkdir -p ${gmetasnap_rrddir}
fi
chown ganglia:ganglia ${gmetasnap_rrddir}
if checkyesno gmetasnap_enable; then
if [ ! -d ${gmetasnap_snapdir} ]; then
mkdir -p ${gmetasnap_snapdir}
chown ganglia:ganglia ${gmetasnap_snapdir}
fi
if [ `ls ${gmetasnap_rrddir} | egrep -v ^.snap | wc -l` -eq 0 ]; then
${gmetasnap_command} -r ${gmetasnap_rrddir} \
-s ${gmetasnap_snapdir} ${gmetasnap_flags} \
restore ${gmetasnap_snapname}
fi
fi
}
gmetad_poststop()
{
if checkyesno gmetasnap_enable; then
${gmetasnap_command} -r ${gmetasnap_rrddir} \
-s ${gmetasnap_snapdir} ${gmetasnap_flags} \
save ${gmetasnap_snapname}
fi
}
load_rc_config $name
command_args="-c ${gmetad_conf}"
required_files=${gmetad_conf}
run_rc_command $*