-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathwatcher.sh
More file actions
executable file
·31 lines (29 loc) · 878 Bytes
/
watcher.sh
File metadata and controls
executable file
·31 lines (29 loc) · 878 Bytes
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
#!/usr/bin/bash
echo Waiting for $1 seconds to finish...
sleep $1
mapfile -t jvm_pids < <(jps -q)
for pid in "${jvm_pids[@]}"
do
echo Checking process $pid
info=$(jinfo $pid);
if [[ "$info" =~ "idea.config.path" ]]; then
echo Found stuck process $pid
echo Writing jinfo.txt
jinfo $pid > jinfo.txt
jinfo $pid
echo Writing jstack.txt
jstack -l -e $pid >jstack.txt
jstack -l -e $pid
echo Writing snapshot.hprof
jmap -dump:format=b,file=snapshot.hprof $pid
echo KILLING HANGED PROCESS $pid
kill -9 $pid
# Wait briefly and verify termination
sleep 1
if kill -0 $pid 2>/dev/null; then
echo "Process $pid still alive after SIGKILL, this shouldn't happen"
# Log this unusual situation for investigation
ps -p $pid -o pid,ppid,user,stat,pcpu,comm
fi
fi
done