-
Notifications
You must be signed in to change notification settings - Fork 1
/
show-server
51 lines (36 loc) · 896 Bytes
/
show-server
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
#!/bin/bash
# Version 0.1
# Author: Norman Carver
# Script which will display any server processes with the name server.
#
# Usage: show-server
if [[ $# != 0 ]]; then
echo "Usage show-server"
exit 1
fi
function get_descendents()
{
local descendents=
for pid in $(pgrep -P "$1"); do
descendents="$descendents $pid"
pid_descendents=$(get_descendents $pid)
if [[ -n "$pid_descendents" ]]; then
descendents="$descendents $pid_descendents"
fi
done
echo $descendents
}
server=$(ps -C server -o pid= | head -n1)
if [[ -z $server ]]; then
echo "No server process!"
exit 1
fi
descendents=$(get_descendents $server)
echo "Server processes and threads:"
ps -L -o pid,tid,ppid,stat,comm $server $descendents
echo
for p in $server $descendents; do
/usr/bin/lsof -a -R -d '^cwd,^txt,^mem,^rtd' -p $p
done
exit
#EOF