[ start | index | login ]
start > knowledgebase > linux > misc > memory troubleshooting

memory troubleshooting

Created by brandon. Last edited by yves, one year and 85 days ago. Viewed 1,007 times. #3
[diff] [history] [edit] [rdf]
labels
attachments
To see how much memory you have used over time, first set up the RimuHosting memory monitor as described at >>http://rimuhosting.com/howto/memory.jsp

After it has run for some time, you can use this perl script to see how much memory your server has used over time, and it gives you a really simple look at how much you have used.

#!/usr/bin/perl

my $max_used = 0; my %memcounts; opendir(DH,".") || die "Unable to open current directory"; while(my $file = readdir(DH)) { if($file =~ m/memmon.txt/) { open(FILE, "<$file"); while($line = <FILE>) { if($line =~ m/buffers/cache: +([0-9]+) +([0-9]+)/) { $used = $1; $memcounts = $memcounts ? $memcounts + 1 : 1; $max_used = $used > $max_used ? $used : $max_used; } } } } print "Max memory used: $max_used\\n\\n";

for($i = 0; $i <= $max_used; $i++) { print "$i => ".$memcounts."\\n"; }

The output shows the number of times that the memmon.sh script hit each amount of memory. Note that this is just a really quick version to view memory utilization. There are much better tools for long-term monitoring of memory usage (and many other things), like MRTG, Cacti, Cricket, etc

请以发表评论身份登录
Powered by snipsnap.org Found a mistake in a howto? Let us know via an email to p.blikibugs at rimuhosting com.