Memory and load issues: Difference between revisions

From Cheatsheet
Jump to navigation Jump to search
No edit summary
m 2 revisions
 
(No difference)

Latest revision as of 23:51, 23 October 2014

Memory and load issues

Load per process checking

/usr/local/cpanel/bin/dcpumonview

Memory per user foo'ed up by mwineland

lwtmpvar=;for each in `ps aux | grep -v COMMAND | awk '{print $1}' | sort | uniq`; do lwtmpvar="$lwtmpvar\n`ps aux | egrep ^$each | awk 'BEGIN{total=0};{total += $4};END{print total, $1}'`"; done; echo -e $lwtmpvar | grep -v ^$ | sort -rn | head

Checking swaps memory usage

vmstat 1

If digging into swaps memory run this and see if there are any tables that are "[!!] Total fragmented tables" If it does show that there are fragmented tables, run an optimize on the tables.

wget mysqltuner.pl/mysqltuner.pl && perl mysqltuner.pl

Optimization script here

for i in $(mysql -e "show databases;" | sed 's/Database//') ; do for each in $(mysql -e "use $i; show tables;" \
| sed 's/Tables.*//' ;) ; do mysql -e "use $i ; optimize table $each" ; done ; done

Using Sar

this can be helpful in figuring out what the swaps are are or the iowait.

sar

This will display Collected, report, or save system activity information.

sar -r

This will show you the memory and swap space utilization statistics.
You can futher clean that up to show just mem used and swpused with the following.

sar -r | awk '{print $1,"\t"$2,"\t"$5,"\t\t"$10}'

You can also use sar to view previous days log files. Do the following.

cd /var/log/sa
ll

This should provide you with a list that looks like the following.

 
-rw-r--r--  1 root root 484640 Aug  1 15:51 sa01
-rw-r--r--  1 root root 484176 Aug  2 23:50 sa02
-rw-r--r--  1 root root 228576 Aug  3 11:00 sa03
-rw-r--r--  1 root root 490992 Jul 26 23:50 sa26
-rw-r--r--  1 root root 490992 Jul 27 23:50 sa27
-rw-r--r--  1 root root 490992 Jul 28 23:50 sa28
-rw-r--r--  1 root root 481232 Jul 29 23:50 sa29
-rw-r--r--  1 root root 490992 Jul 30 23:50 sa30
-rw-r--r--  1 root root 485104 Jul 31 15:37 sa31
-rw-r--r--  1 root root 491873 Aug  1 23:53 sar01
-rw-r--r--  1 root root 491907 Aug  2 23:53 sar02
-rw-r--r--  1 root root 498737 Jul 25 23:53 sar25
-rw-r--r--  1 root root 498737 Jul 26 23:53 sar26
-rw-r--r--  1 root root 498737 Jul 27 23:53 sar27
-rw-r--r--  1 root root 498737 Jul 28 23:53 sar28
-rw-r--r--  1 root root 489709 Jul 29 23:53 sar29
-rw-r--r--  1 root root 498737 Jul 30 23:53 sar30
-rw-r--r--  1 root root 493163 Jul 31 23:53 sar31

Each of those files is a log for that day of the month. Pick and choose then view them with the following command.

sar -f sa01

If you want to view different modes of the sar add the flags at the end of the command like so.

 sar -f sa01 -r

check the parent for oomage figure out the instance id

vzlist -a

place id here.

cat /var/log/messages | grep OOM.*ve\=(id goes here)

run this to see how many times this has happened in one day.

grep Aug\ 21.*OOM.*ve\=(id goes here) /var/log/messages | wc -l

To find script memory usage run the following lines

for each in `ls -A /var/cpanel/users | fgrep -v "."`; do grep -R memory_limit /home/$each/public_html/ >> /root/temp.txt; done
cat /root/temp.txt | grep ini_set

Listening on port

lsof -i :25

Load per process checking

/usr/local/cpanel/bin/dcpumonview

Total connections on port 80

netstat -nap |grep -c :80

rough per sec hits

/usr/bin/lynx -dump -width 500 http://127.0.0.1/whm-server-status | grep GET | awk '{print $12}' | sort | uniq -c | sort -rn | head

Tells how many are using port 80

netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head