-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathentrypoint.sh
executable file
·75 lines (55 loc) · 1.61 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
#!/usr/bin/env bash
set -e
clientSendInterval=${clientSendInterval:-10}
metricsPerSecond=${metricsPerSecond:-1000}
# this is the only one ENV that does not have defaults
carbonAddrs=${carbonAddrs}
connectTimeout=${connectTimeout:-2}
localBind=${localBind:-"localhost:3002"}
log=${log:-"-"}
metricDir=${metricDir:-"/tmp/grafsy/metrics"}
useACL=${useACL:-false}
retryDir=${retryDir:-"/tmp/grafsy/retry"}
sumPrefix=${sumPrefix:-"SUM."}
avgPrefix=${avgPrefix:-"AVG."}
minPrefix=${minPrefix:-"MIN."}
maxPrefix=${maxPrefix:-"MAX."}
aggrInterval=${aggrInterval:-60}
aggrPerSecond=${aggrPerSecond:-100}
monitoringPath=${monitoringPath:-"servers.HOSTNAME.software"}
allowedMetrics=${allowedMetrics:-'^((SUM|AVG|MIN|MAX)[.])?[-a-zA-Z0-9_]+[.][-a-zA-Z0-9_().:/,{}=+#]+(\\s)[-0-9[.]eE+]+(\\s)[0-9]{10}$'}
default_run() {
if [ -z "${carbonAddrs}" ]; then
echo "carbonAddrs must be set as space separated addresses"
exit 1
fi
if ! [ -e /etc/grafsy/grafsy.toml ]; then
cat > /etc/grafsy/grafsy.toml << EOF
clientSendInterval = $clientSendInterval
metricsPerSecond = $metricsPerSecond
carbonAddrs = [
$(sed 's/^/"/;s/$/"/;s/\s\+/", "/g' <<< "$carbonAddrs")
]
connectTimeout = $connectTimeout
localBind = "$localBind"
log = "$log"
metricDir = "$metricDir"
useACL = $useACL
retryDir = "$retryDir"
sumPrefix = "$sumPrefix"
avgPrefix = "$avgPrefix"
minPrefix = "$minPrefix"
maxPrefix = "$maxPrefix"
aggrInterval = $aggrInterval
aggrPerSecond = $aggrPerSecond
monitoringPath = "$monitoringPath"
allowedMetrics = "$allowedMetrics"
EOF
fi
exec "$@"
}
if [ "$*" = "/grafsy/grafsy" ]; then
default_run "$@"
else
exec "$@"
fi