Created
March 19, 2012 02:55
-
-
Save whiteinge/2091989 to your computer and use it in GitHub Desktop.
Grab RAM usage, load, and Apache processes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# List stats helpful for tuning Apache | |
APIDS=$(pgrep apache | wc -l) | |
LOADAVG=$(< /proc/loadavg) | |
# hopefully the prefork section is the first match... | |
MAXCLIENT=$(grep -m 1 "^MaxClient" /etc/apache2/apache2.conf | cut -d' ' -f 2) | |
free -mt | awk ' | |
BEGIN { | |
OFS="\t" | |
} | |
# Get total RAM | |
/^Mem/ { total = $2 } | |
# Get used RAM | |
/^-/ { used = $3 } | |
END { | |
split(loadavg, load, " ") | |
# if ( --no-headers ) | |
# print "Num Apache Procs", "Used/Total Memory", "Load" | |
print apids "/" maxclient, " ", " ", used "/" total " KB", " ", load[1] " " load[2] " " load[3] | |
}' apids=$APIDS "loadavg=$LOADAVG" maxclient=$MAXCLIENT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Debian based:
APIDS=$(pgrep apache2 | wc -l)
MAXCLIENT=$(awk '/^[[:space:]]+MaxClients/ { print $2 }' /etc/apache2/apache2.conf)