You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-admin/collectd/files/collectd.initd

63 lines
1.5 KiB

#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
: ${COLLECTD_PIDFILE:='/var/run/collectd/collectd.pid'}
: ${COLLECTD_CFGFILE:='/etc/collectd.conf'}
: ${COLLECTD_NICELVL:='5'}
: ${COLLECTD_USER:='collectd'}
extra_commands="configtest"
depend() {
use net
}
configtest() {
ebegin "Checking ${SVCNAME} configuration"
checkconfig
eend $?
}
checkconfig() {
if [ $(sed '/^$\|^#/d' ${COLLECTD_CFGFILE} | grep -c 'LoadPlugin\w\+oracle') != 0 ] ; then
if [ -e /etc/env.d/50oracle-instantclient-basic ] ; then
. /etc/env.d/50oracle-instantclient-basic
export ORACLE_HOME
export TNS_ADMIN
else
ewarn "Unable to set Oracle environment, Oracle plugin wont work"
fi
fi
/usr/sbin/collectd -t -C "${COLLECTD_CFGFILE}" 1>/dev/null 2>&1
ret=$?
if [ $ret -ne 0 ]; then
eerror "${SVCNAME} has detected an error in your setup:"
/usr/sbin/collectd -t -C "${COLLECTD_CFGFILE}"
fi
return $ret
}
start() {
checkconfig || return 1
[ -d /var/run/collectd ] || mkdir /var/run/collectd && chown collectd:collectd /var/run/collectd
ebegin "Starting collectd"
start-stop-daemon --start --user "${COLLECTD_USER}:collectd" \
--env LC_NUMERIC=C \
--nicelevel "${COLLECTD_NICELVL}" --exec /usr/sbin/collectd -- \
-P "${COLLECTD_PIDFILE}" -C "${COLLECTD_CFGFILE}"
eend $? "Failed to start collectd"
}
stop() {
ebegin "Stopping collectd"
start-stop-daemon --stop \
--env LC_NUMERIC=C \
--pidfile "${COLLECTD_PIDFILE}"
eend $? "Failed to stop collectd"
}