Memory and load issues

From Cheatsheet
Revision as of 09:48, 13 December 2010 by Admin (talk | contribs) (Created page with ' <h1><center>Memory and load issues</center></h1> '''Load per process checking''' <pre>/usr/local/cpanel/bin/dcpumonview</pre> '''Memory per user''' foo'ed up by mwinelan…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

mbstring

Check if it is installed with the following

php -i | grep --color mbstring

if that come back with this it is installed but not enabled:

mbstring
mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.
mbstring.detect_order => no value => no value
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 0 => 0
mbstring.http_input => pass => pass
mbstring.http_output => pass => pass
mbstring.internal_encoding => no value => no value
mbstring.language => neutral => neutral
mbstring.strict_detection => Off => Off
mbstring.substitute_character => no value => no value

Go into the php.ini and un-comment these lines.

vim /usr/local/lib/php.ini

and un-comment these lines.

extension=php_mbstring.dll
extension=php_mcrypt.dll

Then

/etc/init.d/httpd stop
/etc/init.d/httpd startssl