forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 15
/
entrypoint.sh
executable file
·127 lines (111 loc) · 3.32 KB
/
entrypoint.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash -e
# edas same as kubernetes
if [[ $DICE_CLUSTER_TYPE == 'edas' ]]; then
export DICE_CLUSTER_TYPE="kubernetes"
# 兼容: 启用metaserver插件
export ENABLE_PLUGIN_METASERVER="true"
fi
# set CONFIG_DIR
if [ $DICE_CLUSTER_TYPE == 'kubernetes' ]; then
export CONFIG_DIR=k8s
else
export CONFIG_DIR=$DICE_CLUSTER_TYPE
fi
if [ ! $CONFIG_DIR ]; then
export CONFIG_DIR=dcos
# 兼容: 启用metaserver插件
export ENABLE_PLUGIN_METASERVER="true"
fi
# set CLUSTER_TYPE
if [ $DICE_CLUSTER_TYPE == 'kubernetes' ]; then
export CLUSTER_TYPE="k8s"
else
export CLUSTER_TYPE=$DICE_CLUSTER_TYPE
fi
if [ ! $CLUSTER_TYPE ]; then
CLUSTER_TYPE=dcos
fi
# set IS_K8S
if [[ $CLUSTER_TYPE == 'k8s' ]]; then
export IS_K8S="true"
else
export IS_K8S="false"
fi
# 调度器那边需要兼容k8s的处理, addon拉起的 telegraf 需要走调度器
if [[ $IS_K8S == 'true' ]]; then
HOST_NUM=${HOSTNAME##*-}
for line in $(env)
do
if [[ "$line" =~ ^N${HOST_NUM}\_.+=.+ ]]; then
key=${line%%=*}
value=${line#*=}
newkey=${key#*_}
export ${newkey}=${value}
echo "$key -> $newkey = $value"
fi
done
fi
# default env
if [ ! $DICE_COMPONENT ]; then
export DICE_COMPONENT="spot/telegraf"
fi
if [ -d "/rootfs/etc" ]; then
if [ ! $HOST_ETC ]; then
export HOST_ETC="/rootfs/etc"
fi
fi
if [ -f "/rootfs/etc/cluster-node" ]; then
if [ ! $CLUSTER_PATH ]; then
export CLUSTER_PATH="/rootfs/etc/cluster-node"
fi
fi
if [ -d "/rootfs/sys" ]; then
if [ ! $HOST_SYS ]; then
export HOST_SYS="/rootfs/sys"
fi
fi
if [ -d "/rootfs/proc" ]; then
if [ ! $HOST_PROC ]; then
export HOST_PROC="/rootfs/proc"
fi
fi
if [ -d "/rootfs" ]; then
if [ ! $HOST_MOUNT_PREFIX ]; then
export HOST_MOUNT_PREFIX="/rootfs"
fi
fi
if [ ! $MAIN_PID ]; then
export MAIN_PID="1"
fi
if [ ! $TELEGRAF_CONFIG ]; then
export TELEGRAF_CONFIG=telegraf
fi
TELEGRAF_OPTS=
if [[ $DICE_IS_EDGE == 'true' ]]; then
if [ -f "conf/${CONFIG_DIR}/${TELEGRAF_CONFIG}.conf" ]; then
TELEGRAF_OPTS="--config-directory conf/${CONFIG_DIR}/${TELEGRAF_CONFIG}.conf"
fi
else
if [ -f "conf/${CONFIG_DIR}/${TELEGRAF_CONFIG}-mc.conf" ]; then
TELEGRAF_OPTS="--config-directory conf/${CONFIG_DIR}/${TELEGRAF_CONFIG}-mc.conf"
elif [ -f "conf/${CONFIG_DIR}/${TELEGRAF_CONFIG}.conf" ]; then
TELEGRAF_OPTS="--config-directory conf/${CONFIG_DIR}/${TELEGRAF_CONFIG}.conf"
fi
fi
if [ $TELEGRAF_PPROF_PORT ]; then
TELEGRAF_PPROF_ADDR="--pprof-addr 0.0.0.0:${TELEGRAF_PPROF_PORT}"
fi
# run
if [[ $TELEGRAF_STATIC_CONF != '' ]]; then
./telegraf --config $TELEGRAF_STATIC_CONF $@
elif [[ $TELEGRAF_CONFIG_PATH != '' ]]; then
./telegraf $TELEGRAF_PPROF_ADDR --config $TELEGRAF_CONFIG_PATH $@
elif [[ $TELEGRAF_CONFIG != '' ]]; then
echo "./telegraf --config conf/${TELEGRAF_CONFIG}.conf ${TELEGRAF_OPTS} $@"
./telegraf $TELEGRAF_PPROF_ADDR --config conf/${TELEGRAF_CONFIG}.conf ${TELEGRAF_OPTS} $@
elif [[ $ADDON_TYPE != '' ]]; then
./telegraf $TELEGRAF_PPROF_ADDR --config conf/addon/${ADDON_TYPE}.conf $@
else
echo "./telegraf $TELEGRAF_PPROF_ADDR --config conf/telegraf.conf ${TELEGRAF_OPTS} $@"
./telegraf $TELEGRAF_PPROF_ADDR --config conf/telegraf.conf ${TELEGRAF_OPTS} $@
fi