-
Notifications
You must be signed in to change notification settings - Fork 5
/
create-pid-files.sh
70 lines (63 loc) · 1.39 KB
/
create-pid-files.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
#!/bin/bash
# Configurables
TMP="/tmp"
PIDF="/opt/jvm-monitor/pids"
# Non-Configurables
TEMP_OUT=$TMP/test-jps-output.txt
# Querying plattform
. /opt/jvm-monitor/./get-platform.sh
# Getting running jvms
if [[ $platform == 'sunos' ]]; then
/opt/local/bin/sudo /opt/local/java/openjdk7/bin/jps -v > $TEMP_OUT
else
sudo -H -u wildfly bash -c "/usr/local/bin/jps -v" > $TEMP_OUT
fi
cat $TEMP_OUT
# Parsing process strings into array
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
#/opt/local/java/openjdk7/bin/jstat -gc -t $i
JPIDS=($(<$TEMP_OUT))
rm -f $TEMP_OUT
IFS=$SAFEIFS
# Storing respective jvm process ids in the respective variable
for i in "${JPIDS[@]}"
do
TMP=$(echo $i | grep "Process Controller" | cut -d " " -f 1)
if [ -n "$TMP" ]
then
JPPID=$TMP
fi
TMP=$(echo $i | grep "Host Controller" | cut -d " " -f 1)
if [ -n "$TMP" ]
then
JHPID=$TMP
fi
TMP=$(echo $i | grep "slave" | grep "100" | cut -d " " -f 1)
if [ -n "$TMP" ]
then
JSPID1=$TMP
fi
TMP=$(echo $i | grep "slave" | grep "200" | cut -d " " -f 1)
if [ -n "$TMP" ]
then
JSPID2=$TMP
fi
done
# Storing variables to files
if [ -n "$JPPID" ]
then
echo "$JPPID" > "$PIDF/process-controller.pid"
fi
if [ -n "$JHPID" ]
then
echo "$JHPID" > "$PIDF/host-controller.pid"
fi
if [ -n "$JSPID1" ]
then
echo "$JSPID1" > "$PIDF/slave-100.pid"
fi
if [ -n "$JSPID2" ]
then
echo "$JSPID2" > "$PIDF/slave-200.pid"
fi