<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.jamesdooley.us/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=10.30.6.195</id>
		<title>James Dooley's Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.jamesdooley.us/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=10.30.6.195"/>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Special:Contributions/10.30.6.195"/>
		<updated>2026-04-11T02:38:13Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.28.0</generator>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Disk_Speed_Test&amp;diff=114</id>
		<title>Disk Speed Test</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Disk_Speed_Test&amp;diff=114"/>
				<updated>2011-06-14T19:13:55Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Runs hdparm -t, seeker and Nates dd script.&lt;br /&gt;
&lt;br /&gt;
By default each test is run 3 times to get a good running average. &lt;br /&gt;
&lt;br /&gt;
Outputs are cleaned up to provide usable information&lt;br /&gt;
&lt;br /&gt;
For Nates dd test you will need to have the drive mounted and listed in fstab&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[javascript,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
testpath=`grep $1 /etc/fstab | awk '{print $2}'`&lt;br /&gt;
testcount=3&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing hdparm -t $1&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	hdparm -t $1 | grep &amp;quot;Timing&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing seeker $1&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	seeker $1 | grep &amp;quot;Results&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing DD pv&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	sync&lt;br /&gt;
	echo &amp;quot;Write Test&amp;quot;&lt;br /&gt;
	dd if=/dev/zero bs=1M count=2048 2&amp;gt;/dev/null | pv | dd of=$testpath/ddfile 2&amp;gt;&amp;amp;1 | grep copied&lt;br /&gt;
&lt;br /&gt;
	sync&lt;br /&gt;
	echo &amp;quot;Read Test&amp;quot;&lt;br /&gt;
	cat $testpath/ddfile | pv &amp;gt; /dev/null&lt;br /&gt;
&lt;br /&gt;
	rm -f $testpath/ddfile&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
sh hdtest &amp;lt;drive path&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
testcount This should be set to the number of times you want this test to run.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Disk_Speed_Test&amp;diff=113</id>
		<title>Disk Speed Test</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Disk_Speed_Test&amp;diff=113"/>
				<updated>2011-06-14T19:02:31Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Runs hdparm -t, seeker and Nates dd script.&lt;br /&gt;
&lt;br /&gt;
By default each test is run 3 times to get a good running average. &lt;br /&gt;
&lt;br /&gt;
Outputs are cleaned up to provide usable information&lt;br /&gt;
&lt;br /&gt;
For Nates dd test you will need to have the drive mounted and listed in fstab&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[javascript,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
testpath=`grep $1 /etc/fstab | awk '{print $2}'`&lt;br /&gt;
testcount=3&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing hdparm -t $1&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	hdparm -t $1 | grep &amp;quot;Timing&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing seeker $1&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	seeker $1 | grep &amp;quot;Results&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing DD pv&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	sync&lt;br /&gt;
	echo &amp;quot;Write Test&amp;quot;&lt;br /&gt;
	dd if=/dev/zero bs=1M count=2048 2&amp;gt;/dev/null | pv | dd of=$testpath/ddfile 2&amp;gt;/dev/null | awk '{print $1&amp;quot; &amp;quot;$2&amp;quot; &amp;quot;$3}'&lt;br /&gt;
&lt;br /&gt;
	sync&lt;br /&gt;
	echo &amp;quot;Read Test&amp;quot;&lt;br /&gt;
	cat $testpath/ddfile | pv &amp;gt; /dev/null | awk '{print $1&amp;quot; &amp;quot;$2&amp;quot; &amp;quot;$3}'&lt;br /&gt;
&lt;br /&gt;
	rm -f $testpath/ddfile&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
sh hdtest &amp;lt;drive path&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
testcount This should be set to the number of times you want this test to run.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Disk_Speed_Test&amp;diff=112</id>
		<title>Disk Speed Test</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Disk_Speed_Test&amp;diff=112"/>
				<updated>2011-06-14T18:57:00Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: Created page with &amp;quot;==Overview==  Runs hdparm -t, seeker and Nates dd script.  By default each test is run 3 times to get a good running average.   Outputs are cleaned up to provide usable informati...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Runs hdparm -t, seeker and Nates dd script.&lt;br /&gt;
&lt;br /&gt;
By default each test is run 3 times to get a good running average. &lt;br /&gt;
&lt;br /&gt;
Outputs are cleaned up to provide usable information&lt;br /&gt;
&lt;br /&gt;
For Nates dd test you will need to have the drive mounted and listed in fstab&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[javascript,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
testpath=`grep $1 /etc/fstab | awk '{print $2}'`&lt;br /&gt;
testcount=3&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing hdparm -t $1&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	hdparm -t $1 | grep &amp;quot;Timing&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing seeker $1&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	seeker $1 | grep &amp;quot;Results&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Testing DD pv&amp;quot;&lt;br /&gt;
for i in `seq 1 $testcount`;&lt;br /&gt;
do&lt;br /&gt;
	sync&lt;br /&gt;
	echo &amp;quot;Write Test&amp;quot;&lt;br /&gt;
	dd if=/dev/zero bs=1M count=2048 2&amp;gt;/dev/null | pv | dd of=$testpath/ddfile 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
	sync&lt;br /&gt;
	echo &amp;quot;Read Test&amp;quot;&lt;br /&gt;
	cat $testpath/ddfile | pv &amp;gt; /dev/null&lt;br /&gt;
&lt;br /&gt;
	rm -f $testpath/ddfile&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
==Usage==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
sh hdtest &amp;lt;drive path&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
testcount This should be set to the number of times you want this test to run.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=111</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=111"/>
				<updated>2011-06-14T18:53:21Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Programs (more then one line) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Knowledge==&lt;br /&gt;
[[Monitorix Install cPanel]]&lt;br /&gt;
&lt;br /&gt;
[[Find and Replace in SQL database]]&lt;br /&gt;
&lt;br /&gt;
==Scripts (one liners)==&lt;br /&gt;
[[Add PHP.ini to user directory]]&lt;br /&gt;
&lt;br /&gt;
[[DOS IP with local port]]&lt;br /&gt;
&lt;br /&gt;
[[Find all backups for user]]&lt;br /&gt;
&lt;br /&gt;
[[Get status of MalDet hits]]&lt;br /&gt;
&lt;br /&gt;
[[View Domlogs for top visitors]]&lt;br /&gt;
&lt;br /&gt;
[[Hacker Term Search]]&lt;br /&gt;
&lt;br /&gt;
==Programs (more then one line)==&lt;br /&gt;
[[SwapClean]]&lt;br /&gt;
&lt;br /&gt;
[[errornotify]]&lt;br /&gt;
&lt;br /&gt;
[[ministat]]&lt;br /&gt;
&lt;br /&gt;
[[Disk Speed Test]]&lt;br /&gt;
&lt;br /&gt;
==Greasy Monkey (GreaseMonkey Scripts)==&lt;br /&gt;
[[HD Button Remove]]&lt;br /&gt;
&lt;br /&gt;
[[Not So Important]]&lt;br /&gt;
&lt;br /&gt;
[[Side Bar Color Fixer]]&lt;br /&gt;
&lt;br /&gt;
==Misc Script Fu==&lt;br /&gt;
[[count*.gif? detection and removal]]&lt;br /&gt;
&lt;br /&gt;
==Scripts by Others==&lt;br /&gt;
[[MySQL Memory Usage]]&lt;br /&gt;
&lt;br /&gt;
[[MySQL Memory Usage Verbose]]&lt;br /&gt;
&lt;br /&gt;
==Solutions (Multi Step)==&lt;br /&gt;
&lt;br /&gt;
[[MySQL Import Progress]]&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Find_and_Replace_in_SQL_database&amp;diff=110</id>
		<title>Find and Replace in SQL database</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Find_and_Replace_in_SQL_database&amp;diff=110"/>
				<updated>2011-06-08T14:40:01Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you need to find and replace a small portion of code (such as ~&amp;lt;username&amp;gt; to &amp;lt;url&amp;gt;) in a database you can use something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[sql,n]&lt;br /&gt;
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Just make sure [field_name] is set correctly on both sides. Otherwise you may overwrite data.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Find_and_Replace_in_SQL_database&amp;diff=109</id>
		<title>Find and Replace in SQL database</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Find_and_Replace_in_SQL_database&amp;diff=109"/>
				<updated>2011-06-08T14:39:53Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you need to find and replace a small portion of code (such as ~&amp;lt;username&amp;gt; to &amp;lt;url&amp;gt;) in a database you can use something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[sql,n]&lt;br /&gt;
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');&lt;br /&gt;
&lt;br /&gt;
Just make sure [field_name] is set correctly on both sides. Otherwise you may overwrite data.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Find_and_Replace_in_SQL_database&amp;diff=108</id>
		<title>Find and Replace in SQL database</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Find_and_Replace_in_SQL_database&amp;diff=108"/>
				<updated>2011-06-08T14:38:33Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: Created page with &amp;quot;If you need to find and replace a small portion of code (such as ~&amp;lt;username&amp;gt; to &amp;lt;url&amp;gt;) in a database you can use something like:  update [table_name] set [field_name] = replace([...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you need to find and replace a small portion of code (such as ~&amp;lt;username&amp;gt; to &amp;lt;url&amp;gt;) in a database you can use something like:&lt;br /&gt;
&lt;br /&gt;
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');&lt;br /&gt;
&lt;br /&gt;
Just make sure [field_name] is set correctly on both sides. Otherwise you may overwrite data.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=107</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=107"/>
				<updated>2011-06-08T14:37:04Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Knowledge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Knowledge==&lt;br /&gt;
[[Monitorix Install cPanel]]&lt;br /&gt;
&lt;br /&gt;
[[Find and Replace in SQL database]]&lt;br /&gt;
&lt;br /&gt;
==Scripts (one liners)==&lt;br /&gt;
[[Add PHP.ini to user directory]]&lt;br /&gt;
&lt;br /&gt;
[[DOS IP with local port]]&lt;br /&gt;
&lt;br /&gt;
[[Find all backups for user]]&lt;br /&gt;
&lt;br /&gt;
[[Get status of MalDet hits]]&lt;br /&gt;
&lt;br /&gt;
[[View Domlogs for top visitors]]&lt;br /&gt;
&lt;br /&gt;
[[Hacker Term Search]]&lt;br /&gt;
&lt;br /&gt;
==Programs (more then one line)==&lt;br /&gt;
[[SwapClean]]&lt;br /&gt;
&lt;br /&gt;
[[errornotify]]&lt;br /&gt;
&lt;br /&gt;
[[ministat]]&lt;br /&gt;
&lt;br /&gt;
==Greasy Monkey (GreaseMonkey Scripts)==&lt;br /&gt;
[[HD Button Remove]]&lt;br /&gt;
&lt;br /&gt;
[[Not So Important]]&lt;br /&gt;
&lt;br /&gt;
[[Side Bar Color Fixer]]&lt;br /&gt;
&lt;br /&gt;
==Misc Script Fu==&lt;br /&gt;
[[count*.gif? detection and removal]]&lt;br /&gt;
&lt;br /&gt;
==Scripts by Others==&lt;br /&gt;
[[MySQL Memory Usage]]&lt;br /&gt;
&lt;br /&gt;
[[MySQL Memory Usage Verbose]]&lt;br /&gt;
&lt;br /&gt;
==Solutions (Multi Step)==&lt;br /&gt;
&lt;br /&gt;
[[MySQL Import Progress]]&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=106</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=106"/>
				<updated>2011-06-08T14:36:58Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Knowledge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Knowledge==&lt;br /&gt;
[[Monitorix Install cPanel]]&lt;br /&gt;
[[Find and Replace in SQL database]]&lt;br /&gt;
&lt;br /&gt;
==Scripts (one liners)==&lt;br /&gt;
[[Add PHP.ini to user directory]]&lt;br /&gt;
&lt;br /&gt;
[[DOS IP with local port]]&lt;br /&gt;
&lt;br /&gt;
[[Find all backups for user]]&lt;br /&gt;
&lt;br /&gt;
[[Get status of MalDet hits]]&lt;br /&gt;
&lt;br /&gt;
[[View Domlogs for top visitors]]&lt;br /&gt;
&lt;br /&gt;
[[Hacker Term Search]]&lt;br /&gt;
&lt;br /&gt;
==Programs (more then one line)==&lt;br /&gt;
[[SwapClean]]&lt;br /&gt;
&lt;br /&gt;
[[errornotify]]&lt;br /&gt;
&lt;br /&gt;
[[ministat]]&lt;br /&gt;
&lt;br /&gt;
==Greasy Monkey (GreaseMonkey Scripts)==&lt;br /&gt;
[[HD Button Remove]]&lt;br /&gt;
&lt;br /&gt;
[[Not So Important]]&lt;br /&gt;
&lt;br /&gt;
[[Side Bar Color Fixer]]&lt;br /&gt;
&lt;br /&gt;
==Misc Script Fu==&lt;br /&gt;
[[count*.gif? detection and removal]]&lt;br /&gt;
&lt;br /&gt;
==Scripts by Others==&lt;br /&gt;
[[MySQL Memory Usage]]&lt;br /&gt;
&lt;br /&gt;
[[MySQL Memory Usage Verbose]]&lt;br /&gt;
&lt;br /&gt;
==Solutions (Multi Step)==&lt;br /&gt;
&lt;br /&gt;
[[MySQL Import Progress]]&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=105</id>
		<title>SwapClean</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=105"/>
				<updated>2011-06-03T14:47:00Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Script that is run via cron every ~10 minutes. Main purpose is to clear any swap usage if the system has the enough free ram and load is below a set value.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#Swap Cleaner&lt;br /&gt;
#Watches swap usage&lt;br /&gt;
#If there is swapping going on and there is enough free (+cache) ram, then turn swap off and back on.&lt;br /&gt;
#Created by James Dooley&lt;br /&gt;
#Feature / Bug requests jdooley@lw&lt;br /&gt;
 &lt;br /&gt;
#User Assigned Variables&lt;br /&gt;
 &lt;br /&gt;
swapthresh=0	#Swap threshold for clearing swap. Will not clear until this value is hit. Good for servers that normally allocates small amounts of swap for some reason.&lt;br /&gt;
freethresh=0	#Real free (free+cached) - current swap threshold. Ensures that atleast x bytes are free before clearing. &lt;br /&gt;
loadthresh=0	#Load threshold, will not clear if above this value (unless 0)&lt;br /&gt;
logrotate=1000	#Max number of lines in the log file&lt;br /&gt;
####&lt;br /&gt;
 &lt;br /&gt;
function plog {&lt;br /&gt;
	echo &amp;quot;[ `date` ][ $curswap; $curfree; $realload ] $1&amp;quot; &amp;gt;&amp;gt; /var/log/swapclean&lt;br /&gt;
	if [ &amp;quot;`wc -l /var/log/swapclean | awk '{print $1}'`&amp;quot; -gt &amp;quot;$logrotate&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		sed -i -e &amp;quot;1d&amp;quot; /var/log/swapclean&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function clearswap {&lt;br /&gt;
	plog &amp;quot;Clearing swap&amp;quot;&lt;br /&gt;
	touch /var/run/.swapoff&lt;br /&gt;
	echo $$ &amp;gt; /var/run/.swapoff&lt;br /&gt;
	/sbin/swapoff -a &amp;amp;&amp;amp; /sbin/swapon -a&lt;br /&gt;
	rm -f /var/run/.swapoff&lt;br /&gt;
	plog &amp;quot;Swap Cleared&amp;quot;&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function checkswap {&lt;br /&gt;
 &lt;br /&gt;
	curswap=`free | fgrep &amp;quot;Swap:&amp;quot; | awk '{print $3}'`&lt;br /&gt;
	curfree=`free | fgrep &amp;quot;buffers/cache:&amp;quot; | awk '{print $4}'`&lt;br /&gt;
	realload=`cat /proc/loadavg | awk '{print $1}'`&lt;br /&gt;
	curload=`echo &amp;quot;$realload * 100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	loadthresh=`echo &amp;quot;$loadthresh *100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	swapdif=`expr $curfree - $curswap`&lt;br /&gt;
 &lt;br /&gt;
	if [ &amp;quot;$swapthresh&amp;quot; -lt &amp;quot;$curswap&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		#Server has swapped and is above its threshold&lt;br /&gt;
		if [ &amp;quot;$freethresh&amp;quot; -lt &amp;quot;$swapdif&amp;quot; ]&lt;br /&gt;
		then&lt;br /&gt;
			#Free - Swap is greater then freethresh&lt;br /&gt;
			if [ &amp;quot;$curload&amp;quot; -lt &amp;quot;$loadthresh&amp;quot; -o &amp;quot;$loadthresh&amp;quot; -eq 0 ]&lt;br /&gt;
			then&lt;br /&gt;
				#Load is below threshold&lt;br /&gt;
				if [ ! -e &amp;quot;/var/run/.swapoff&amp;quot; ] &lt;br /&gt;
				then&lt;br /&gt;
					clearswap&lt;br /&gt;
				else	&lt;br /&gt;
					plog &amp;quot;Lock file found, swap may be already clearing&amp;quot;&lt;br /&gt;
					opid=`cat /var/run/.swapoff`&lt;br /&gt;
					if [ ! &amp;quot;`ps ax | grep $opid | grep ${0##*/}`&amp;quot; ]&lt;br /&gt;
					then&lt;br /&gt;
						plog &amp;quot;PID not active or not owned by swapclean, clearing pid file&amp;quot;&lt;br /&gt;
						rm -f /var/run/.swapoff&lt;br /&gt;
						clearswap&lt;br /&gt;
					else&lt;br /&gt;
						plog &amp;quot;Swap already being cleared, PID active&amp;quot;&lt;br /&gt;
					fi&lt;br /&gt;
				fi&lt;br /&gt;
			else&lt;br /&gt;
				plog &amp;quot;High load, waiting to clear swap&amp;quot;&lt;br /&gt;
			fi&lt;br /&gt;
		else&lt;br /&gt;
			plog &amp;quot;Not enough free memory, waiting to clear swap&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function enablecron {&lt;br /&gt;
	if [ -e &amp;quot;/etc/cron.d/swapclean.sh&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		echo &amp;quot;Cron already enabled, use change to set new time&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;What time would you like to set the cron to&amp;quot;&lt;br /&gt;
		echo &amp;quot;[IE: */10 * * * * ]&amp;quot;&lt;br /&gt;
		read crontime;&lt;br /&gt;
		if [ ! $crontime ] &lt;br /&gt;
		then&lt;br /&gt;
			crontime=&amp;quot;*/10 * * * *&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
		echo &amp;quot;SHELL=/bin/bash&amp;quot; &amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;$crontime root $(readlink -f $0)&amp;quot; &amp;gt;&amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
		chmod 0644 /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;Cron enabled [$crontime root $(readlink -f $0)]&amp;quot;&lt;br /&gt;
		return&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function disablecron {&lt;br /&gt;
	if [ -e &amp;quot;/etc/cron.d/swapclean.sh&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		rm -f /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;Cron disabled&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;Cron not enabled&amp;quot;&lt;br /&gt;
	fi&lt;br /&gt;
 	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
case $1 in&lt;br /&gt;
        --cron)&lt;br /&gt;
                case $2 in&lt;br /&gt;
			on)&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
			off)&lt;br /&gt;
				disablecron&lt;br /&gt;
				;;&lt;br /&gt;
			change)&lt;br /&gt;
				disablecron&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
		esac&lt;br /&gt;
                ;;&lt;br /&gt;
        --help)&lt;br /&gt;
                echo &amp;quot;Check swap usage:&amp;quot;&lt;br /&gt;
		echo &amp;quot; --cron [on, change, off]&amp;quot;&lt;br /&gt;
		echo &amp;quot;	on: Turns on cron job and asks for time&amp;quot;&lt;br /&gt;
		echo &amp;quot;	change: Changes the cron time&amp;quot;&lt;br /&gt;
		echo &amp;quot;	off: Turns off the cron job&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                checkswap&lt;br /&gt;
                ;;&lt;br /&gt;
  esac&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
===swapthresh===&lt;br /&gt;
This value allows swap to get to a certain level before looking to swap. &lt;br /&gt;
&lt;br /&gt;
===freethresh===&lt;br /&gt;
This is the level of extra free ram the script will require before attempting to clean swap&lt;br /&gt;
&lt;br /&gt;
===loadthresh===&lt;br /&gt;
This is the load level threshold at which the script will allow swap to be cleaned.&lt;br /&gt;
&lt;br /&gt;
You will probably want to set this value to a sane number, otherwise an already stressed system may lock up.&lt;br /&gt;
&lt;br /&gt;
===logrotate===&lt;br /&gt;
This is the number of lines that will be stored in the log file. When reached the top line will be deleted.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=104</id>
		<title>SwapClean</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=104"/>
				<updated>2011-06-03T14:17:31Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Script that is run via cron every ~10 minutes. Main purpose is to clear any swap usage if the system has the enough free ram and load is below a set value.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#Swap Cleaner&lt;br /&gt;
#Watches swap usage&lt;br /&gt;
#If there is swapping going on and there is enough free (+cache) ram, then turn swap off and back on.&lt;br /&gt;
#Created by James Dooley&lt;br /&gt;
#Feature / Bug requests jdooley@lw&lt;br /&gt;
 &lt;br /&gt;
#User Assigned Variables&lt;br /&gt;
 &lt;br /&gt;
swapthresh=0	#Swap threshold for clearing swap. Will not clear until this value is hit. Good for servers that normally allocates small amounts of swap for some reason.&lt;br /&gt;
freethresh=0	#Real free (free+cached) - current swap threshold. Ensures that atleast x bytes are free before clearing. &lt;br /&gt;
loadthresh=0	#Load threshold, will not clear if above this value (unless 0)&lt;br /&gt;
logrotate=1000	#Max number of lines in the log file&lt;br /&gt;
####&lt;br /&gt;
 &lt;br /&gt;
function plog {&lt;br /&gt;
	echo &amp;quot;[ `date` ][ $curswap; $curfree; $realload ] $1&amp;quot; &amp;gt;&amp;gt; /var/log/swapclean&lt;br /&gt;
	if [ &amp;quot;`wc -l /var/log/swapclean | awk '{print $1}'`&amp;quot; -gt &amp;quot;$logrotate&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		sed -i -e &amp;quot;1d&amp;quot; /var/log/swapclean&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function clearswap {&lt;br /&gt;
	plog &amp;quot;Clearing swap&amp;quot;&lt;br /&gt;
	touch .swapoff&lt;br /&gt;
	echo $$ &amp;gt; .swapoff&lt;br /&gt;
	/sbin/swapoff -a &amp;amp;&amp;amp; /sbin/swapon -a&lt;br /&gt;
	rm -f .swapoff&lt;br /&gt;
	plog &amp;quot;Swap Cleared&amp;quot;&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function checkswap {&lt;br /&gt;
 &lt;br /&gt;
	curswap=`free | fgrep &amp;quot;Swap:&amp;quot; | awk '{print $3}'`&lt;br /&gt;
	curfree=`free | fgrep &amp;quot;buffers/cache:&amp;quot; | awk '{print $4}'`&lt;br /&gt;
	realload=`cat /proc/loadavg | awk '{print $1}'`&lt;br /&gt;
	curload=`echo &amp;quot;$realload * 100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	loadthresh=`echo &amp;quot;$loadthresh *100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	swapdif=`expr $curfree - $curswap`&lt;br /&gt;
 &lt;br /&gt;
	if [ &amp;quot;$swapthresh&amp;quot; -lt &amp;quot;$curswap&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		#Server has swapped and is above its threshold&lt;br /&gt;
		if [ &amp;quot;$freethresh&amp;quot; -lt &amp;quot;$swapdif&amp;quot; ]&lt;br /&gt;
		then&lt;br /&gt;
			#Free - Swap is greater then freethresh&lt;br /&gt;
			if [ &amp;quot;$curload&amp;quot; -lt &amp;quot;$loadthresh&amp;quot; -o &amp;quot;$loadthresh&amp;quot; -eq 0 ]&lt;br /&gt;
			then&lt;br /&gt;
				#Load is below threshold&lt;br /&gt;
				if [ ! -e &amp;quot;.swapoff&amp;quot; ] &lt;br /&gt;
				then&lt;br /&gt;
					clearswap&lt;br /&gt;
				else	&lt;br /&gt;
					plog &amp;quot;Lock file found, swap may be already clearing&amp;quot;&lt;br /&gt;
					opid=`cat .swapoff`&lt;br /&gt;
					if [ ! &amp;quot;`ps ax | grep $opid | grep ${0##*/}`&amp;quot; ]&lt;br /&gt;
					then&lt;br /&gt;
						plog &amp;quot;PID not active or not owned by swapclean, clearing pid file&amp;quot;&lt;br /&gt;
						rm -f .swapoff&lt;br /&gt;
						clearswap&lt;br /&gt;
					else&lt;br /&gt;
						plog &amp;quot;Swap already being cleared, PID active&amp;quot;&lt;br /&gt;
					fi&lt;br /&gt;
				fi&lt;br /&gt;
			else&lt;br /&gt;
				plog &amp;quot;High load, waiting to clear swap&amp;quot;&lt;br /&gt;
			fi&lt;br /&gt;
		else&lt;br /&gt;
			plog &amp;quot;Not enough free memory, waiting to clear swap&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function enablecron {&lt;br /&gt;
	if [ -e &amp;quot;/etc/cron.d/swapclean.sh&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		echo &amp;quot;Cron already enabled, use change to set new time&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;What time would you like to set the cron to&amp;quot;&lt;br /&gt;
		echo &amp;quot;[IE: */10 * * * * ]&amp;quot;&lt;br /&gt;
		read crontime;&lt;br /&gt;
		if [ ! $crontime ] &lt;br /&gt;
		then&lt;br /&gt;
			crontime=&amp;quot;*/10 * * * *&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
		echo &amp;quot;SHELL=/bin/bash&amp;quot; &amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;$crontime root $(readlink -f $0)&amp;quot; &amp;gt;&amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
		chmod 0644 /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;Cron enabled [$crontime root $(readlink -f $0)]&amp;quot;&lt;br /&gt;
		return&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function disablecron {&lt;br /&gt;
	if [ -e &amp;quot;/etc/cron.d/swapclean.sh&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		rm -f /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;Cron disabled&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;Cron not enabled&amp;quot;&lt;br /&gt;
	fi&lt;br /&gt;
 	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
case $1 in&lt;br /&gt;
        --cron)&lt;br /&gt;
                case $2 in&lt;br /&gt;
			on)&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
			off)&lt;br /&gt;
				disablecron&lt;br /&gt;
				;;&lt;br /&gt;
			change)&lt;br /&gt;
				disablecron&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
		esac&lt;br /&gt;
                ;;&lt;br /&gt;
        --help)&lt;br /&gt;
                echo &amp;quot;Check swap usage:&amp;quot;&lt;br /&gt;
		echo &amp;quot; --cron [on, change, off]&amp;quot;&lt;br /&gt;
		echo &amp;quot;	on: Turns on cron job and asks for time&amp;quot;&lt;br /&gt;
		echo &amp;quot;	change: Changes the cron time&amp;quot;&lt;br /&gt;
		echo &amp;quot;	off: Turns off the cron job&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                checkswap&lt;br /&gt;
                ;;&lt;br /&gt;
  esac&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
===swapthresh===&lt;br /&gt;
This value allows swap to get to a certain level before looking to swap. &lt;br /&gt;
&lt;br /&gt;
===freethresh===&lt;br /&gt;
This is the level of extra free ram the script will require before attempting to clean swap&lt;br /&gt;
&lt;br /&gt;
===loadthresh===&lt;br /&gt;
This is the load level threshold at which the script will allow swap to be cleaned.&lt;br /&gt;
&lt;br /&gt;
You will probably want to set this value to a sane number, otherwise an already stressed system may lock up.&lt;br /&gt;
&lt;br /&gt;
===logrotate===&lt;br /&gt;
This is the number of lines that will be stored in the log file. When reached the top line will be deleted.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=103</id>
		<title>SwapClean</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=103"/>
				<updated>2011-06-03T13:33:53Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Script that is run via cron every ~10 minutes. Main purpose is to clear any swap usage if the system has the enough free ram and load is below a set value.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#Swap Cleaner&lt;br /&gt;
#Watches swap usage&lt;br /&gt;
#If there is swapping going on and there is enough free (+cache) ram, then turn swap off and back on.&lt;br /&gt;
#Created by James Dooley&lt;br /&gt;
#Feature / Bug requests jdooley@lw&lt;br /&gt;
 &lt;br /&gt;
#User Assigned Variables&lt;br /&gt;
 &lt;br /&gt;
swapthresh=0	#Swap threshold for clearing swap. Will not clear until this value is hit. Good for servers that normally allocates small amounts of swap for some reason.&lt;br /&gt;
freethresh=0	#Real free (free+cached) - current swap threshold. Ensures that atleast x bytes are free before clearing. &lt;br /&gt;
loadthresh=0	#Load threshold, will not clear if above this value (unless 0)&lt;br /&gt;
logrotate=1000	#Max number of lines in the log file&lt;br /&gt;
####&lt;br /&gt;
 &lt;br /&gt;
function plog {&lt;br /&gt;
	echo &amp;quot;[ `date` ][ $curswap; $curfree; $realload ] $1&amp;quot; &amp;gt;&amp;gt; /var/log/swapclean&lt;br /&gt;
	if [ &amp;quot;`wc -l /var/log/swapclean | awk '{print $1}'`&amp;quot; -gt &amp;quot;$logrotate&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		sed -i -e &amp;quot;1d&amp;quot; /var/log/swapclean&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function checkswap {&lt;br /&gt;
 &lt;br /&gt;
	curswap=`free | fgrep &amp;quot;Swap:&amp;quot; | awk '{print $3}'`&lt;br /&gt;
	curfree=`free | fgrep &amp;quot;buffers/cache:&amp;quot; | awk '{print $4}'`&lt;br /&gt;
	realload=`cat /proc/loadavg | awk '{print $1}'`&lt;br /&gt;
	curload=`echo &amp;quot;$realload * 100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	loadthresh=`echo &amp;quot;$loadthresh *100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	swapdif=`expr $curfree - $curswap`&lt;br /&gt;
 &lt;br /&gt;
	if [ &amp;quot;$swapthresh&amp;quot; -lt &amp;quot;$curswap&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		#Server has swapped and is above its threshold&lt;br /&gt;
		if [ &amp;quot;$freethresh&amp;quot; -lt &amp;quot;$swapdif&amp;quot; ]&lt;br /&gt;
		then&lt;br /&gt;
			#Free - Swap is greater then freethresh&lt;br /&gt;
			if [ &amp;quot;$curload&amp;quot; -lt &amp;quot;$loadthresh&amp;quot; -o &amp;quot;$loadthresh&amp;quot; -eq 0 ]&lt;br /&gt;
			then&lt;br /&gt;
				#Load is below threshold&lt;br /&gt;
				if [ ! -e &amp;quot;.swapoff&amp;quot; ] &lt;br /&gt;
				then&lt;br /&gt;
					clearswap&lt;br /&gt;
				else	&lt;br /&gt;
					plog &amp;quot;Lock file found, swap may be already clearing&amp;quot;&lt;br /&gt;
					opid=`cat .swapoff`&lt;br /&gt;
					if [ `ps ax | grep $opid | grep swapclean` -eq &amp;quot;&amp;quot; ]&lt;br /&gt;
					then&lt;br /&gt;
						plog &amp;quot;PID not active or not owned by swapclean, clearing pid file&amp;quot;&lt;br /&gt;
						rm -f .swapoff&lt;br /&gt;
						clearswap&lt;br /&gt;
					else&lt;br /&gt;
						plog &amp;quot;Swap already being cleared, PID active&amp;quot;&lt;br /&gt;
					fi&lt;br /&gt;
				fi&lt;br /&gt;
			else&lt;br /&gt;
				plog &amp;quot;High load, waiting to clear swap&amp;quot;&lt;br /&gt;
			fi&lt;br /&gt;
		else&lt;br /&gt;
			plog &amp;quot;Not enough free memory, waiting to clear swap&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function clearswap {&lt;br /&gt;
	plog &amp;quot;Clearing swap&amp;quot;&lt;br /&gt;
	touch .swapoff&lt;br /&gt;
	echo $$ &amp;gt; .swapoff&lt;br /&gt;
	/sbin/swapoff -a &amp;amp;&amp;amp; /sbin/swapon -a&lt;br /&gt;
	rm -f .swapoff&lt;br /&gt;
	plog &amp;quot;Swap Cleared&amp;quot;&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
	&lt;br /&gt;
 &lt;br /&gt;
function enablecron {&lt;br /&gt;
	if [ -e &amp;quot;/etc/cron.d/swapclean.sh&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		echo &amp;quot;Cron already enabled, use change to set new time&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;What time would you like to set the cron to&amp;quot;&lt;br /&gt;
		echo &amp;quot;[IE: */10 * * * * ]&amp;quot;&lt;br /&gt;
		read crontime;&lt;br /&gt;
		if [ ! $crontime ] &lt;br /&gt;
		then&lt;br /&gt;
			crontime=&amp;quot;*/10 * * * *&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
		echo &amp;quot;SHELL=/bin/bash&amp;quot; &amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;$crontime root $(readlink -f $0)&amp;quot; &amp;gt;&amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
		chmod 0644 /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;Cron enabled [$crontime root $(readlink -f $0)]&amp;quot;&lt;br /&gt;
		return&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function disablecron {&lt;br /&gt;
	if [ -e &amp;quot;/etc/cron.d/swapclean.sh&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		rm -f /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;Cron disabled&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;Cron not enabled&amp;quot;&lt;br /&gt;
	fi&lt;br /&gt;
 	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
case $1 in&lt;br /&gt;
        --cron)&lt;br /&gt;
                case $2 in&lt;br /&gt;
			on)&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
			off)&lt;br /&gt;
				disablecron&lt;br /&gt;
				;;&lt;br /&gt;
			change)&lt;br /&gt;
				disablecron&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
		esac&lt;br /&gt;
                ;;&lt;br /&gt;
        --help)&lt;br /&gt;
                echo &amp;quot;Check swap usage:&amp;quot;&lt;br /&gt;
		echo &amp;quot; --cron [on, change, off]&amp;quot;&lt;br /&gt;
		echo &amp;quot;	on: Turns on cron job and asks for time&amp;quot;&lt;br /&gt;
		echo &amp;quot;  change: Changes the cron time&amp;quot;&lt;br /&gt;
		echo &amp;quot;	off: Turns off the cron job&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                checkswap&lt;br /&gt;
                ;;&lt;br /&gt;
  esac&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
===swapthresh===&lt;br /&gt;
This value allows swap to get to a certain level before looking to swap. &lt;br /&gt;
&lt;br /&gt;
===freethresh===&lt;br /&gt;
This is the level of extra free ram the script will require before attempting to clean swap&lt;br /&gt;
&lt;br /&gt;
===loadthresh===&lt;br /&gt;
This is the load level threshold at which the script will allow swap to be cleaned.&lt;br /&gt;
&lt;br /&gt;
You will probably want to set this value to a sane number, otherwise an already stressed system may lock up.&lt;br /&gt;
&lt;br /&gt;
===logrotate===&lt;br /&gt;
This is the number of lines that will be stored in the log file. When reached the top line will be deleted.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=102</id>
		<title>SwapClean</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=102"/>
				<updated>2011-06-03T13:24:22Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Script that is run via cron every ~10 minutes. Main purpose is to clear any swap usage if the system has the enough free ram and load is below a set value.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#Swap Cleaner&lt;br /&gt;
#Watches swap usage&lt;br /&gt;
#If there is swapping going on and there is enough free (+cache) ram, then turn swap off and back on.&lt;br /&gt;
#Created by James Dooley&lt;br /&gt;
#Feature / Bug requests jdooley@lw&lt;br /&gt;
 &lt;br /&gt;
#User Assigned Variables&lt;br /&gt;
 &lt;br /&gt;
swapthresh=0	#Swap threshold for clearing swap. Will not clear until this value is hit. Good for servers that normally allocates small amounts of swap for some reason.&lt;br /&gt;
freethresh=0	#Real free (free+cached) - current swap threshold. Ensures that atleast x bytes are free before clearing. &lt;br /&gt;
loadthresh=0	#Load threshold, will not clear if above this value (unless 0)&lt;br /&gt;
logrotate=1000	#Max number of lines in the log file&lt;br /&gt;
####&lt;br /&gt;
 &lt;br /&gt;
function plog {&lt;br /&gt;
	echo &amp;quot;[ `date` ][ $curswap; $curfree; $realload ] $1&amp;quot; &amp;gt;&amp;gt; /var/log/swapclean&lt;br /&gt;
	if [ &amp;quot;`wc -l /var/log/swapclean | awk '{print $1}'`&amp;quot; -gt &amp;quot;$logrotate&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		sed -i -e &amp;quot;1d&amp;quot; /var/log/swapclean&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function checkswap {&lt;br /&gt;
 &lt;br /&gt;
	curswap=`free | fgrep &amp;quot;Swap:&amp;quot; | awk '{print $3}'`&lt;br /&gt;
	curfree=`free | fgrep &amp;quot;buffers/cache:&amp;quot; | awk '{print $4}'`&lt;br /&gt;
	realload=`cat /proc/loadavg | awk '{print $1}'`&lt;br /&gt;
	curload=`echo &amp;quot;$realload * 100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	loadthresh=`echo &amp;quot;$loadthresh *100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	swapdif=`expr $curfree - $curswap`&lt;br /&gt;
 &lt;br /&gt;
	if [ &amp;quot;$swapthresh&amp;quot; -lt &amp;quot;$curswap&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		#Server has swapped and is above its threshold&lt;br /&gt;
		if [ &amp;quot;$freethresh&amp;quot; -lt &amp;quot;$swapdif&amp;quot; ]&lt;br /&gt;
		then&lt;br /&gt;
			#Free - Swap is greater then freethresh&lt;br /&gt;
			if [ &amp;quot;$curload&amp;quot; -lt &amp;quot;$loadthresh&amp;quot; -o &amp;quot;$loadthresh&amp;quot; -eq 0 ]&lt;br /&gt;
			then&lt;br /&gt;
				#Load is below threshold&lt;br /&gt;
				if [ ! -e &amp;quot;.swapoff&amp;quot; ] &lt;br /&gt;
				then&lt;br /&gt;
					clearswap&lt;br /&gt;
				else	&lt;br /&gt;
					plog &amp;quot;Lock file found, swap may be already clearing&amp;quot;&lt;br /&gt;
					opid=`cat .swapoff`&lt;br /&gt;
					if [ `ps ax | grep $opid | grep swapclean` -eq &amp;quot;&amp;quot; ]&lt;br /&gt;
						plog &amp;quot;PID not active or not owned by swapclean, clearing pid file&amp;quot;&lt;br /&gt;
						rm -f .swapoff&lt;br /&gt;
						clearswap&lt;br /&gt;
					else&lt;br /&gt;
						plog &amp;quot;Swap already being cleared, PID active&amp;quot;&lt;br /&gt;
					fi&lt;br /&gt;
				fi&lt;br /&gt;
			else&lt;br /&gt;
				plog &amp;quot;High load, waiting to clear swap&amp;quot;&lt;br /&gt;
			fi&lt;br /&gt;
		else&lt;br /&gt;
			plog &amp;quot;Not enough free memory, waiting to clear swap&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function clearswap {&lt;br /&gt;
	plog &amp;quot;Clearing swap&amp;quot;&lt;br /&gt;
	touch .swapoff&lt;br /&gt;
	echo $$ &amp;gt; .swapoff&lt;br /&gt;
	/sbin/swapoff -a &amp;amp;&amp;amp; /sbin/swapon -a&lt;br /&gt;
	rm -f .swapoff&lt;br /&gt;
	plog &amp;quot;Swap Cleared&amp;quot;&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
	&lt;br /&gt;
 &lt;br /&gt;
function enablecron {&lt;br /&gt;
	if [ -e &amp;quot;/etc/cron.d/swapclean.sh&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		echo &amp;quot;Cron already enabled, use change to set new time&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;What time would you like to set the cron to&amp;quot;&lt;br /&gt;
		echo &amp;quot;[IE: */10 * * * * ]&amp;quot;&lt;br /&gt;
		read crontime;&lt;br /&gt;
		if [ ! $crontime ] &lt;br /&gt;
		then&lt;br /&gt;
			crontime=&amp;quot;*/10 * * * *&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
		echo &amp;quot;SHELL=/bin/bash&amp;quot; &amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;$crontime root $(readlink -f $0)&amp;quot; &amp;gt;&amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
		chmod 0644 /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;Cron enabled [$crontime root $(readlink -f $0)]&amp;quot;&lt;br /&gt;
		return&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function disablecron {&lt;br /&gt;
	if [ -e &amp;quot;/etc/cron.d/swapclean.sh&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		rm -f /etc/cron.d/swapclean.sh&lt;br /&gt;
		echo &amp;quot;Cron disabled&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;Cron not enabled&amp;quot;&lt;br /&gt;
	fi&lt;br /&gt;
 	return&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
case $1 in&lt;br /&gt;
        --cron)&lt;br /&gt;
                case $2 in&lt;br /&gt;
			on)&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
			off)&lt;br /&gt;
				disablecron&lt;br /&gt;
				;;&lt;br /&gt;
			change)&lt;br /&gt;
				disablecron&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
		esac&lt;br /&gt;
                ;;&lt;br /&gt;
        --help)&lt;br /&gt;
                echo &amp;quot;Check swap usage:&amp;quot;&lt;br /&gt;
		echo &amp;quot; --cron [on, change, off]&amp;quot;&lt;br /&gt;
		echo &amp;quot;	on: Turns on cron job and asks for time&amp;quot;&lt;br /&gt;
		echo &amp;quot;  change: Changes the cron time&amp;quot;&lt;br /&gt;
		echo &amp;quot;	off: Turns off the cron job&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                checkswap&lt;br /&gt;
                ;;&lt;br /&gt;
  esac&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
===swapthresh===&lt;br /&gt;
This value allows swap to get to a certain level before looking to swap. &lt;br /&gt;
&lt;br /&gt;
===freethresh===&lt;br /&gt;
This is the level of extra free ram the script will require before attempting to clean swap&lt;br /&gt;
&lt;br /&gt;
===loadthresh===&lt;br /&gt;
This is the load level threshold at which the script will allow swap to be cleaned.&lt;br /&gt;
&lt;br /&gt;
You will probably want to set this value to a sane number, otherwise an already stressed system may lock up.&lt;br /&gt;
&lt;br /&gt;
===logrotate===&lt;br /&gt;
This is the number of lines that will be stored in the log file. When reached the top line will be deleted.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=101</id>
		<title>SwapClean</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=101"/>
				<updated>2011-06-02T18:26:38Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* loadthresh */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Script that is run via cron every ~10 minutes. Main purpose is to clear any swap usage if the system has the enough free ram and load is below a set value.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#Swap Cleaner&lt;br /&gt;
#Watches swap usage&lt;br /&gt;
#If there is swapping going on and there is enough free (+cache) ram, then turn swap off and back on.&lt;br /&gt;
 &lt;br /&gt;
#User Assigned Variables&lt;br /&gt;
 &lt;br /&gt;
swapthresh=0	#Swap threshold for clearing swap. Will not clear until this value is hit&lt;br /&gt;
freethresh=0	#Real free (free+cached) - current swap threshold. Ensures that atleast x bytes are free before clearing&lt;br /&gt;
loadthresh=0	#Load threshold, will not clear if above this value (unless 0)&lt;br /&gt;
logrotate=1000	#Max number of lines in the log file&lt;br /&gt;
####&lt;br /&gt;
 &lt;br /&gt;
function plog {&lt;br /&gt;
	echo &amp;quot;[ `date` ][ $curswap; $curfree; $realload ] $1&amp;quot; &amp;gt;&amp;gt; /var/log/swapclean&lt;br /&gt;
	if [ &amp;quot;`wc -l /var/log/swapclean | awk '{print $1}'`&amp;quot; -gt &amp;quot;$logrotate&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		sed -i -e &amp;quot;1d&amp;quot; /var/log/swapclean&lt;br /&gt;
	fi&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function checkswap {&lt;br /&gt;
 &lt;br /&gt;
	curswap=`free | fgrep &amp;quot;Swap:&amp;quot; | awk '{print $3}'`&lt;br /&gt;
	curfree=`free | fgrep &amp;quot;buffers/cache:&amp;quot; | awk '{print $4}'`&lt;br /&gt;
	realload=`cat /proc/loadavg | awk '{print $1}'`&lt;br /&gt;
	curload=`echo &amp;quot;$realload * 100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	loadthresh=`echo &amp;quot;$loadthresh *100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	swapdif=`expr $curfree - $curswap`&lt;br /&gt;
 &lt;br /&gt;
	if [ &amp;quot;$swapthresh&amp;quot; -lt &amp;quot;$curswap&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		#Server has swapped and is above its threshold&lt;br /&gt;
		if [ &amp;quot;$freethresh&amp;quot; -lt &amp;quot;$swapdif&amp;quot; ]&lt;br /&gt;
		then&lt;br /&gt;
			#Free - Swap is greater then freethresh&lt;br /&gt;
			if [ &amp;quot;$curload&amp;quot; -lt &amp;quot;$loadthresh&amp;quot; -o &amp;quot;$loadthresh&amp;quot; -eq 0 ]&lt;br /&gt;
			then&lt;br /&gt;
				#Load is below threshold&lt;br /&gt;
				if [ ! -e &amp;quot;.swapoff&amp;quot; ] &lt;br /&gt;
				then&lt;br /&gt;
					plog &amp;quot;Clearing swap&amp;quot;&lt;br /&gt;
					#Not currently clearing swap, nuke it.&lt;br /&gt;
					touch .swapoff&lt;br /&gt;
					/sbin/swapoff -a &amp;amp;&amp;amp; /sbin/swapon -a&lt;br /&gt;
					rm -f .swapoff&lt;br /&gt;
					plog &amp;quot;Swap Cleared&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					plog &amp;quot;Lock file found, swap may be already clearing&amp;quot;&lt;br /&gt;
				fi&lt;br /&gt;
			else&lt;br /&gt;
				plog &amp;quot;High load, waiting to clear swap&amp;quot;&lt;br /&gt;
			fi&lt;br /&gt;
		else&lt;br /&gt;
			plog &amp;quot;Not enough free memory, waiting to clear swap&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
	fi&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function enablecron {&lt;br /&gt;
 &lt;br /&gt;
	echo &amp;quot;What time would you like to set the cron to&amp;quot;&lt;br /&gt;
	echo &amp;quot;[IE: */10 * * * * ]&amp;quot;&lt;br /&gt;
	read crontime;&lt;br /&gt;
	if [ ! $crontime ] &lt;br /&gt;
	then&lt;br /&gt;
		crontime=&amp;quot;*/10 * * * *&amp;quot;&lt;br /&gt;
	fi&lt;br /&gt;
	echo &amp;quot;SHELL=/bin/bash&amp;quot; &amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
	echo &amp;quot;$crontime root $(readlink -f $0)&amp;quot; &amp;gt;&amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
	chmod 0644 /etc/cron.d/swapclean.sh&lt;br /&gt;
	echo &amp;quot;Cron enabled [$crontime root $(readlink -f $0)]&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function disablecron {&lt;br /&gt;
 &lt;br /&gt;
	rm -f /etc/cron.d/swapclean.sh&lt;br /&gt;
	echo &amp;quot;Cron disabled&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
case $1 in&lt;br /&gt;
        --cron)&lt;br /&gt;
                case $2 in&lt;br /&gt;
			on)&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
			off)&lt;br /&gt;
				disablecron&lt;br /&gt;
				;;&lt;br /&gt;
		esac&lt;br /&gt;
                ;;&lt;br /&gt;
        --help)&lt;br /&gt;
                echo &amp;quot;Check swap usage:&amp;quot;&lt;br /&gt;
		echo &amp;quot; --cron [on, off]&amp;quot;&lt;br /&gt;
		echo &amp;quot;	on: Turns on cron job and asks for time&amp;quot;&lt;br /&gt;
		echo &amp;quot;	off: Turns off the cron job&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                checkswap&lt;br /&gt;
                ;;&lt;br /&gt;
  esac&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
===swapthresh===&lt;br /&gt;
This value allows swap to get to a certain level before looking to swap. &lt;br /&gt;
&lt;br /&gt;
===freethresh===&lt;br /&gt;
This is the level of extra free ram the script will require before attempting to clean swap&lt;br /&gt;
&lt;br /&gt;
===loadthresh===&lt;br /&gt;
This is the load level threshold at which the script will allow swap to be cleaned.&lt;br /&gt;
&lt;br /&gt;
You will probably want to set this value to a sane number, otherwise an already stressed system may lock up.&lt;br /&gt;
&lt;br /&gt;
===logrotate===&lt;br /&gt;
This is the number of lines that will be stored in the log file. When reached the top line will be deleted.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=100</id>
		<title>SwapClean</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=SwapClean&amp;diff=100"/>
				<updated>2011-06-02T18:25:54Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Script that is run via cron every ~10 minutes. Main purpose is to clear any swap usage if the system has the enough free ram and load is below a set value.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#Swap Cleaner&lt;br /&gt;
#Watches swap usage&lt;br /&gt;
#If there is swapping going on and there is enough free (+cache) ram, then turn swap off and back on.&lt;br /&gt;
 &lt;br /&gt;
#User Assigned Variables&lt;br /&gt;
 &lt;br /&gt;
swapthresh=0	#Swap threshold for clearing swap. Will not clear until this value is hit&lt;br /&gt;
freethresh=0	#Real free (free+cached) - current swap threshold. Ensures that atleast x bytes are free before clearing&lt;br /&gt;
loadthresh=0	#Load threshold, will not clear if above this value (unless 0)&lt;br /&gt;
logrotate=1000	#Max number of lines in the log file&lt;br /&gt;
####&lt;br /&gt;
 &lt;br /&gt;
function plog {&lt;br /&gt;
	echo &amp;quot;[ `date` ][ $curswap; $curfree; $realload ] $1&amp;quot; &amp;gt;&amp;gt; /var/log/swapclean&lt;br /&gt;
	if [ &amp;quot;`wc -l /var/log/swapclean | awk '{print $1}'`&amp;quot; -gt &amp;quot;$logrotate&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		sed -i -e &amp;quot;1d&amp;quot; /var/log/swapclean&lt;br /&gt;
	fi&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function checkswap {&lt;br /&gt;
 &lt;br /&gt;
	curswap=`free | fgrep &amp;quot;Swap:&amp;quot; | awk '{print $3}'`&lt;br /&gt;
	curfree=`free | fgrep &amp;quot;buffers/cache:&amp;quot; | awk '{print $4}'`&lt;br /&gt;
	realload=`cat /proc/loadavg | awk '{print $1}'`&lt;br /&gt;
	curload=`echo &amp;quot;$realload * 100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	loadthresh=`echo &amp;quot;$loadthresh *100&amp;quot; | bc | sed 's/[.].*//'`&lt;br /&gt;
	swapdif=`expr $curfree - $curswap`&lt;br /&gt;
 &lt;br /&gt;
	if [ &amp;quot;$swapthresh&amp;quot; -lt &amp;quot;$curswap&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		#Server has swapped and is above its threshold&lt;br /&gt;
		if [ &amp;quot;$freethresh&amp;quot; -lt &amp;quot;$swapdif&amp;quot; ]&lt;br /&gt;
		then&lt;br /&gt;
			#Free - Swap is greater then freethresh&lt;br /&gt;
			if [ &amp;quot;$curload&amp;quot; -lt &amp;quot;$loadthresh&amp;quot; -o &amp;quot;$loadthresh&amp;quot; -eq 0 ]&lt;br /&gt;
			then&lt;br /&gt;
				#Load is below threshold&lt;br /&gt;
				if [ ! -e &amp;quot;.swapoff&amp;quot; ] &lt;br /&gt;
				then&lt;br /&gt;
					plog &amp;quot;Clearing swap&amp;quot;&lt;br /&gt;
					#Not currently clearing swap, nuke it.&lt;br /&gt;
					touch .swapoff&lt;br /&gt;
					/sbin/swapoff -a &amp;amp;&amp;amp; /sbin/swapon -a&lt;br /&gt;
					rm -f .swapoff&lt;br /&gt;
					plog &amp;quot;Swap Cleared&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					plog &amp;quot;Lock file found, swap may be already clearing&amp;quot;&lt;br /&gt;
				fi&lt;br /&gt;
			else&lt;br /&gt;
				plog &amp;quot;High load, waiting to clear swap&amp;quot;&lt;br /&gt;
			fi&lt;br /&gt;
		else&lt;br /&gt;
			plog &amp;quot;Not enough free memory, waiting to clear swap&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
	fi&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function enablecron {&lt;br /&gt;
 &lt;br /&gt;
	echo &amp;quot;What time would you like to set the cron to&amp;quot;&lt;br /&gt;
	echo &amp;quot;[IE: */10 * * * * ]&amp;quot;&lt;br /&gt;
	read crontime;&lt;br /&gt;
	if [ ! $crontime ] &lt;br /&gt;
	then&lt;br /&gt;
		crontime=&amp;quot;*/10 * * * *&amp;quot;&lt;br /&gt;
	fi&lt;br /&gt;
	echo &amp;quot;SHELL=/bin/bash&amp;quot; &amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
	echo &amp;quot;$crontime root $(readlink -f $0)&amp;quot; &amp;gt;&amp;gt; /etc/cron.d/swapclean.sh&lt;br /&gt;
	chmod 0644 /etc/cron.d/swapclean.sh&lt;br /&gt;
	echo &amp;quot;Cron enabled [$crontime root $(readlink -f $0)]&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function disablecron {&lt;br /&gt;
 &lt;br /&gt;
	rm -f /etc/cron.d/swapclean.sh&lt;br /&gt;
	echo &amp;quot;Cron disabled&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
case $1 in&lt;br /&gt;
        --cron)&lt;br /&gt;
                case $2 in&lt;br /&gt;
			on)&lt;br /&gt;
				enablecron&lt;br /&gt;
				;;&lt;br /&gt;
			off)&lt;br /&gt;
				disablecron&lt;br /&gt;
				;;&lt;br /&gt;
		esac&lt;br /&gt;
                ;;&lt;br /&gt;
        --help)&lt;br /&gt;
                echo &amp;quot;Check swap usage:&amp;quot;&lt;br /&gt;
		echo &amp;quot; --cron [on, off]&amp;quot;&lt;br /&gt;
		echo &amp;quot;	on: Turns on cron job and asks for time&amp;quot;&lt;br /&gt;
		echo &amp;quot;	off: Turns off the cron job&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                checkswap&lt;br /&gt;
                ;;&lt;br /&gt;
  esac&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
===swapthresh===&lt;br /&gt;
This value allows swap to get to a certain level before looking to swap. &lt;br /&gt;
&lt;br /&gt;
===freethresh===&lt;br /&gt;
This is the level of extra free ram the script will require before attempting to clean swap&lt;br /&gt;
&lt;br /&gt;
===loadthresh===&lt;br /&gt;
This is the load level threshold at which the script will allow swap to be cleaned.&lt;br /&gt;
&lt;br /&gt;
===logrotate===&lt;br /&gt;
This is the number of lines that will be stored in the log file. When reached the top line will be deleted.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=99</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=99"/>
				<updated>2011-06-01T13:23:23Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
Auto adjusts output based on size of the terminal.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
function checkmysql {&lt;br /&gt;
	cmdmysql=`mysql --batch -e 'show processlist;' | grep -v &amp;quot;Id&amp;quot; | cut -f6,5,4,8 | sed -e 's/\t/ /g' | sort -nr --key=3 | sed -e 's/ /\|/' -e 's/ /\|/' -e 's/ /\|/' | awk 'BEGIN {FS=&amp;quot;|&amp;quot;}; { printf &amp;quot;%-4s%-18s%-8s%-30s&amp;quot;,$3,$1,$2,$4; print &amp;quot;&amp;quot; }'`&lt;br /&gt;
	if [[ $cmdmysql != &amp;quot;&amp;quot; ]]&lt;br /&gt;
	then&lt;br /&gt;
		wcmysql=`echo &amp;quot;$cmdmysql&amp;quot; | wc -l`&lt;br /&gt;
	else&lt;br /&gt;
		wcmysql=0&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function checkapache {&lt;br /&gt;
	if [ -d &amp;quot;/var/cpanel&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		cmdapache=`httpd status 2&amp;gt;&amp;amp;1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep &amp;quot;requests/sec&amp;quot; -A 999`&lt;br /&gt;
	else&lt;br /&gt;
		cmdapache=`lynx --dump http://localhost/server-status 2&amp;gt;&amp;amp;1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep &amp;quot;requests/sec&amp;quot; -A 999`&lt;br /&gt;
	fi&lt;br /&gt;
	if [[ $cmdapache != &amp;quot;&amp;quot; ]]&lt;br /&gt;
	then&lt;br /&gt;
		wcapache=`echo &amp;quot;$cmdapache&amp;quot; | wc -l`&lt;br /&gt;
	else&lt;br /&gt;
		wcapache=0&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function calclines {&lt;br /&gt;
	nline=`tput lines | awk '{print int(($1 - 14) / 3)}'`&lt;br /&gt;
	aline=`echo $nline 3 | awk '{print $1 + $2}'`&lt;br /&gt;
	if [ $nline -gt $wcmysql ]&lt;br /&gt;
	then&lt;br /&gt;
		nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function addseperator {&lt;br /&gt;
	printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
checkmysql&lt;br /&gt;
checkapache&lt;br /&gt;
calclines&lt;br /&gt;
&lt;br /&gt;
top -c -b -n 1 | grep -v &amp;quot;grep&amp;quot; | grep &amp;quot;PID&amp;quot; -A $nline&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ $wcmysql -gt 0 ]&lt;br /&gt;
then&lt;br /&gt;
	addseperator&lt;br /&gt;
	echo &amp;quot;$cmdmysql&amp;quot; | head -$nline&lt;br /&gt;
fi&lt;br /&gt;
if [ $wcapache -gt 0 ]&lt;br /&gt;
then&lt;br /&gt;
	addseperator&lt;br /&gt;
	echo &amp;quot;$cmdapache&amp;quot; | head -$aline&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode) from ent.int server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://scripts.ent.liquidweb.com/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode) from this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Side_Bar_Color_Fixer&amp;diff=98</id>
		<title>Side Bar Color Fixer</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Side_Bar_Color_Fixer&amp;diff=98"/>
				<updated>2011-05-24T13:28:05Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Changes the link colors to something more readable and removes link underlines.&lt;br /&gt;
&lt;br /&gt;
Also shrunk the text down to fit inside the frame for Nate's sidebar.&lt;br /&gt;
&lt;br /&gt;
Removed search boxes since nobody uses them anyway.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[javascript,n]&lt;br /&gt;
// ==UserScript==&lt;br /&gt;
// @name           HD Link Color&lt;br /&gt;
// @namespace      http://jamesdooley.us&lt;br /&gt;
// @description    Change HD Status Links to more visible colors&lt;br /&gt;
// @include        https://hd.int.liquidweb.com/stats/acd/support/vertsearch.mhtml&lt;br /&gt;
// ==/UserScript==&lt;br /&gt;
&lt;br /&gt;
GM_addStyle(&amp;quot;A { color: #FFF; text-decoration: none}&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.numbers { float: right;}&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.header { font-size: 10px; }&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.stats { font-size: 10px; }&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.statsred { font-size: 10px; }&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.statsgreen { font-size: 10px; }&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tablerows = document.getElementsByTagName('tr');&lt;br /&gt;
&lt;br /&gt;
for (i=9; i&amp;lt;=14; i++)&lt;br /&gt;
{&lt;br /&gt;
        tablerows[i].style.display = &amp;quot;none&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
document.getElementsByTagName('p')[0].style.display = &amp;quot;none&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
To change the link color&lt;br /&gt;
&lt;br /&gt;
color: &amp;lt;hex&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To enable link underlines remove &lt;br /&gt;
&lt;br /&gt;
text-decoration: none&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Side_Bar_Color_Fixer&amp;diff=97</id>
		<title>Side Bar Color Fixer</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Side_Bar_Color_Fixer&amp;diff=97"/>
				<updated>2011-05-24T13:27:13Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Changes the link colors to something more readable and removes link underlines.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[javascript,n]&lt;br /&gt;
// ==UserScript==&lt;br /&gt;
// @name           HD Link Color&lt;br /&gt;
// @namespace      http://jamesdooley.us&lt;br /&gt;
// @description    Change HD Status Links to more visible colors&lt;br /&gt;
// @include        https://hd.int.liquidweb.com/stats/acd/support/vertsearch.mhtml&lt;br /&gt;
// ==/UserScript==&lt;br /&gt;
&lt;br /&gt;
GM_addStyle(&amp;quot;A { color: #FFF; text-decoration: none}&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.numbers { float: right;}&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.header { font-size: 10px; }&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.stats { font-size: 10px; }&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.statsred { font-size: 10px; }&amp;quot;);&lt;br /&gt;
GM_addStyle(&amp;quot;.statsgreen { font-size: 10px; }&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tablerows = document.getElementsByTagName('tr');&lt;br /&gt;
&lt;br /&gt;
for (i=9; i&amp;lt;=14; i++)&lt;br /&gt;
{&lt;br /&gt;
        tablerows[i].style.display = &amp;quot;none&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
document.getElementsByTagName('p')[0].style.display = &amp;quot;none&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
To change the link color&lt;br /&gt;
&lt;br /&gt;
color: &amp;lt;hex&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To enable link underlines remove &lt;br /&gt;
&lt;br /&gt;
text-decoration: none&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=96</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=96"/>
				<updated>2011-05-20T16:30:52Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
Auto adjusts output based on size of the terminal.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
function checkmysql {&lt;br /&gt;
	cmdmysql=`mysql --batch -e 'show processlist;' | grep -v &amp;quot;Id&amp;quot; | cut -f6,5,4,8 | sed -e 's/\t/ /g' | sort -nr --key=3 | sed -e 's/ /\|/' -e 's/ /\|/' -e 's/ /\|/' | awk 'BEGIN {FS=&amp;quot;|&amp;quot;}; { printf &amp;quot;%-4s%-18s%-8s%-30s&amp;quot;,$3,$1,$2,$4; print &amp;quot;&amp;quot; }'`&lt;br /&gt;
	if [[ $cmdmysql != &amp;quot;&amp;quot; ]]&lt;br /&gt;
	then&lt;br /&gt;
		wcmysql=`echo &amp;quot;$cmdmysql&amp;quot; | wc -l`&lt;br /&gt;
	else&lt;br /&gt;
		wcmysql=0&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function checkapache {&lt;br /&gt;
	if [ -d &amp;quot;/var/cpanel&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		cmdapache=`httpd status 2&amp;gt;&amp;amp;1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep &amp;quot;requests/sec&amp;quot; -A 999`&lt;br /&gt;
	else&lt;br /&gt;
		cmdapache=`lynx --dump http://localhost/server-status 2&amp;gt;&amp;amp;1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep &amp;quot;requests/sec&amp;quot; -A 999`&lt;br /&gt;
	fi&lt;br /&gt;
	if [[ $cmdapache != &amp;quot;&amp;quot; ]]&lt;br /&gt;
	then&lt;br /&gt;
		wcapache=`echo &amp;quot;$cmdapache&amp;quot; | wc -l`&lt;br /&gt;
	else&lt;br /&gt;
		wcapache=0&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function calclines {&lt;br /&gt;
	nline=`tput lines | awk '{print int(($1 - 14) / 3)}'`&lt;br /&gt;
	aline=`echo $nline 3 | awk '{print $1 + $2}'`&lt;br /&gt;
	if [ $nline -gt $wcmysql ]&lt;br /&gt;
	then&lt;br /&gt;
		nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function addseperator {&lt;br /&gt;
	printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
checkmysql&lt;br /&gt;
checkapache&lt;br /&gt;
calclines&lt;br /&gt;
&lt;br /&gt;
top -c -b -n 1 | grep -v &amp;quot;grep&amp;quot; | grep &amp;quot;PID&amp;quot; -A $nline&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ $wcmysql -gt 0 ]&lt;br /&gt;
then&lt;br /&gt;
	addseperator&lt;br /&gt;
	echo &amp;quot;$cmdmysql&amp;quot; | head -$nline&lt;br /&gt;
fi&lt;br /&gt;
if [ $wcapache -gt 0 ]&lt;br /&gt;
then&lt;br /&gt;
	addseperator&lt;br /&gt;
	echo &amp;quot;$cmdapache&amp;quot; | head -$aline&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=95</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=95"/>
				<updated>2011-05-20T15:40:26Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
Auto adjusts output based on size of the terminal.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
function checkmysql {&lt;br /&gt;
	cmdmysql=`mysql --batch -e 'show processlist;' | grep -v &amp;quot;Id&amp;quot; | cut -f6,5,4,8 | sed -e 's/\t/ /g' | sort -nr --key=3 | sed -e 's/ /\|/' -e 's/ /\|/' -e 's/ /\|/' -e 's/ /\|/' | awk 'BEGIN {FS=&amp;quot;|&amp;quot;}; { printf &amp;quot;%-4s%-15s%-8s%-30s&amp;quot;,$3,$1,$2,$4; print &amp;quot;&amp;quot; }'`&lt;br /&gt;
	if [[ $cmdmysql != &amp;quot;&amp;quot; ]]&lt;br /&gt;
	then&lt;br /&gt;
		wcmysql=`echo &amp;quot;$cmdmysql&amp;quot; | wc -l`&lt;br /&gt;
	else&lt;br /&gt;
		wcmysql=0&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function checkapache {&lt;br /&gt;
	if [ -d &amp;quot;/var/cpanel&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		cmdapache=`httpd status 2&amp;gt;&amp;amp;1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep &amp;quot;requests/sec&amp;quot; -A 999`&lt;br /&gt;
	else&lt;br /&gt;
		cmdapache=`lynx --dump http://localhost/server-status 2&amp;gt;&amp;amp;1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep &amp;quot;requests/sec&amp;quot; -A 999`&lt;br /&gt;
	fi&lt;br /&gt;
	if [[ $cmdapache != &amp;quot;&amp;quot; ]]&lt;br /&gt;
	then&lt;br /&gt;
		wcapache=`echo &amp;quot;$cmdapache&amp;quot; | wc -l`&lt;br /&gt;
	else&lt;br /&gt;
		wcapache=0&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function calclines {&lt;br /&gt;
	nline=`tput lines | awk '{print int(($1 - 14) / 3)}'`&lt;br /&gt;
	aline=`echo $nline 3 | awk '{print $1 + $2}'`&lt;br /&gt;
	if [ $nline -gt $wcmysql ]&lt;br /&gt;
	then&lt;br /&gt;
		nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function addseperator {&lt;br /&gt;
	printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
checkmysql&lt;br /&gt;
checkapache&lt;br /&gt;
calclines&lt;br /&gt;
&lt;br /&gt;
top -c -b -n 1 | grep -v &amp;quot;grep&amp;quot; | grep &amp;quot;PID&amp;quot; -A $nline&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ $wcmysql -gt 0 ]&lt;br /&gt;
then&lt;br /&gt;
	addseperator&lt;br /&gt;
	echo &amp;quot;$cmdmysql&amp;quot; | head -$nline&lt;br /&gt;
fi&lt;br /&gt;
if [ $wcapache -gt 0 ]&lt;br /&gt;
then&lt;br /&gt;
	addseperator&lt;br /&gt;
	echo &amp;quot;$cmdapache&amp;quot; | head -$aline&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=View_Domlogs_for_top_visitors&amp;diff=94</id>
		<title>View Domlogs for top visitors</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=View_Domlogs_for_top_visitors&amp;diff=94"/>
				<updated>2011-05-19T18:09:37Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* What to change */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Enter a partial date string to get top visitors during that period. Will also return site and all user agents that IP has used.&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
===Standard===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]echo &amp;quot;Date String [31/Mar/2011:13:4]&amp;quot;; read datestring; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Auto Date===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n] datestring=`date | awk '{print $3 &amp;quot;/&amp;quot; $2 &amp;quot;/&amp;quot; $6 &amp;quot;:&amp;quot; $4}' | sed 's/....$//'`; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Auto Date (Minus 10m)===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n] datestring=`date -d &amp;quot;10 min ago&amp;quot; | awk '{print $3 &amp;quot;/&amp;quot; $2 &amp;quot;/&amp;quot; $6 &amp;quot;:&amp;quot; $4}' | sed 's/....$//'`; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
Datestring&lt;br /&gt;
&lt;br /&gt;
The less information you put in to this the wider the search area.&lt;br /&gt;
&lt;br /&gt;
31/Mar/2011:13:4 will return 13:40 - 13:49&lt;br /&gt;
&lt;br /&gt;
31/Mar/2011:13 will return 13:00 - 13:59&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also the auto date (minus 10m) can be changed to go back a certain amount of time.&lt;br /&gt;
&lt;br /&gt;
By default this still only shows a 10 minute period.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=View_Domlogs_for_top_visitors&amp;diff=93</id>
		<title>View Domlogs for top visitors</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=View_Domlogs_for_top_visitors&amp;diff=93"/>
				<updated>2011-05-19T17:51:35Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* What to change */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Enter a partial date string to get top visitors during that period. Will also return site and all user agents that IP has used.&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
===Standard===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]echo &amp;quot;Date String [31/Mar/2011:13:4]&amp;quot;; read datestring; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Auto Date===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n] datestring=`date | awk '{print $3 &amp;quot;/&amp;quot; $2 &amp;quot;/&amp;quot; $6 &amp;quot;:&amp;quot; $4}' | sed 's/....$//'`; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Auto Date (Minus 10m)===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n] datestring=`date -d &amp;quot;10 min ago&amp;quot; | awk '{print $3 &amp;quot;/&amp;quot; $2 &amp;quot;/&amp;quot; $6 &amp;quot;:&amp;quot; $4}' | sed 's/....$//'`; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
Datestring&lt;br /&gt;
&lt;br /&gt;
The less information you put in to this the wider the search area.&lt;br /&gt;
&lt;br /&gt;
31/Mar/2011:13:4 will return 13:40 - 13:49&lt;br /&gt;
&lt;br /&gt;
31/Mar/2011:13 will return 13:00 - 13:59&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Hacker_Term_Search&amp;diff=92</id>
		<title>Hacker Term Search</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Hacker_Term_Search&amp;diff=92"/>
				<updated>2011-05-19T12:47:04Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: Created page with &amp;quot;==Overview== Simple find statement coupled with a grep statement. Will return path of any file containing these terms.    ==Script==  &amp;lt;code&amp;gt;[bash,n] find /home*/ -type f -name &amp;quot;*...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Simple find statement coupled with a grep statement. Will return path of any file containing these terms. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
find /home*/ -type f -name &amp;quot;*.htm*&amp;quot; -o -type f -name &amp;quot;*.php&amp;quot; -print0 | xargs -0 grep -il &amp;quot;hacked by\|script kitten&amp;quot; &amp;gt;&amp;gt; malware_hits.txt&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
Change the terms in the grep statement.&lt;br /&gt;
&lt;br /&gt;
Hacked by is the most common, Kittens use the same terms on all of their pages. No need to be original.&lt;br /&gt;
&lt;br /&gt;
Additional terms can be added if looking for a specific hacker group.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=91</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=91"/>
				<updated>2011-05-19T12:43:26Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Scripts (one liners) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Knowledge==&lt;br /&gt;
[[Monitorix Install cPanel]]&lt;br /&gt;
&lt;br /&gt;
==Scripts (one liners)==&lt;br /&gt;
[[Add PHP.ini to user directory]]&lt;br /&gt;
&lt;br /&gt;
[[DOS IP with local port]]&lt;br /&gt;
&lt;br /&gt;
[[Find all backups for user]]&lt;br /&gt;
&lt;br /&gt;
[[Get status of MalDet hits]]&lt;br /&gt;
&lt;br /&gt;
[[View Domlogs for top visitors]]&lt;br /&gt;
&lt;br /&gt;
[[Hacker Term Search]]&lt;br /&gt;
&lt;br /&gt;
==Programs (more then one line)==&lt;br /&gt;
[[SwapClean]]&lt;br /&gt;
&lt;br /&gt;
[[errornotify]]&lt;br /&gt;
&lt;br /&gt;
[[ministat]]&lt;br /&gt;
&lt;br /&gt;
==Greasy Monkey (GreaseMonkey Scripts)==&lt;br /&gt;
[[HD Button Remove]]&lt;br /&gt;
&lt;br /&gt;
[[Not So Important]]&lt;br /&gt;
&lt;br /&gt;
[[Side Bar Color Fixer]]&lt;br /&gt;
&lt;br /&gt;
==Misc Script Fu==&lt;br /&gt;
[[count*.gif? detection and removal]]&lt;br /&gt;
&lt;br /&gt;
==Scripts by Others==&lt;br /&gt;
[[MySQL Memory Usage]]&lt;br /&gt;
&lt;br /&gt;
[[MySQL Memory Usage Verbose]]&lt;br /&gt;
&lt;br /&gt;
==Solutions (Multi Step)==&lt;br /&gt;
&lt;br /&gt;
[[MySQL Import Progress]]&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=90</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=90"/>
				<updated>2011-05-18T13:30:01Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
Auto adjusts output based on size of the terminal.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
function checkmysql {&lt;br /&gt;
	cmdmysql=`mysqladmin proc stat 2&amp;gt;&amp;amp;1 | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | awk 'BEGIN{FS=&amp;quot;|&amp;quot;};{print $7,$6,$9}' | sort -n`&lt;br /&gt;
	wcmysql=`echo $cmdmysql | wc -l`&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function checkapache {&lt;br /&gt;
	if [ -d &amp;quot;/var/cpanel&amp;quot; ]&lt;br /&gt;
	then&lt;br /&gt;
		httpd status 2&amp;gt;&amp;amp;1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep &amp;quot;requests/sec&amp;quot; -A $aline&lt;br /&gt;
	else&lt;br /&gt;
		lynx --dump http://localhost/server-status 2&amp;gt;&amp;amp;1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep &amp;quot;requests/sec&amp;quot; -A $aline&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function calclines {&lt;br /&gt;
	nline=`tput lines | awk '{print int(($1 - 14) / 3)}'`&lt;br /&gt;
	aline=`echo $nline 3 | awk '{print $1 + $2}'`&lt;br /&gt;
	if [ $nline -gt $wcmysql ]&lt;br /&gt;
	then&lt;br /&gt;
		nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function addseperator {&lt;br /&gt;
	printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
checkmysql&lt;br /&gt;
calclines&lt;br /&gt;
&lt;br /&gt;
top -c -b -n 1 | grep -v &amp;quot;grep&amp;quot; | grep &amp;quot;PID&amp;quot; -A $nline&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
echo $cmdmysql | head -$nline&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
checkapache&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=89</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=89"/>
				<updated>2011-05-18T13:00:08Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
Auto adjusts output based on size of the terminal.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
function checkmysql {&lt;br /&gt;
	cmdmysql=`mysqladmin proc stat 2&amp;gt;&amp;amp;1 | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | awk 'BEGIN{FS=&amp;quot;|&amp;quot;};{print $7,$6,$9}' | sort -n`&lt;br /&gt;
	wcmysql=`echo $cmdmysql | wc -l`&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function checkapache {&lt;br /&gt;
	httpd status 2&amp;gt;&amp;amp;1 | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function calclines {&lt;br /&gt;
	nline=`tput lines | awk '{print int(($1 - 18) / 2)}'`&lt;br /&gt;
	if [ $nline -gt $wcmysql ]&lt;br /&gt;
	then&lt;br /&gt;
		nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
	fi&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
function addseperator {&lt;br /&gt;
	printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
	return&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
checkmysql&lt;br /&gt;
calclines&lt;br /&gt;
&lt;br /&gt;
top -c -b -n 1 | grep -v &amp;quot;grep&amp;quot; | grep &amp;quot;PID&amp;quot; -A $nline&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
echo $cmdmysql | head -$nline&lt;br /&gt;
addseperator&lt;br /&gt;
&lt;br /&gt;
httpd status 2&amp;gt;&amp;amp;1 | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=88</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=88"/>
				<updated>2011-05-17T18:39:47Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
Auto adjusts output based on size of the terminal.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
cmdmysql=`mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | awk 'BEGIN{FS=&amp;quot;|&amp;quot;};{print $7,$6,$9}' | sort -n`&lt;br /&gt;
&lt;br /&gt;
wcmysql=`echo $cmdmysql | wc -l`&lt;br /&gt;
&lt;br /&gt;
nline=`tput lines | awk '{print int(($1 - 18) / 2)}'`&lt;br /&gt;
if [ $nline -gt $wcmysql ] &lt;br /&gt;
then&lt;br /&gt;
  nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#Display Junk&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | grep -v &amp;quot;grep&amp;quot; | grep &amp;quot;PID&amp;quot; -A $nline&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
echo $cmdmysql | head -$nline&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=87</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=87"/>
				<updated>2011-05-17T18:29:22Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
Auto adjusts output based on size of the terminal.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
cmdtop=`top -c -b -n 1 | grep &amp;quot;PID&amp;quot; -A999`&lt;br /&gt;
cmdmysql=`mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | awk 'BEGIN{FS=&amp;quot;|&amp;quot;};{print $7,$6,$9}' | sort -n`&lt;br /&gt;
&lt;br /&gt;
wctop=`echo $cmdtop | wc -l`&lt;br /&gt;
wcmysql=`echo $cmdmysql | wc -l`&lt;br /&gt;
&lt;br /&gt;
nline=`tput lines | awk '{print int(($1 - 18) / 2)}'`&lt;br /&gt;
if [ $nline -gt $wcmysql ] &lt;br /&gt;
then&lt;br /&gt;
  nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#Display Junk&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | grep &amp;quot;PID&amp;quot; -A999 | head -$nline&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
echo $cmdmysql | head -$nline&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=86</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=86"/>
				<updated>2011-05-17T18:28:52Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
cmdtop=`top -c -b -n 1 | grep &amp;quot;PID&amp;quot; -A999`&lt;br /&gt;
cmdmysql=`mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | awk 'BEGIN{FS=&amp;quot;|&amp;quot;};{print $7,$6,$9}' | sort -n`&lt;br /&gt;
&lt;br /&gt;
wctop=`echo $cmdtop | wc -l`&lt;br /&gt;
wcmysql=`echo $cmdmysql | wc -l`&lt;br /&gt;
&lt;br /&gt;
nline=`tput lines | awk '{print int(($1 - 18) / 2)}'`&lt;br /&gt;
if [ $nline -gt $wcmysql ] &lt;br /&gt;
then&lt;br /&gt;
  nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#Display Junk&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | grep &amp;quot;PID&amp;quot; -A999 | head -$nline&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
echo $cmdmysql | head -$nline&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=85</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=85"/>
				<updated>2011-05-17T18:19:41Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
cmdtop=`top -c -b -n 1 | grep &amp;quot;PID&amp;quot; -A999`&lt;br /&gt;
cmdmysql=`mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | awk '{FS=&amp;quot;|&amp;quot;};{print $7,$6,$9}' | sort -n`&lt;br /&gt;
&lt;br /&gt;
wctop=`echo $cmdtop | wc -l`&lt;br /&gt;
wcmysql=`echo $cmdmysql | wc -l`&lt;br /&gt;
&lt;br /&gt;
nline=`tput lines | awk '{print int(($1 - 18) / 2)}'`&lt;br /&gt;
if [ $nline -gt $wcmysql ] &lt;br /&gt;
then&lt;br /&gt;
  nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#Display Junk&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | grep &amp;quot;PID&amp;quot; -A999 | head -$nline&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
echo $cmdmysql | head -$nline&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=84</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=84"/>
				<updated>2011-05-17T17:30:59Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | head -12 | tail -3&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot;  | awk 'BEGIN {FS=&amp;quot;|&amp;quot;};{print $7,$6,$9}' | sort -n | head -3&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=83</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=83"/>
				<updated>2011-05-17T17:21:19Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | head -12 | tail -3&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | grep -v &amp;quot;processlist&amp;quot; | cut -d &amp;quot;|&amp;quot; -f7,9 | sed &amp;quot;s/ //g&amp;quot; | sort -n | head -3 &lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=82</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=82"/>
				<updated>2011-05-17T17:05:15Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | head -12 | tail -3&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | grep -v &amp;quot;processlist&amp;quot; | cut -d &amp;quot;|&amp;quot; -f7,9 | sed &amp;quot;s/ //g&amp;quot; | sort -n | head -3 &lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free | grep -v &amp;quot;cache:&amp;quot;&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | grep &amp;quot;requests/sec&amp;quot; -A6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=81</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=81"/>
				<updated>2011-05-17T16:40:16Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | head -12 | tail -5&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | grep -v &amp;quot;show processlist&amp;quot; | cut -d &amp;quot;|&amp;quot; -f7,9 | sed &amp;quot;s/ //g&amp;quot; | sort -n | head &lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | head -23 | tail -7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=80</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=80"/>
				<updated>2011-05-17T16:37:36Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | head -12 | tail -5&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
mysqladmin proc stat | grep &amp;quot;|&amp;quot; | grep -v &amp;quot;Id&amp;quot; | grep -v &amp;quot;show processlist&amp;quot; | cut -d &amp;quot;|&amp;quot; -f7,9 | sed &amp;quot;s/ //g&amp;quot; | sort -n | head &lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | head -23 | tail -7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=View_Domlogs_for_top_visitors&amp;diff=79</id>
		<title>View Domlogs for top visitors</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=View_Domlogs_for_top_visitors&amp;diff=79"/>
				<updated>2011-05-17T16:09:21Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Auto Date */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Enter a partial date string to get top visitors during that period. Will also return site and all user agents that IP has used.&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
===Standard===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]echo &amp;quot;Date String [31/Mar/2011:13:4]&amp;quot;; read datestring; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Auto Date===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n] datestring=`date | awk '{print $3 &amp;quot;/&amp;quot; $2 &amp;quot;/&amp;quot; $6 &amp;quot;:&amp;quot; $4}' | sed 's/....$//'`; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Auto Date (Minus 10m)===&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n] datestring=`date -d &amp;quot;10 min ago&amp;quot; | awk '{print $3 &amp;quot;/&amp;quot; $2 &amp;quot;/&amp;quot; $6 &amp;quot;:&amp;quot; $4}' | sed 's/....$//'`; \&lt;br /&gt;
for i in $(grep $datestring /usr/local/apache/domlogs/* | awk {'print $1'} | sort | uniq -c | sort -n | sed -e 's/^[ \t]*//' | awk '{print $1 &amp;quot;:&amp;quot; $2}' | tail -10); \&lt;br /&gt;
 do count=`echo $i | cut -d: -f1`; \&lt;br /&gt;
 ip=`echo $i | cut -d: -f3`; \&lt;br /&gt;
 domain=`echo $i | cut -d: -f2`; \&lt;br /&gt;
 agent=`grep $datestring $domain | grep $ip | cut -d '&amp;quot;' -f6 | sort | uniq -c | sort -n | awk {'print &amp;quot;\n\t&amp;quot; $0'}` ; \&lt;br /&gt;
 echo -e &amp;quot;$count $ip $domain $agent&amp;quot;; done &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=78</id>
		<title>Ministat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Ministat&amp;diff=78"/>
				<updated>2011-05-17T14:41:41Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: Created page with &amp;quot;==Overview== Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.  Useful for monitoring a server that is having p...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.&lt;br /&gt;
&lt;br /&gt;
Useful for monitoring a server that is having problems.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
cat /proc/loadavg&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
top -c -b -n 1 | head -12 | tail -5&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
mysqladmin proc stat | grep &amp;quot;Query&amp;quot; | cut -d &amp;quot;|&amp;quot; -f7,9 | sed &amp;quot;s/ //g&amp;quot; | sort -n | head &lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
free&lt;br /&gt;
printf &amp;quot;%$(tput cols)s\n&amp;quot;|tr ' ' '='&lt;br /&gt;
httpd status | head -23 | tail -7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch sh ministat; rm -f ministat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=77</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=77"/>
				<updated>2011-05-17T14:34:04Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Programs (more then one line) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Knowledge==&lt;br /&gt;
[[Monitorix Install cPanel]]&lt;br /&gt;
&lt;br /&gt;
==Scripts (one liners)==&lt;br /&gt;
[[Add PHP.ini to user directory]]&lt;br /&gt;
&lt;br /&gt;
[[DOS IP with local port]]&lt;br /&gt;
&lt;br /&gt;
[[Find all backups for user]]&lt;br /&gt;
&lt;br /&gt;
[[Get status of MalDet hits]]&lt;br /&gt;
&lt;br /&gt;
[[View Domlogs for top visitors]]&lt;br /&gt;
&lt;br /&gt;
==Programs (more then one line)==&lt;br /&gt;
[[SwapClean]]&lt;br /&gt;
&lt;br /&gt;
[[errornotify]]&lt;br /&gt;
&lt;br /&gt;
[[ministat]]&lt;br /&gt;
&lt;br /&gt;
==Greasy Monkey (GreaseMonkey Scripts)==&lt;br /&gt;
[[HD Button Remove]]&lt;br /&gt;
&lt;br /&gt;
[[Not So Important]]&lt;br /&gt;
&lt;br /&gt;
[[Side Bar Color Fixer]]&lt;br /&gt;
&lt;br /&gt;
==Misc Script Fu==&lt;br /&gt;
[[count*.gif? detection and removal]]&lt;br /&gt;
&lt;br /&gt;
==Scripts by Others==&lt;br /&gt;
[[MySQL Memory Usage]]&lt;br /&gt;
&lt;br /&gt;
[[MySQL Memory Usage Verbose]]&lt;br /&gt;
&lt;br /&gt;
==Solutions (Multi Step)==&lt;br /&gt;
&lt;br /&gt;
[[MySQL Import Progress]]&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Import_Progress&amp;diff=72</id>
		<title>MySQL Import Progress</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Import_Progress&amp;diff=72"/>
				<updated>2011-05-04T19:51:11Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Step 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Needed a progress indicator for an excessively long MySQL import. &lt;br /&gt;
&lt;br /&gt;
Created this down and dirty solution to give a very buggy inaccurate look at the progress.&lt;br /&gt;
&lt;br /&gt;
Expect lots of errors as I have no error checking in here. &lt;br /&gt;
&lt;br /&gt;
Its accurate at least once per table.&lt;br /&gt;
&lt;br /&gt;
==Step 1==&lt;br /&gt;
Populate table counts&lt;br /&gt;
&lt;br /&gt;
ID will need to be changed for what ever their autoinc field is. Will not work with non numeric values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
for i in $(mysql &amp;lt;DATABASE&amp;gt; --batch -e 'show tables;' | grep -v &amp;quot;Tables_in&amp;quot;); do lastrecord=`mysql &amp;lt;DATABASE&amp;gt; --batch -e 'select id from '$i' order by id desc limit 1'|grep -v id`; echo &amp;quot;$i,$lastrecord&amp;quot; &amp;gt;&amp;gt; tablecounts.txt; done&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Step 2==&lt;br /&gt;
Run code and watch the bugs fly&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
currentcommand=`mysql --batch -e 'show processlist' | grep INSERT | head -1`&lt;br /&gt;
currenttable=`echo $currentcommand | cut -d '\`' -f2`&lt;br /&gt;
currentrecord=`echo $currentcommand | cut -d &amp;quot;(&amp;quot; -f2 | cut -d &amp;quot;,&amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
recordcount=`cat tablecounts.txt | grep &amp;quot;^$currenttable,&amp;quot; | cut -d &amp;quot;,&amp;quot; -f2`&lt;br /&gt;
&lt;br /&gt;
currentpercent=`echo $currentrecord $recordcount | awk '{print $1 / $2*100}'`&lt;br /&gt;
&lt;br /&gt;
#if [$currenttable -eq &amp;quot;&amp;quot;]&lt;br /&gt;
#then&lt;br /&gt;
#	echo &amp;quot;no table being imported&amp;quot;&lt;br /&gt;
#else&lt;br /&gt;
	echo &amp;quot;$currenttable $currentrecord / $recordcount ($currentpercent)&amp;quot;&lt;br /&gt;
#fi&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
Really need a better solution in the future. But this works for what we needed at the time.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Import_Progress&amp;diff=71</id>
		<title>MySQL Import Progress</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Import_Progress&amp;diff=71"/>
				<updated>2011-05-04T19:42:43Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Step 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Needed a progress indicator for an excessively long MySQL import. &lt;br /&gt;
&lt;br /&gt;
Created this down and dirty solution to give a very buggy inaccurate look at the progress.&lt;br /&gt;
&lt;br /&gt;
Expect lots of errors as I have no error checking in here. &lt;br /&gt;
&lt;br /&gt;
Its accurate at least once per table.&lt;br /&gt;
&lt;br /&gt;
==Step 1==&lt;br /&gt;
Populate table counts&lt;br /&gt;
&lt;br /&gt;
ID will need to be changed for what ever their autoinc field is. Will not work with non numeric values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
for i in $(mysql &amp;lt;DATABASE&amp;gt; --batch -e 'show tables;' | grep -v &amp;quot;Tables_in&amp;quot;); do lastrecord=`mysql &amp;lt;DATABASE&amp;gt; --batch -e 'select id from '$i' order by id desc limit 1'|grep -v id`; echo &amp;quot;$i,$lastrecord&amp;quot; &amp;gt;&amp;gt; tablecounts.txt; done&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Step 2==&lt;br /&gt;
Run code and watch the bugs fly&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
currentcommand=`mysqladmin processlist | grep INSERT | head -1`&lt;br /&gt;
currenttable=`echo $currentcommand | cut -d '\`' -f2`&lt;br /&gt;
currentrecord=`echo $currentcommand | cut -d &amp;quot;(&amp;quot; -f2 | cut -d &amp;quot;,&amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
recordcount=`cat tablecounts.txt | grep &amp;quot;$currenttable,&amp;quot; | cut -d &amp;quot;,&amp;quot; -f2`&lt;br /&gt;
&lt;br /&gt;
currentpercent=`echo $currentrecord $recordcount | awk '{print $1 / $2*100}'`&lt;br /&gt;
echo &amp;quot;$currenttable $currentrecord / $recordcount ($currentpercent)&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
Really need a better solution in the future. But this works for what we needed at the time.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Import_Progress&amp;diff=70</id>
		<title>MySQL Import Progress</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Import_Progress&amp;diff=70"/>
				<updated>2011-05-04T19:32:03Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: Created page with &amp;quot;==Overview==  Needed a progress indicator for an excessively long MySQL import.   Created this down and dirty solution to give a very buggy inaccurate look at the progress.  Expe...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Needed a progress indicator for an excessively long MySQL import. &lt;br /&gt;
&lt;br /&gt;
Created this down and dirty solution to give a very buggy inaccurate look at the progress.&lt;br /&gt;
&lt;br /&gt;
Expect lots of errors as I have no error checking in here. &lt;br /&gt;
&lt;br /&gt;
Its accurate at least once per table.&lt;br /&gt;
&lt;br /&gt;
==Step 1==&lt;br /&gt;
Populate table counts&lt;br /&gt;
&lt;br /&gt;
ID will need to be changed for what ever their autoinc field is. Will not work with non numeric values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
for i in $(mysql &amp;lt;DATABASE&amp;gt; --batch -e 'show tables;' | grep -v &amp;quot;Tables_in&amp;quot;); do lastrecord=`mysql &amp;lt;DATABASE&amp;gt; --batch -e 'select id from '$i' order by id desc limit 1'|grep -v id`; echo &amp;quot;$i,$lastrecord&amp;quot; &amp;gt;&amp;gt; tablecounts.txt; done&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Step 2==&lt;br /&gt;
Run code and watch the bugs fly&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
currentcommand=`mysqladmin processlist | grep INSERT`&lt;br /&gt;
currenttable=`echo $currentcommand | cut -d '\`' -f2`&lt;br /&gt;
currentrecord=`echo $currentcommand | cut -d &amp;quot;(&amp;quot; -f2 | cut -d &amp;quot;,&amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
recordcount=`cat tablecounts.txt | grep &amp;quot;$currenttable,&amp;quot; | cut -d &amp;quot;,&amp;quot; -f2`&lt;br /&gt;
&lt;br /&gt;
currentpercent=`echo $currentrecord $recordcount | awk '{print $1 / $2*100}'`&lt;br /&gt;
echo &amp;quot;$currenttable $currentrecord / $recordcount ($currentpercent)&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
Really need a better solution in the future. But this works for what we needed at the time.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=69</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=69"/>
				<updated>2011-05-04T19:27:19Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Scripts by Others */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Knowledge==&lt;br /&gt;
[[Monitorix Install cPanel]]&lt;br /&gt;
&lt;br /&gt;
==Scripts (one liners)==&lt;br /&gt;
[[Add PHP.ini to user directory]]&lt;br /&gt;
&lt;br /&gt;
[[DOS IP with local port]]&lt;br /&gt;
&lt;br /&gt;
[[Find all backups for user]]&lt;br /&gt;
&lt;br /&gt;
[[Get status of MalDet hits]]&lt;br /&gt;
&lt;br /&gt;
[[View Domlogs for top visitors]]&lt;br /&gt;
&lt;br /&gt;
==Programs (more then one line)==&lt;br /&gt;
[[SwapClean]]&lt;br /&gt;
&lt;br /&gt;
[[errornotify]]&lt;br /&gt;
&lt;br /&gt;
==Greasy Monkey (GreaseMonkey Scripts)==&lt;br /&gt;
[[HD Button Remove]]&lt;br /&gt;
&lt;br /&gt;
[[Not So Important]]&lt;br /&gt;
&lt;br /&gt;
==Misc Script Fu==&lt;br /&gt;
[[count*.gif? detection and removal]]&lt;br /&gt;
&lt;br /&gt;
==Scripts by Others==&lt;br /&gt;
[[MySQL Memory Usage]]&lt;br /&gt;
&lt;br /&gt;
[[MySQL Memory Usage Verbose]]&lt;br /&gt;
&lt;br /&gt;
==Solutions (Multi Step)==&lt;br /&gt;
&lt;br /&gt;
[[MySQL Import Progress]]&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=HD_Button_Remove&amp;diff=68</id>
		<title>HD Button Remove</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=HD_Button_Remove&amp;diff=68"/>
				<updated>2011-05-04T13:03:42Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Cleans up HD keyword button clutter.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[javascript,n]&lt;br /&gt;
// ==UserScript==&lt;br /&gt;
// @name           Button Remover&lt;br /&gt;
// @namespace      http://jamesdooley.us&lt;br /&gt;
// @description    Get rid of button clutter&lt;br /&gt;
// @include        https://adminhd.liquidweb.com*/msgs/*&lt;br /&gt;
// @include        https://hd.int.liquidweb.com*/msgs/*&lt;br /&gt;
// ==/UserScript==&lt;br /&gt;
&lt;br /&gt;
//List of buttons by value to remove&lt;br /&gt;
var btnlist = new Array(&amp;quot;besteffort&amp;quot;,&amp;quot;document_this&amp;quot;,&amp;quot;escalations&amp;quot;,&amp;quot;resolver-changed&amp;quot;,&amp;quot;storm&amp;quot;,&amp;quot;support_handoff&amp;quot;,&amp;quot;terminations&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
var hdbutton = document.getElementsByTagName('button');&lt;br /&gt;
for (var i=0; i &amp;lt; hdbutton.length; i++) {&lt;br /&gt;
	btnremove(hdbutton[i].getAttribute('value'))&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function btnremove (btnvalue){&lt;br /&gt;
	for (var b=0; b &amp;lt; btnlist.length; b++) {&lt;br /&gt;
		if (btnvalue==btnlist[b]) {&lt;br /&gt;
			var style = hdbutton[i].style;&lt;br /&gt;
			style.display = 'none';&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return false;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
btnlist contains a list of buttons you wish to remove. The value is the text that is displayed on the button.&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=67</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=Main_Page&amp;diff=67"/>
				<updated>2011-05-03T16:18:14Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Scripts by Others */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Knowledge==&lt;br /&gt;
[[Monitorix Install cPanel]]&lt;br /&gt;
&lt;br /&gt;
==Scripts (one liners)==&lt;br /&gt;
[[Add PHP.ini to user directory]]&lt;br /&gt;
&lt;br /&gt;
[[DOS IP with local port]]&lt;br /&gt;
&lt;br /&gt;
[[Find all backups for user]]&lt;br /&gt;
&lt;br /&gt;
[[Get status of MalDet hits]]&lt;br /&gt;
&lt;br /&gt;
[[View Domlogs for top visitors]]&lt;br /&gt;
&lt;br /&gt;
==Programs (more then one line)==&lt;br /&gt;
[[SwapClean]]&lt;br /&gt;
&lt;br /&gt;
[[errornotify]]&lt;br /&gt;
&lt;br /&gt;
==Greasy Monkey (GreaseMonkey Scripts)==&lt;br /&gt;
[[HD Button Remove]]&lt;br /&gt;
&lt;br /&gt;
[[Not So Important]]&lt;br /&gt;
&lt;br /&gt;
==Misc Script Fu==&lt;br /&gt;
[[count*.gif? detection and removal]]&lt;br /&gt;
&lt;br /&gt;
==Scripts by Others==&lt;br /&gt;
[[MySQL Memory Usage]]&lt;br /&gt;
&lt;br /&gt;
[[MySQL Memory Usage Verbose]]&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=66</id>
		<title>MySQL Memory Usage</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=66"/>
				<updated>2011-05-03T15:07:44Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Perl script to calculate MySQL max memory allotment. &lt;br /&gt;
&lt;br /&gt;
Modified original code to search for cPanel defaults.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[perl,n]&lt;br /&gt;
    #!/usr/bin/perl&lt;br /&gt;
    #&lt;br /&gt;
    # calculate mysqld memory consumption from my.cnf&lt;br /&gt;
    # usage: mysql-memory-usage /path/to/my.cnf [/path/to/mysqld]&lt;br /&gt;
    #&lt;br /&gt;
    # $Id: mysql-memory-usage 228 2010-05-31 10:53:33Z schwenke $&lt;br /&gt;
     &lt;br /&gt;
    my $mycnf= shift;&lt;br /&gt;
    $mycnf= &amp;quot;/etc/my.cnf&amp;quot; unless $mycnf;&lt;br /&gt;
    die &amp;quot;cannot read $mycnf\n&amp;quot; unless (-r $mycnf);&lt;br /&gt;
     &lt;br /&gt;
    my $mysqld= shift;&lt;br /&gt;
    unless ($mysqld) {&lt;br /&gt;
    # find mysqld relative to mysql&lt;br /&gt;
    $mysqld= `which mysqld` or $mysqld= `which mysql` or die;&lt;br /&gt;
    chomp $mysqld;&lt;br /&gt;
    $mysqld =~ s(bin/mysql$)(libexec/mysqld);&lt;br /&gt;
    }&lt;br /&gt;
    die &amp;quot;cannot execute $mysqld\n&amp;quot; unless (-x $mysqld);&lt;br /&gt;
     &lt;br /&gt;
    # read configuration&lt;br /&gt;
    my %conf;&lt;br /&gt;
    open M, &amp;quot;$mysqld --defaults-file=$mycnf --help --verbose |&amp;quot; or die;&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) { # skip to parameter list&lt;br /&gt;
    last if (/^\-{5,} \-{5,}$/o);&lt;br /&gt;
    }&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) {&lt;br /&gt;
    last if /^$/o;&lt;br /&gt;
    my ($var, $val)= split;&lt;br /&gt;
    $conf{$var}= $val;&lt;br /&gt;
    }&lt;br /&gt;
    close M;&lt;br /&gt;
     &lt;br /&gt;
    # static memory consumption&lt;br /&gt;
    my $static= $conf{'key_buffer_size'} + $conf{'query_cache_size'};&lt;br /&gt;
    # has innodb&lt;br /&gt;
    $static+= $conf{'innodb-buffer-pool-size'} + $conf{'innodb-log-buffer-size'}&lt;br /&gt;
    + $conf{'innodb-additional-mem-pool-size'} if (($conf{'innodb'} eq 'TRUE') or ($conf{'innodb'} eq 'ON'));&lt;br /&gt;
     &lt;br /&gt;
    # per thread memory consumption&lt;br /&gt;
    my $thread= $conf{'thread_stack'}&lt;br /&gt;
    + 2*$conf{'net_buffer_length'} + $conf{'read_buffer_size'}&lt;br /&gt;
    + $conf{'read_rnd_buffer_size'} + $conf{'sort_buffer_size'};&lt;br /&gt;
     &lt;br /&gt;
    # writes binlog&lt;br /&gt;
    $thread += $conf{'binlog_cache_size'} if ($conf{'log-bin'} ne '(No');&lt;br /&gt;
     &lt;br /&gt;
    # MyISAM repair thread(s)&lt;br /&gt;
    my $repair= 0;&lt;br /&gt;
    $repair+= $conf{'myisam_repair_threads'} * $conf{'myisam_sort_buffer_size'}&lt;br /&gt;
    if ($conf{'myisam-recover'} ne 'OFF');&lt;br /&gt;
     &lt;br /&gt;
    # Memory (HEAP) tables&lt;br /&gt;
    my $heaptables= $conf{'max_heap_table_size'};&lt;br /&gt;
     &lt;br /&gt;
    # temp. tables&lt;br /&gt;
    my $tmptables= min($conf{'tmp_table_size'}, $conf{'max_heap_table_size'});&lt;br /&gt;
     &lt;br /&gt;
    #&lt;br /&gt;
    # show result&lt;br /&gt;
    #&lt;br /&gt;
    print &amp;quot;$mysqld will use at most:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s for global stuff\n&amp;quot;, p($static);&lt;br /&gt;
    printf &amp;quot;%-10s per thread\n&amp;quot;, p($thread);&lt;br /&gt;
    printf &amp;quot;%-10s total (with %d active threads)\n&amp;quot;,&lt;br /&gt;
    p($static + $conf{'max_connections'}*$thread), $conf{'max_connections'};&lt;br /&gt;
    print &amp;quot;and additionally:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s while recovering MyISAM tables\n&amp;quot;, p($repair) if ($repair);&lt;br /&gt;
    printf &amp;quot;%-10s for each HEAP table\n&amp;quot;, p($heaptables);&lt;br /&gt;
    printf &amp;quot;%-10s for each temporary table\n&amp;quot;, p($tmptables);&lt;br /&gt;
    exit 0;&lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
    sub min {&lt;br /&gt;
    my ($a, $b)= @_;&lt;br /&gt;
    return $a &amp;lt;$b ? $a : $b;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    sub p {&lt;br /&gt;
    my $n= shift;&lt;br /&gt;
    my $prefix= 0;&lt;br /&gt;
    while ($n &amp;gt;= 1024 &amp;amp;&amp;amp; $prefix &amp;lt; 5) {&lt;br /&gt;
    $n/= 1024;&lt;br /&gt;
    $prefix++;&lt;br /&gt;
    }&lt;br /&gt;
    sprintf $prefix?&amp;quot;%.1f %s&amp;quot;:&amp;quot;%d %s&amp;quot;, $n, qw&amp;quot;Bytes KB MB GB TB&amp;quot;[$prefix];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/sqlmem -O - | perl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Default&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Defaults will use the cpanel default MySQL locations.&lt;br /&gt;
&lt;br /&gt;
Specify paths&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl [/path/to/my.cnf] [/path/to/mysqld]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
&lt;br /&gt;
Original code created by:&lt;br /&gt;
&lt;br /&gt;
Axel Schwenke:&lt;br /&gt;
&lt;br /&gt;
http://forge.mysql.com/tools/tool.php?id=266&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=65</id>
		<title>MySQL Memory Usage</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=65"/>
				<updated>2011-05-03T15:05:35Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Perl script to calculate MySQL max memory allotment. &lt;br /&gt;
&lt;br /&gt;
Modified original code to search for cPanel defaults.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[perl,n]&lt;br /&gt;
    #!/usr/bin/perl -w&lt;br /&gt;
    #&lt;br /&gt;
    # calculate mysqld memory consumption from my.cnf&lt;br /&gt;
    # usage: mysql-memory-usage /path/to/my.cnf [/path/to/mysqld]&lt;br /&gt;
    #&lt;br /&gt;
    # $Id: mysql-memory-usage 228 2010-05-31 10:53:33Z schwenke $&lt;br /&gt;
     &lt;br /&gt;
    my $mycnf= shift;&lt;br /&gt;
    $mycnf= &amp;quot;/etc/my.cnf&amp;quot; unless $mycnf;&lt;br /&gt;
    die &amp;quot;cannot read $mycnf\n&amp;quot; unless (-r $mycnf);&lt;br /&gt;
     &lt;br /&gt;
    my $mysqld= shift;&lt;br /&gt;
    unless ($mysqld) {&lt;br /&gt;
    # find mysqld relative to mysql&lt;br /&gt;
    $mysqld= `which mysqld` or $mysqld= `which mysql` or die;&lt;br /&gt;
    chomp $mysqld;&lt;br /&gt;
    $mysqld =~ s(bin/mysql$)(libexec/mysqld);&lt;br /&gt;
    }&lt;br /&gt;
    die &amp;quot;cannot execute $mysqld\n&amp;quot; unless (-x $mysqld);&lt;br /&gt;
     &lt;br /&gt;
    # read configuration&lt;br /&gt;
    my %conf;&lt;br /&gt;
    open M, &amp;quot;$mysqld --defaults-file=$mycnf --help --verbose |&amp;quot; or die;&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) { # skip to parameter list&lt;br /&gt;
    last if (/^\-{5,} \-{5,}$/o);&lt;br /&gt;
    }&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) {&lt;br /&gt;
    last if /^$/o;&lt;br /&gt;
    my ($var, $val)= split;&lt;br /&gt;
    $conf{$var}= $val;&lt;br /&gt;
    }&lt;br /&gt;
    close M;&lt;br /&gt;
     &lt;br /&gt;
    # static memory consumption&lt;br /&gt;
    my $static= $conf{'key_buffer_size'} + $conf{'query_cache_size'};&lt;br /&gt;
    # has innodb&lt;br /&gt;
    $static+= $conf{'innodb-buffer-pool-size'} + $conf{'innodb-log-buffer-size'}&lt;br /&gt;
    + $conf{'innodb-additional-mem-pool-size'} if (($conf{'innodb'} eq 'TRUE') or ($conf{'innodb'} eq 'ON'));&lt;br /&gt;
     &lt;br /&gt;
    # per thread memory consumption&lt;br /&gt;
    my $thread= $conf{'thread_stack'}&lt;br /&gt;
    + 2*$conf{'net_buffer_length'} + $conf{'read_buffer_size'}&lt;br /&gt;
    + $conf{'read_rnd_buffer_size'} + $conf{'sort_buffer_size'};&lt;br /&gt;
     &lt;br /&gt;
    # writes binlog&lt;br /&gt;
    $thread += $conf{'binlog_cache_size'} if ($conf{'log-bin'} ne '(No');&lt;br /&gt;
     &lt;br /&gt;
    # MyISAM repair thread(s)&lt;br /&gt;
    my $repair= 0;&lt;br /&gt;
    $repair+= $conf{'myisam_repair_threads'} * $conf{'myisam_sort_buffer_size'}&lt;br /&gt;
    if ($conf{'myisam-recover'} ne 'OFF');&lt;br /&gt;
     &lt;br /&gt;
    # Memory (HEAP) tables&lt;br /&gt;
    my $heaptables= $conf{'max_heap_table_size'};&lt;br /&gt;
     &lt;br /&gt;
    # temp. tables&lt;br /&gt;
    my $tmptables= min($conf{'tmp_table_size'}, $conf{'max_heap_table_size'});&lt;br /&gt;
     &lt;br /&gt;
    #&lt;br /&gt;
    # show result&lt;br /&gt;
    #&lt;br /&gt;
    print &amp;quot;$mysqld will use at most:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s for global stuff\n&amp;quot;, p($static);&lt;br /&gt;
    printf &amp;quot;%-10s per thread\n&amp;quot;, p($thread);&lt;br /&gt;
    printf &amp;quot;%-10s total (with %d active threads)\n&amp;quot;,&lt;br /&gt;
    p($static + $conf{'max_connections'}*$thread), $conf{'max_connections'};&lt;br /&gt;
    print &amp;quot;and additionally:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s while recovering MyISAM tables\n&amp;quot;, p($repair) if ($repair);&lt;br /&gt;
    printf &amp;quot;%-10s for each HEAP table\n&amp;quot;, p($heaptables);&lt;br /&gt;
    printf &amp;quot;%-10s for each temporary table\n&amp;quot;, p($tmptables);&lt;br /&gt;
    exit 0;&lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
    sub min {&lt;br /&gt;
    my ($a, $b)= @_;&lt;br /&gt;
    return $a &amp;lt;$b ? $a : $b;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    sub p {&lt;br /&gt;
    my $n= shift;&lt;br /&gt;
    my $prefix= 0;&lt;br /&gt;
    while ($n &amp;gt;= 1024 &amp;amp;&amp;amp; $prefix &amp;lt; 5) {&lt;br /&gt;
    $n/= 1024;&lt;br /&gt;
    $prefix++;&lt;br /&gt;
    }&lt;br /&gt;
    sprintf $prefix?&amp;quot;%.1f %s&amp;quot;:&amp;quot;%d %s&amp;quot;, $n, qw&amp;quot;Bytes KB MB GB TB&amp;quot;[$prefix];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/sqlmem -O - | perl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Default&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Defaults will use the cpanel default MySQL locations.&lt;br /&gt;
&lt;br /&gt;
Specify paths&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl [/path/to/my.cnf] [/path/to/mysqld]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
&lt;br /&gt;
Original code created by:&lt;br /&gt;
&lt;br /&gt;
Axel Schwenke:&lt;br /&gt;
&lt;br /&gt;
http://forge.mysql.com/tools/tool.php?id=266&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=64</id>
		<title>MySQL Memory Usage</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=64"/>
				<updated>2011-05-03T15:03:39Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Perl script to calculate MySQL max memory allotment. &lt;br /&gt;
&lt;br /&gt;
Modified original code to search for cPanel defaults.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[perl,n]&lt;br /&gt;
    #!/usr/bin/perl -w&lt;br /&gt;
    #&lt;br /&gt;
    # calculate mysqld memory consumption from my.cnf&lt;br /&gt;
    # usage: mysql-memory-usage /path/to/my.cnf [/path/to/mysqld]&lt;br /&gt;
    #&lt;br /&gt;
    # $Id: mysql-memory-usage 228 2010-05-31 10:53:33Z schwenke $&lt;br /&gt;
     &lt;br /&gt;
    my $mycnf= shift;&lt;br /&gt;
    $mycnf= &amp;quot;/etc/my.cnf&amp;quot; unless $mycnf;&lt;br /&gt;
    die &amp;quot;cannot read $mycnf\n&amp;quot; unless (-r $mycnf);&lt;br /&gt;
     &lt;br /&gt;
    my $mysqld= shift;&lt;br /&gt;
    unless ($mysqld) {&lt;br /&gt;
    # find mysqld relative to mysql&lt;br /&gt;
    $mysqld= `which mysqld` or die;&lt;br /&gt;
    chomp $mysqld;&lt;br /&gt;
    $mysqld =~ s(bin/mysql$)(libexec/mysqld);&lt;br /&gt;
    }&lt;br /&gt;
    die &amp;quot;cannot execute $mysqld\n&amp;quot; unless (-x $mysqld);&lt;br /&gt;
     &lt;br /&gt;
    # read configuration&lt;br /&gt;
    my %conf;&lt;br /&gt;
    open M, &amp;quot;$mysqld --defaults-file=$mycnf --help --verbose |&amp;quot; or die;&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) { # skip to parameter list&lt;br /&gt;
    last if (/^\-{5,} \-{5,}$/o);&lt;br /&gt;
    }&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) {&lt;br /&gt;
    last if /^$/o;&lt;br /&gt;
    my ($var, $val)= split;&lt;br /&gt;
    $conf{$var}= $val;&lt;br /&gt;
    }&lt;br /&gt;
    close M;&lt;br /&gt;
     &lt;br /&gt;
    # static memory consumption&lt;br /&gt;
    my $static= $conf{'key_buffer_size'} + $conf{'query_cache_size'};&lt;br /&gt;
    # has innodb&lt;br /&gt;
    $static+= $conf{'innodb-buffer-pool-size'} + $conf{'innodb-log-buffer-size'}&lt;br /&gt;
    + $conf{'innodb-additional-mem-pool-size'} if (($conf{'innodb'} eq 'TRUE') or ($conf{'innodb'} eq 'ON'));&lt;br /&gt;
     &lt;br /&gt;
    # per thread memory consumption&lt;br /&gt;
    my $thread= $conf{'thread_stack'}&lt;br /&gt;
    + 2*$conf{'net_buffer_length'} + $conf{'read_buffer_size'}&lt;br /&gt;
    + $conf{'read_rnd_buffer_size'} + $conf{'sort_buffer_size'};&lt;br /&gt;
     &lt;br /&gt;
    # writes binlog&lt;br /&gt;
    $thread += $conf{'binlog_cache_size'} if ($conf{'log-bin'} ne '(No');&lt;br /&gt;
     &lt;br /&gt;
    # MyISAM repair thread(s)&lt;br /&gt;
    my $repair= 0;&lt;br /&gt;
    $repair+= $conf{'myisam_repair_threads'} * $conf{'myisam_sort_buffer_size'}&lt;br /&gt;
    if ($conf{'myisam-recover'} ne 'OFF');&lt;br /&gt;
     &lt;br /&gt;
    # Memory (HEAP) tables&lt;br /&gt;
    my $heaptables= $conf{'max_heap_table_size'};&lt;br /&gt;
     &lt;br /&gt;
    # temp. tables&lt;br /&gt;
    my $tmptables= min($conf{'tmp_table_size'}, $conf{'max_heap_table_size'});&lt;br /&gt;
     &lt;br /&gt;
    #&lt;br /&gt;
    # show result&lt;br /&gt;
    #&lt;br /&gt;
    print &amp;quot;$mysqld will use at most:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s for global stuff\n&amp;quot;, p($static);&lt;br /&gt;
    printf &amp;quot;%-10s per thread\n&amp;quot;, p($thread);&lt;br /&gt;
    printf &amp;quot;%-10s total (with %d active threads)\n&amp;quot;,&lt;br /&gt;
    p($static + $conf{'max_connections'}*$thread), $conf{'max_connections'};&lt;br /&gt;
    print &amp;quot;and additionally:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s while recovering MyISAM tables\n&amp;quot;, p($repair) if ($repair);&lt;br /&gt;
    printf &amp;quot;%-10s for each HEAP table\n&amp;quot;, p($heaptables);&lt;br /&gt;
    printf &amp;quot;%-10s for each temporary table\n&amp;quot;, p($tmptables);&lt;br /&gt;
    exit 0;&lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
    sub min {&lt;br /&gt;
    my ($a, $b)= @_;&lt;br /&gt;
    return $a &amp;lt;$b ? $a : $b;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    sub p {&lt;br /&gt;
    my $n= shift;&lt;br /&gt;
    my $prefix= 0;&lt;br /&gt;
    while ($n &amp;gt;= 1024 &amp;amp;&amp;amp; $prefix &amp;lt; 5) {&lt;br /&gt;
    $n/= 1024;&lt;br /&gt;
    $prefix++;&lt;br /&gt;
    }&lt;br /&gt;
    sprintf $prefix?&amp;quot;%.1f %s&amp;quot;:&amp;quot;%d %s&amp;quot;, $n, qw&amp;quot;Bytes KB MB GB TB&amp;quot;[$prefix];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Direct download and execution of script (auto mode)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]wget http://wiki.jamesdooley.us/scripts/sqlmem -O - | perl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Default&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Defaults will use the cpanel default MySQL locations.&lt;br /&gt;
&lt;br /&gt;
Specify paths&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl [/path/to/my.cnf] [/path/to/mysqld]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
&lt;br /&gt;
Original code created by:&lt;br /&gt;
&lt;br /&gt;
Axel Schwenke:&lt;br /&gt;
&lt;br /&gt;
http://forge.mysql.com/tools/tool.php?id=266&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=63</id>
		<title>MySQL Memory Usage</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=63"/>
				<updated>2011-05-03T14:54:16Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Credits */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Perl script to calculate MySQL max memory allotment. &lt;br /&gt;
&lt;br /&gt;
Modified original code to search for cPanel defaults.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[perl,n]&lt;br /&gt;
    #!/usr/bin/perl -w&lt;br /&gt;
    #&lt;br /&gt;
    # calculate mysqld memory consumption from my.cnf&lt;br /&gt;
    # usage: mysql-memory-usage /path/to/my.cnf [/path/to/mysqld]&lt;br /&gt;
    #&lt;br /&gt;
    # $Id: mysql-memory-usage 228 2010-05-31 10:53:33Z schwenke $&lt;br /&gt;
     &lt;br /&gt;
    my $mycnf= shift;&lt;br /&gt;
    $mycnf= &amp;quot;/etc/my.cnf&amp;quot; unless $mycnf;&lt;br /&gt;
    die &amp;quot;cannot read $mycnf\n&amp;quot; unless (-r $mycnf);&lt;br /&gt;
     &lt;br /&gt;
    my $mysqld= shift;&lt;br /&gt;
    unless ($mysqld) {&lt;br /&gt;
    # find mysqld relative to mysql&lt;br /&gt;
    $mysqld= `which mysqld` or die;&lt;br /&gt;
    chomp $mysqld;&lt;br /&gt;
    $mysqld =~ s(bin/mysql$)(libexec/mysqld);&lt;br /&gt;
    }&lt;br /&gt;
    die &amp;quot;cannot execute $mysqld\n&amp;quot; unless (-x $mysqld);&lt;br /&gt;
     &lt;br /&gt;
    # read configuration&lt;br /&gt;
    my %conf;&lt;br /&gt;
    open M, &amp;quot;$mysqld --defaults-file=$mycnf --help --verbose |&amp;quot; or die;&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) { # skip to parameter list&lt;br /&gt;
    last if (/^\-{5,} \-{5,}$/o);&lt;br /&gt;
    }&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) {&lt;br /&gt;
    last if /^$/o;&lt;br /&gt;
    my ($var, $val)= split;&lt;br /&gt;
    $conf{$var}= $val;&lt;br /&gt;
    }&lt;br /&gt;
    close M;&lt;br /&gt;
     &lt;br /&gt;
    # static memory consumption&lt;br /&gt;
    my $static= $conf{'key_buffer_size'} + $conf{'query_cache_size'};&lt;br /&gt;
    # has innodb&lt;br /&gt;
    $static+= $conf{'innodb-buffer-pool-size'} + $conf{'innodb-log-buffer-size'}&lt;br /&gt;
    + $conf{'innodb-additional-mem-pool-size'} if (($conf{'innodb'} eq 'TRUE') or ($conf{'innodb'} eq 'ON'));&lt;br /&gt;
     &lt;br /&gt;
    # per thread memory consumption&lt;br /&gt;
    my $thread= $conf{'thread_stack'}&lt;br /&gt;
    + 2*$conf{'net_buffer_length'} + $conf{'read_buffer_size'}&lt;br /&gt;
    + $conf{'read_rnd_buffer_size'} + $conf{'sort_buffer_size'};&lt;br /&gt;
     &lt;br /&gt;
    # writes binlog&lt;br /&gt;
    $thread += $conf{'binlog_cache_size'} if ($conf{'log-bin'} ne '(No');&lt;br /&gt;
     &lt;br /&gt;
    # MyISAM repair thread(s)&lt;br /&gt;
    my $repair= 0;&lt;br /&gt;
    $repair+= $conf{'myisam_repair_threads'} * $conf{'myisam_sort_buffer_size'}&lt;br /&gt;
    if ($conf{'myisam-recover'} ne 'OFF');&lt;br /&gt;
     &lt;br /&gt;
    # Memory (HEAP) tables&lt;br /&gt;
    my $heaptables= $conf{'max_heap_table_size'};&lt;br /&gt;
     &lt;br /&gt;
    # temp. tables&lt;br /&gt;
    my $tmptables= min($conf{'tmp_table_size'}, $conf{'max_heap_table_size'});&lt;br /&gt;
     &lt;br /&gt;
    #&lt;br /&gt;
    # show result&lt;br /&gt;
    #&lt;br /&gt;
    print &amp;quot;$mysqld will use at most:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s for global stuff\n&amp;quot;, p($static);&lt;br /&gt;
    printf &amp;quot;%-10s per thread\n&amp;quot;, p($thread);&lt;br /&gt;
    printf &amp;quot;%-10s total (with %d active threads)\n&amp;quot;,&lt;br /&gt;
    p($static + $conf{'max_connections'}*$thread), $conf{'max_connections'};&lt;br /&gt;
    print &amp;quot;and additionally:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s while recovering MyISAM tables\n&amp;quot;, p($repair) if ($repair);&lt;br /&gt;
    printf &amp;quot;%-10s for each HEAP table\n&amp;quot;, p($heaptables);&lt;br /&gt;
    printf &amp;quot;%-10s for each temporary table\n&amp;quot;, p($tmptables);&lt;br /&gt;
    exit 0;&lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
    sub min {&lt;br /&gt;
    my ($a, $b)= @_;&lt;br /&gt;
    return $a &amp;lt;$b ? $a : $b;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    sub p {&lt;br /&gt;
    my $n= shift;&lt;br /&gt;
    my $prefix= 0;&lt;br /&gt;
    while ($n &amp;gt;= 1024 &amp;amp;&amp;amp; $prefix &amp;lt; 5) {&lt;br /&gt;
    $n/= 1024;&lt;br /&gt;
    $prefix++;&lt;br /&gt;
    }&lt;br /&gt;
    sprintf $prefix?&amp;quot;%.1f %s&amp;quot;:&amp;quot;%d %s&amp;quot;, $n, qw&amp;quot;Bytes KB MB GB TB&amp;quot;[$prefix];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Default&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Defaults will use the cpanel default MySQL locations.&lt;br /&gt;
&lt;br /&gt;
Specify paths&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl [/path/to/my.cnf] [/path/to/mysqld]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
&lt;br /&gt;
Original code created by:&lt;br /&gt;
&lt;br /&gt;
Axel Schwenke:&lt;br /&gt;
&lt;br /&gt;
http://forge.mysql.com/tools/tool.php?id=266&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=62</id>
		<title>MySQL Memory Usage</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=62"/>
				<updated>2011-05-03T14:53:20Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* What to change */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Perl script to calculate MySQL max memory allotment. &lt;br /&gt;
&lt;br /&gt;
Modified original code to search for cPanel defaults.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[perl,n]&lt;br /&gt;
    #!/usr/bin/perl -w&lt;br /&gt;
    #&lt;br /&gt;
    # calculate mysqld memory consumption from my.cnf&lt;br /&gt;
    # usage: mysql-memory-usage /path/to/my.cnf [/path/to/mysqld]&lt;br /&gt;
    #&lt;br /&gt;
    # $Id: mysql-memory-usage 228 2010-05-31 10:53:33Z schwenke $&lt;br /&gt;
     &lt;br /&gt;
    my $mycnf= shift;&lt;br /&gt;
    $mycnf= &amp;quot;/etc/my.cnf&amp;quot; unless $mycnf;&lt;br /&gt;
    die &amp;quot;cannot read $mycnf\n&amp;quot; unless (-r $mycnf);&lt;br /&gt;
     &lt;br /&gt;
    my $mysqld= shift;&lt;br /&gt;
    unless ($mysqld) {&lt;br /&gt;
    # find mysqld relative to mysql&lt;br /&gt;
    $mysqld= `which mysqld` or die;&lt;br /&gt;
    chomp $mysqld;&lt;br /&gt;
    $mysqld =~ s(bin/mysql$)(libexec/mysqld);&lt;br /&gt;
    }&lt;br /&gt;
    die &amp;quot;cannot execute $mysqld\n&amp;quot; unless (-x $mysqld);&lt;br /&gt;
     &lt;br /&gt;
    # read configuration&lt;br /&gt;
    my %conf;&lt;br /&gt;
    open M, &amp;quot;$mysqld --defaults-file=$mycnf --help --verbose |&amp;quot; or die;&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) { # skip to parameter list&lt;br /&gt;
    last if (/^\-{5,} \-{5,}$/o);&lt;br /&gt;
    }&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) {&lt;br /&gt;
    last if /^$/o;&lt;br /&gt;
    my ($var, $val)= split;&lt;br /&gt;
    $conf{$var}= $val;&lt;br /&gt;
    }&lt;br /&gt;
    close M;&lt;br /&gt;
     &lt;br /&gt;
    # static memory consumption&lt;br /&gt;
    my $static= $conf{'key_buffer_size'} + $conf{'query_cache_size'};&lt;br /&gt;
    # has innodb&lt;br /&gt;
    $static+= $conf{'innodb-buffer-pool-size'} + $conf{'innodb-log-buffer-size'}&lt;br /&gt;
    + $conf{'innodb-additional-mem-pool-size'} if (($conf{'innodb'} eq 'TRUE') or ($conf{'innodb'} eq 'ON'));&lt;br /&gt;
     &lt;br /&gt;
    # per thread memory consumption&lt;br /&gt;
    my $thread= $conf{'thread_stack'}&lt;br /&gt;
    + 2*$conf{'net_buffer_length'} + $conf{'read_buffer_size'}&lt;br /&gt;
    + $conf{'read_rnd_buffer_size'} + $conf{'sort_buffer_size'};&lt;br /&gt;
     &lt;br /&gt;
    # writes binlog&lt;br /&gt;
    $thread += $conf{'binlog_cache_size'} if ($conf{'log-bin'} ne '(No');&lt;br /&gt;
     &lt;br /&gt;
    # MyISAM repair thread(s)&lt;br /&gt;
    my $repair= 0;&lt;br /&gt;
    $repair+= $conf{'myisam_repair_threads'} * $conf{'myisam_sort_buffer_size'}&lt;br /&gt;
    if ($conf{'myisam-recover'} ne 'OFF');&lt;br /&gt;
     &lt;br /&gt;
    # Memory (HEAP) tables&lt;br /&gt;
    my $heaptables= $conf{'max_heap_table_size'};&lt;br /&gt;
     &lt;br /&gt;
    # temp. tables&lt;br /&gt;
    my $tmptables= min($conf{'tmp_table_size'}, $conf{'max_heap_table_size'});&lt;br /&gt;
     &lt;br /&gt;
    #&lt;br /&gt;
    # show result&lt;br /&gt;
    #&lt;br /&gt;
    print &amp;quot;$mysqld will use at most:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s for global stuff\n&amp;quot;, p($static);&lt;br /&gt;
    printf &amp;quot;%-10s per thread\n&amp;quot;, p($thread);&lt;br /&gt;
    printf &amp;quot;%-10s total (with %d active threads)\n&amp;quot;,&lt;br /&gt;
    p($static + $conf{'max_connections'}*$thread), $conf{'max_connections'};&lt;br /&gt;
    print &amp;quot;and additionally:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s while recovering MyISAM tables\n&amp;quot;, p($repair) if ($repair);&lt;br /&gt;
    printf &amp;quot;%-10s for each HEAP table\n&amp;quot;, p($heaptables);&lt;br /&gt;
    printf &amp;quot;%-10s for each temporary table\n&amp;quot;, p($tmptables);&lt;br /&gt;
    exit 0;&lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
    sub min {&lt;br /&gt;
    my ($a, $b)= @_;&lt;br /&gt;
    return $a &amp;lt;$b ? $a : $b;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    sub p {&lt;br /&gt;
    my $n= shift;&lt;br /&gt;
    my $prefix= 0;&lt;br /&gt;
    while ($n &amp;gt;= 1024 &amp;amp;&amp;amp; $prefix &amp;lt; 5) {&lt;br /&gt;
    $n/= 1024;&lt;br /&gt;
    $prefix++;&lt;br /&gt;
    }&lt;br /&gt;
    sprintf $prefix?&amp;quot;%.1f %s&amp;quot;:&amp;quot;%d %s&amp;quot;, $n, qw&amp;quot;Bytes KB MB GB TB&amp;quot;[$prefix];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
Default&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Defaults will use the cpanel default MySQL locations.&lt;br /&gt;
&lt;br /&gt;
Specify paths&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[bash,n]perl sqlmem.pl [/path/to/my.cnf] [/path/to/mysqld]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	<entry>
		<id>http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=61</id>
		<title>MySQL Memory Usage</title>
		<link rel="alternate" type="text/html" href="http://wiki.jamesdooley.us/index.php?title=MySQL_Memory_Usage&amp;diff=61"/>
				<updated>2011-05-03T14:50:32Z</updated>
		
		<summary type="html">&lt;p&gt;10.30.6.195: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Perl script to calculate MySQL max memory allotment. &lt;br /&gt;
&lt;br /&gt;
Modified original code to search for cPanel defaults.&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[perl,n]&lt;br /&gt;
    #!/usr/bin/perl -w&lt;br /&gt;
    #&lt;br /&gt;
    # calculate mysqld memory consumption from my.cnf&lt;br /&gt;
    # usage: mysql-memory-usage /path/to/my.cnf [/path/to/mysqld]&lt;br /&gt;
    #&lt;br /&gt;
    # $Id: mysql-memory-usage 228 2010-05-31 10:53:33Z schwenke $&lt;br /&gt;
     &lt;br /&gt;
    my $mycnf= shift;&lt;br /&gt;
    $mycnf= &amp;quot;/etc/my.cnf&amp;quot; unless $mycnf;&lt;br /&gt;
    die &amp;quot;cannot read $mycnf\n&amp;quot; unless (-r $mycnf);&lt;br /&gt;
     &lt;br /&gt;
    my $mysqld= shift;&lt;br /&gt;
    unless ($mysqld) {&lt;br /&gt;
    # find mysqld relative to mysql&lt;br /&gt;
    $mysqld= `which mysqld` or die;&lt;br /&gt;
    chomp $mysqld;&lt;br /&gt;
    $mysqld =~ s(bin/mysql$)(libexec/mysqld);&lt;br /&gt;
    }&lt;br /&gt;
    die &amp;quot;cannot execute $mysqld\n&amp;quot; unless (-x $mysqld);&lt;br /&gt;
     &lt;br /&gt;
    # read configuration&lt;br /&gt;
    my %conf;&lt;br /&gt;
    open M, &amp;quot;$mysqld --defaults-file=$mycnf --help --verbose |&amp;quot; or die;&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) { # skip to parameter list&lt;br /&gt;
    last if (/^\-{5,} \-{5,}$/o);&lt;br /&gt;
    }&lt;br /&gt;
    while (&amp;lt;M&amp;gt;) {&lt;br /&gt;
    last if /^$/o;&lt;br /&gt;
    my ($var, $val)= split;&lt;br /&gt;
    $conf{$var}= $val;&lt;br /&gt;
    }&lt;br /&gt;
    close M;&lt;br /&gt;
     &lt;br /&gt;
    # static memory consumption&lt;br /&gt;
    my $static= $conf{'key_buffer_size'} + $conf{'query_cache_size'};&lt;br /&gt;
    # has innodb&lt;br /&gt;
    $static+= $conf{'innodb-buffer-pool-size'} + $conf{'innodb-log-buffer-size'}&lt;br /&gt;
    + $conf{'innodb-additional-mem-pool-size'} if (($conf{'innodb'} eq 'TRUE') or ($conf{'innodb'} eq 'ON'));&lt;br /&gt;
     &lt;br /&gt;
    # per thread memory consumption&lt;br /&gt;
    my $thread= $conf{'thread_stack'}&lt;br /&gt;
    + 2*$conf{'net_buffer_length'} + $conf{'read_buffer_size'}&lt;br /&gt;
    + $conf{'read_rnd_buffer_size'} + $conf{'sort_buffer_size'};&lt;br /&gt;
     &lt;br /&gt;
    # writes binlog&lt;br /&gt;
    $thread += $conf{'binlog_cache_size'} if ($conf{'log-bin'} ne '(No');&lt;br /&gt;
     &lt;br /&gt;
    # MyISAM repair thread(s)&lt;br /&gt;
    my $repair= 0;&lt;br /&gt;
    $repair+= $conf{'myisam_repair_threads'} * $conf{'myisam_sort_buffer_size'}&lt;br /&gt;
    if ($conf{'myisam-recover'} ne 'OFF');&lt;br /&gt;
     &lt;br /&gt;
    # Memory (HEAP) tables&lt;br /&gt;
    my $heaptables= $conf{'max_heap_table_size'};&lt;br /&gt;
     &lt;br /&gt;
    # temp. tables&lt;br /&gt;
    my $tmptables= min($conf{'tmp_table_size'}, $conf{'max_heap_table_size'});&lt;br /&gt;
     &lt;br /&gt;
    #&lt;br /&gt;
    # show result&lt;br /&gt;
    #&lt;br /&gt;
    print &amp;quot;$mysqld will use at most:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s for global stuff\n&amp;quot;, p($static);&lt;br /&gt;
    printf &amp;quot;%-10s per thread\n&amp;quot;, p($thread);&lt;br /&gt;
    printf &amp;quot;%-10s total (with %d active threads)\n&amp;quot;,&lt;br /&gt;
    p($static + $conf{'max_connections'}*$thread), $conf{'max_connections'};&lt;br /&gt;
    print &amp;quot;and additionally:\n&amp;quot;;&lt;br /&gt;
    printf &amp;quot;%-10s while recovering MyISAM tables\n&amp;quot;, p($repair) if ($repair);&lt;br /&gt;
    printf &amp;quot;%-10s for each HEAP table\n&amp;quot;, p($heaptables);&lt;br /&gt;
    printf &amp;quot;%-10s for each temporary table\n&amp;quot;, p($tmptables);&lt;br /&gt;
    exit 0;&lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
    sub min {&lt;br /&gt;
    my ($a, $b)= @_;&lt;br /&gt;
    return $a &amp;lt;$b ? $a : $b;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    sub p {&lt;br /&gt;
    my $n= shift;&lt;br /&gt;
    my $prefix= 0;&lt;br /&gt;
    while ($n &amp;gt;= 1024 &amp;amp;&amp;amp; $prefix &amp;lt; 5) {&lt;br /&gt;
    $n/= 1024;&lt;br /&gt;
    $prefix++;&lt;br /&gt;
    }&lt;br /&gt;
    sprintf $prefix?&amp;quot;%.1f %s&amp;quot;:&amp;quot;%d %s&amp;quot;, $n, qw&amp;quot;Bytes KB MB GB TB&amp;quot;[$prefix];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What to change==&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;/div&gt;</summary>
		<author><name>10.30.6.195</name></author>	</entry>

	</feed>