<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>information &#8211; Everything is Broken</title>
	<atom:link href="https://play.datalude.com/blog/tag/information/feed/" rel="self" type="application/rss+xml" />
	<link>https://play.datalude.com/blog</link>
	<description>Efficiency vs. Inefficiency, in a no-holds barred fight.</description>
	<lastBuildDate>Sat, 20 Dec 2008 05:40:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Linux Memory Usage Summary Script</title>
		<link>https://play.datalude.com/blog/2008/11/linux-memory-usage-summary-script/</link>
					<comments>https://play.datalude.com/blog/2008/11/linux-memory-usage-summary-script/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 20 Nov 2008 07:21:46 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[report troubleshooting]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">http://play.datalude.com/blog/?p=110</guid>

					<description><![CDATA[I was having trouble with a webserver this week, which I'd just set up for a client. When it went live, it seemed OK initially, but when we left it overnight it curled up its toes and died. It was so dead that I couldn't even ssh in to reboot it, so we had to ... <a title="Linux Memory Usage Summary Script" class="read-more" href="https://play.datalude.com/blog/2008/11/linux-memory-usage-summary-script/" aria-label="Read more about Linux Memory Usage Summary Script">Read more</a>]]></description>
										<content:encoded><![CDATA[<p>I was having trouble with a webserver this week, which I'd just set up for a client. When it went live, it seemed OK initially, but when we left it overnight it curled up its toes and died. It was so dead that I couldn't even ssh in to reboot it, so we had to do a remote reboot. Crunch.</p>
<p>Anyway, on getting it back up, I poked around in the logs and found that it was running out of memory, which it really shouldn't do given that it was a fairly low load on the webserver, and only apache, mysql and php were running on it. I looked around the Interwebs and found an excellent resource called <a href="http://rimuhosting.com/howto/memory.jsp" target="_blank">Troubleshooting Memory Usage</a>, which gave me some pointers about how to rein in apache and stop it from eating up memory so quickly. Thanks!</p>
<p>Anyway on the page was a script for summarising memory usage, which I thought was a good idea, so i grabbed that one and adapted it to my own purposes. I thought I'd make the results available here, so feel free to grab it and adapt it to your own needs.<span id="more-110"></span></p>
<pre>#!/bin/bash
# Mem-info.sh. Version 1.5 2008-12-20
# Adapted from various sources around the Internet.
# Requires mutt to be installed to use the email function. 

#################### Functions ####################
function print_help {
	echo "  Usage:"
	echo "    $0 [-a full|summary] -f /tmp/memoryreport.txt"
	echo "    Parameters:"
	echo "    -a              Specify full or summary report"
	echo "    -f              Specify alternate filename "
	echo "    -e &lt;adddr&gt;      Send report to specified email address"             
	echo "    -h | --help     This usage information"
	echo "    Running the script with no parameters writes a summary report to ./output.txt"
}

function summary_report {
	echo "=========================== SUMMARY ============================" &gt; $mem_outputfile
	date &gt;&gt; $mem_outputfile
	echo  &gt;&gt; $mem_outputfile
	echo "=========================== uptime ==============================" &gt;&gt; $mem_outputfile
	uptime &gt;&gt; $mem_outputfile
	echo  &gt;&gt; $mem_outputfile
	echo "========================== free -m ==============================" &gt;&gt; $mem_outputfile
	free -m &gt;&gt; $mem_outputfile
	echo  &gt;&gt; $mem_outputfile
	echo "========================= vmstat 1.5 ============================" &gt;&gt; $mem_outputfile
	vmstat 1 5 &gt;&gt; $mem_outputfile
	echo  &gt;&gt; $mem_outputfile
	echo "================== ps top 20 Processes by CPU ===================" &gt;&gt; $mem_outputfile
	ps -eo user,%mem,%cpu,pid,cmd --sort -%cpu | head -n 20 &gt;&gt; $mem_outputfile
	echo  &gt;&gt; $mem_outputfile

}

function full_report {
	summary_report
	echo "========================= FULL DETAIL ===========================" &gt;&gt; $mem_outputfile
	echo "======================== top raw output =========================" &gt;&gt; $mem_outputfile
	top -b -n 1 &gt;&gt; $mem_outputfile
	echo " " &gt;&gt; $mem_outputfile
	echo "======================= ps auxf raw output ======================" &gt;&gt; $mem_outputfile
	ps auxf --width=200 &gt;&gt; $mem_outputfile
	echo  &gt;&gt; $mem_outputfile
	echo "=========================== end ================================ " &gt;&gt; $mem_outputfile
	echo  &gt;&gt; $mem_outputfile
	echo  &gt;&gt; $mem_outputfile
}

#################### Process Command line ####################

while [ "$1" != "" ]; do
    case $1 in
        -f )           	shift
                                mem_outputfile=$1
                                ;;
        -a )    	shift
				mem_action=$1
                                ;;
        -e )            shift
				email_to=$1
				;;
        -h | --help )           print_help
                                exit
                                ;;
        * )                     print_help
                                exit
				;;
    esac
    shift
done

######################### Set Defaults #########################
if [ -z "${mem_action}" ]; then 
    echo "    No action Specified. Defaulting to summary report"
    mem_action="summary"
fi
if [ -z "${mem_outputfile}" ]; then 
    echo "    No output file specified. Writing to `pwd`/output.txt"
    mem_outputfile="output.txt"
fi

######################### Do Stuff #########################

if [ "$mem_action" = "full" ]; then
		full_report
	else
		summary_report
fi

if [ "$email_to" = "" ]; then
		echo "    No email address specified. Not emailing report."
	else
		mutt -s "Memory Usage Report" $email_to &lt; $mem_outputfile
fi</pre>
<p>Or you can download the file <a href="http://play.datalude.com/blog/wp-content/uploads/2008/11/mem-info1.sh">mem-info1 </a> if the formatting above is all messed up. Make sure you go to the page I linked to above for excellent advice on interpreting the report.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2008/11/linux-memory-usage-summary-script/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
