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.
62 lines
1.6 KiB
62 lines
1.6 KiB
13 years ago
|
#!/sbin/runscript
|
||
|
# Copyright 1999-2011 Gentoo Foundation
|
||
|
# Distributed under the terms of the GNU General Public License v2
|
||
|
# $Header: /var/cvsroot/gentoo-x86/app-admin/collectd/files/collectd.initd,v 1.5 2011/08/25 21:02:37 dilfridge Exp $
|
||
|
|
||
|
: ${COLLECTD_PIDFILE:='/var/run/collectd/collectd.pid'}
|
||
|
: ${COLLECTD_CFGFILE:='/etc/collectd.conf'}
|
||
|
: ${COLLECTD_NICELVL:='5'}
|
||
|
: ${COLLECTD_USER:='collectd'}
|
||
|
|
||
|
opts="${opts} 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
|
||
|
source /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" \
|
||
|
--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 \
|
||
|
--pidfile "${COLLECTD_PIDFILE}"
|
||
|
eend $? "Failed to stop collectd"
|
||
|
}
|
||
|
|