blob: 6028c93f5efdd36f9ad6974b7c0fffab695f823f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/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.4 2011/04/24 17:10:05 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 -c "${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"
}
|