Showing posts with label technical notes. Show all posts
Showing posts with label technical notes. Show all posts

20090422

snippets used to research low disk space

Simple snippets useful for troubleshooting low disk space.

Using 'du' against a directory and single filesystem and sorting i
du -hxc --max-depth=1 / | sort -n

Find command that displays the 10 largest files within the defined directory
find /tmp -mount -type f -ls | sort -k 7 -r -n | head -10

snippets used to identify cause of high CPU usage

Snippets useful for investigating high CPU usage

Top 10 CPU consuming processes
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

Identify device encountering IO wait (x is optional and will display more details)
iostat -x 5

Identify processes encountering IO wait (and usually causing the IO)
ps -eo pid,stat,args,wchan | grep ' D'

And of course the awesome tool of 'sar' that is provided within the 'sysstat' package.

simple snippets to identify memory usage

Simple snippets to identify general memory usage.

Show top 10 memory consuming processes
ps xuaw --sort -rss | head

Display general memory summary
free -m

Display detailed memory breakdown
cat /proc/meminfo

simple mysql health check page

Simple? Yes. Useful? Yes.

Although the below is very simple it can be a very useful and effective way to regularly check apache functionality and its ability to communicate with mysql.

<html>
<head>
<title>Test mysql communications</title>
</head>
<body>
<!--test-->
<?php
$dbhost = 'localhost:3306';
$dbuser = 'trunty';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn)
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($conn);
?>
</body>
</html>

A URL that this can be seen in action is http://dev.linuxismybff.com/test/mysql/mysqltestconnect.php