-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax_clients.sh
More file actions
executable file
·34 lines (30 loc) · 1.04 KB
/
max_clients.sh
File metadata and controls
executable file
·34 lines (30 loc) · 1.04 KB
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
#!/bin/bash
PROCNAME=httpd
PARENTPIDS=`comm -12 <(ps -C $PROCNAME -o ppid | sort -u) <(ps -C $PROCNAME -o pid | sort -u)`
for ParPID in $PARENTPIDS; do
SUM=0
COUNT=0
for x in `ps f --ppid $ParPID -o rss | tail -n +2`; do
SUM=$(( $SUM + $x ))
COUNT=$(( $COUNT + 1 ))
done
MEMPP=$(( $SUM / $COUNT / 1024 ))
FREERAM=$(( `free | tail -2 | head -1 | awk '{print $4}'` / 1024 ))
APACHERAM=$(( $SUM / 1024 ))
APACHEMAX=$(( $APACHERAM + $FREERAM ))
(
echo
echo "Info for the following parent apache process:"
echo " "`ps f --pid $ParPID -o command | tail -n +2`
echo
echo "Current # of apache processes: $COUNT"
echo "Average memory per apache process: $MEMPP MB"
echo "Free RAM (including cache & buffers): $FREERAM MB"
echo "RAM currently in use by apache: $APACHERAM MB"
echo "Max RAM available to apache: $APACHEMAX MB"
echo
echo "Theoretical maximum MaxClients: $(( $APACHEMAX / $MEMPP ))"
echo "Recommended MaxClients: $(( $APACHEMAX / 10 * 9 / $MEMPP ))"
echo
)
done