-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathentrypoint.sh
56 lines (45 loc) · 1.33 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
#!/bin/bash
trap signal EXIT
trap signal SIGINT
function signal()
{
echo "Exited due to signal recieved."
exit
}
function main()
{
echo "Found hostname:"
echo $(/usr/bin/hostname)
echo "Checking collectl version:"
/usr/bin/collectl -v
echo "Current configuration:"
CONFIG=$(egrep -v "\#|^$" /etc/collectl.conf)
echo "$CONFIG"
echo "Ensuring /var/log/collectl exists..."
if [ ! -d /var/log/collectl ]
then
mkdir /var/log/collectl
fi
echo "Checking if collectl is already running on this node..."
PID=$(pgrep -f '/usr/bin/perl -w /usr/bin/collectl')
if [ ! -z "$PID" ]
then
echo "Host process $PID is already running collectl, exiting."
exit
fi
echo "Starting collectl process..."
/usr/bin/collectl -D /etc/collectl.conf
PID=$(pgrep -f '/usr/bin/perl -w /usr/bin/collectl')
echo "Monitoring PID $PID for exit..."
while true
do
PID=$(pgrep -f '/usr/bin/perl -w /usr/bin/collectl')
if [ $? -ne 0 ]
then
echo "Could no longer find PID $PID, exiting..."
exit
fi
sleep 10
done
}
main