-
Notifications
You must be signed in to change notification settings - Fork 51
/
monitor-nginx.sh
51 lines (47 loc) · 1.04 KB
/
monitor-nginx.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
#!/bin/bash
function active {
curl -s "http://127.0.0.1:8080/nginxstatus" | grep 'Active' | awk '{print $3}'
}
function reading {
curl -s "http://127.0.0.1:8080/nginxstatus" | grep 'Reading' | awk '{print $2}'
}
function writing {
curl -s "http://127.0.0.1:8080/nginxstatus" | grep 'Writing' | awk '{print $4}'
}
function waiting {
curl -s "http://127.0.0.1:8080/nginxstatus" | grep 'Waiting' | awk '{print $6}'
}
function accepts {
curl -s "http://127.0.0.1:8080/nginxstatus" | awk NR==3 | awk '{print $1}'
}
function handled {
curl -s "http://127.0.0.1:8080/nginxstatus" | awk NR==3 | awk '{print $2}'
}
function requests {
curl -s "http://127.0.0.1:8080/nginxstatus" | awk NR==3 | awk '{print $3}'
}
case "$1" in
active)
active
;;
reading)
reading
;;
writing)
writing
;;
waiting)
waiting
;;
accepts)
accepts
;;
handled)
handled
;;
requests)
requests
;;
*)
echo "Usage: $0 {active|reading|writing|waiting|accepts|handled|requests}"
esac