-
Notifications
You must be signed in to change notification settings - Fork 2
/
status.sh
96 lines (81 loc) · 1.9 KB
/
status.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
echo '{'
echo '"channels" : ['
for i in {1..4}
do
for j in {3..4}
do
pid=$(ps -ef | grep c$i$j | awk '{print $1}')
[ -z "$pid" ] && pid=0
time=$(ps -eo etimes,args | grep c$i$j | grep -v grep | awk '{print $1}')
[ -z "$time" ] && time=0
online=$(netstat -an | grep 30$i$j''0 | wc -l)
[ -z "$online" ] && online=0
echo '
{
"name":"C'$i'-'$j'",
"pid":'$pid',
"time":'$time',
"online":'$online'
},'
done
done
pid=$(ps -ef | grep c991 | awk '{print $1}')
[ -z "$pid" ] && pid=0
time=$(ps -eo etimes,args | grep c991 | grep -v grep | awk '{print $1}')
[ -z "$time" ] && time=0
online=$(netstat -an | grep 30910 | wc -l)
[ -z "$online" ] && online=0
echo '
{
"name":"C99-1",
"pid":'$pid',
"time":'$time',
"online":'$online'
},'
pid=$(ps -ef | grep c992 | awk '{print $1}')
[ -z "$pid" ] && pid=0
time=$(ps -eo etimes,args | grep c992 | grep -v grep | awk '{print $1}')
[ -z "$time" ] && time=0
online=$(netstat -an | grep 30920 | wc -l)
[ -z "$online" ] && online=0
echo '
{
"name":"C99-2",
"pid":'$pid',
"time":'$time',
"online":'$online'
},'
pid=$(ps -ef | grep c993 | awk '{print $1}')
[ -z "$pid" ] && pid=0
time=$(ps -eo etimes,args | grep c993 | grep -v grep | awk '{print $1}')
[ -z "$time" ] && time=0
online=$(netstat -an | grep 30930 | wc -l)
[ -z "$online" ] && online=0
echo '
{
"name":"C99-3",
"pid":'$pid',
"time":'$time',
"online":'$online'
}'
echo '],'
dbpid=$(ps -ef | grep mt_db | awk '{print $1}')
[ -z "$dbpid" ] && dbpid=0
dbtime=$(ps -eo etimes,args | grep mt_db | grep -v grep | awk '{print $1}')
[ -z "$dbtime" ] && dbtime=0
echo '
"db" : {
"pid":'$dbpid',
"time":'$dbtime'
},'
authpid=$(ps -ef | grep mt_auth | awk '{print $1}')
[ -z "$authpid" ] && authpid=0
authtime=$(ps -eo etimes,args | grep mt_auth | grep -v grep | awk '{print $1}')
[ -z "$authtime" ] && authtime=0
echo '
"auth" : {
"pid":'$authpid',
"time":'$authtime'
}'
echo '}'