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

<channel>
	<title>Hack Admin &#187; script</title>
	<atom:link href="http://www.hackadmin.com/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackadmin.com</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 21:31:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Identifying Slow MySQL queries</title>
		<link>http://www.hackadmin.com/2010/02/13/identifying-slow-mysql-queries/</link>
		<comments>http://www.hackadmin.com/2010/02/13/identifying-slow-mysql-queries/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 17:34:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Aashish]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[querry]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=213</guid>
		<description><![CDATA[MySQL can sometimes create big problems on a server when you have users abusing it.
This article will teach you how to correctly identify the queries that are creating a problem for your server.]]></description>
			<content:encoded><![CDATA[<p>Article by <a href="http://www.hackadmin.com/aashish/">Aashish</a></p>
<p>MySQL can sometimes create big problems on a server when you have users abusing it.<br />
This article will teach you how to correctly identify the queries that are creating a problem for your server.</p>
<p><span id="more-213"></span><br />
MySQL can log those queries that are taking longer then X seconds but this future is not turned on by default.<br />
Here’s how you turn it on:<br />
Login to your server as root<br />
Open my.cnf with your favorite editor. Example:<br />
vim /etc/my.cnf</p>
<p>Into the [mysqld] section add the fallowing lines<br />
log-slow-queries = /var/log/mysql-slow.log<br />
long_query_time = 3</p>
<p>This is just an example. You can use any file name that you want and you can modify the long_query_time to any value. In this example I will be logging to /var/log/mysql-slow.log any queries that are taking longer then 3 seconds.</p>
<p>Go ahead and save the configuration.<br />
For vim: CTRL+X and YES</p>
<p>Now we have to actually create the log file.<br />
touch /var/log/mysql-slow.log</p>
<p>Now we are changing the owner of the file so that mysql and actually write to it.<br />
chown mysql.root /var/log/mysql-slow.log</p>
<p>Now we restart mysql<br />
service mysql restart</p>
<p>It should restart successfully. If it doesn’t check that you didn’t brake my.cnf by examining the error file in your data directory.</p>
<p>Wait a few minutes and then examine the slow queries log<br />
A few examples on how to do it:</p>
<p>cat /var/log/mysql-slow.log<br />
tail /var/log/mysql-slow.log<br />
tail -50 /var/log/mysql-slow.log</p>
<p>After you have identified the offending query go ahead and optimize or remove it.<br />
Again test the results by looking at your server load and the mysql slow queries log.</p>
<p>After you fixed all the problems go ahead and comment the slow queries logging as it will slow your server a bit if you leave it on. my.cnf should now look similar to this:</p>
<p>#log-slow-queries = /var/log/mysql-slow.log<br />
#long_query_time = 3</p>
<p>And don’t forget to restart MySQL after this.</p>
<p>service mysql restart</p>
<p>Hope this helps ! </p>
<p>Install MySQL Performance Tuning Primer Script</p>
<p>Tuning the performance of MySQL can be a really hard job to do.<br />
There are many things to consider and no two servers are identical so there is no universal solution.<br />
Tuning Primer is a script that will help you tune your mysql installation by providing very healthy recommendations based on past mysql records.<br />
For the script to be efficient you must run the mysql server for at least 48 hours.<br />
Installation is extremely simple:</p>
<p>Download the script<br />
wget http://day32.com/MySQL/tuning-primer.sh</p>
<p>Change the permissions for the file<br />
chmod 755 tuning-primer.sh</p>
<p>Run it<br />
./tuning-primer.sh</p>
<p>Apply the sugesttions</p>
<p>                    Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2010/02/13/identifying-slow-mysql-queries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding A Custom Built Apache Installation to chkconfig</title>
		<link>http://www.hackadmin.com/2009/07/15/adding-a-custom-built-apache-installation-to-chkconfig/</link>
		<comments>http://www.hackadmin.com/2009/07/15/adding-a-custom-built-apache-installation-to-chkconfig/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 23:18:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apachectrl]]></category>
		<category><![CDATA[chkconfig]]></category>
		<category><![CDATA[customization]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=151</guid>
		<description><![CDATA[A few simple tips on setting up apachectrl with chkconfig in a non-standard, packaged version of apache. ]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s lots of reasons to steer away from a nicely packaged version of apache.  Most recently I needed to do this for a custom build of curl and cAres, but whatever your reason, you&#8217;ll find yourself with an apachectrl that&#8217;s not quite ready to be used with chkconfig.</p>
<p>The fix is really simple, chkconfig wants to see 2 lines in your apachectrl that tell it what it is and what to do with it.  At that point, chkconfig will recognize the service as your script name.  So here it is:</p>
<p><span id="more-151"></span></p>
<ol>
<li>Add the following lines to the top of the apachectrl script that you&#8217;ll find in the apache2/bin directory of your install.#!/bin/sh<br />
#<br />
<em># chkconfig: 35 85 15<br />
# description: Apache is a World Wide Web server.</em><br />
#<br />
# Licensed to the Apache Software Foundation (ASF) under one or more</p>
<p>The first line:<br />
# chkconfig: 35 85 15<br />
The 35 tells chkconfig you want the service running at run level 3 and run level 5.<br />
The 85 is the start priority.<br />
The 15 is the stop priority.</p>
<p>The second line:<br />
# description: Apache is a World Wide Web server.<br />
This is merely a description of the service.<br />
*note* Both lines start with a comment &#8220;#&#8221; (pound sign).</li>
<li>Once your lines are in place you can move or link your apachectrl to /etc/init.d/httpd</li>
<li>Once the script is in /etc/init.d/ you can run the following command to make it all go:<br />
<code>chkconfig httpd on</code>(this is of course assuming that you named the script in /etc/init.d/  &#8220;httpd&#8221;, if you named the script &#8220;chuck&#8221; then you&#8217;ll run: chkconfig chuck on, I think you get the point).</li>
</ol>
<p>That is all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2009/07/15/adding-a-custom-built-apache-installation-to-chkconfig/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To Make Sendmail Relay Everything</title>
		<link>http://www.hackadmin.com/2009/07/10/how-to-make-sendmail-relay-everything/</link>
		<comments>http://www.hackadmin.com/2009/07/10/how-to-make-sendmail-relay-everything/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 23:44:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Workaround]]></category>
		<category><![CDATA[directive]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[email relay]]></category>
		<category><![CDATA[inbound email]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[relay]]></category>
		<category><![CDATA[relay email]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sendmail]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=146</guid>
		<description><![CDATA[I knew I had done this before, but all the explanations I found today were amazingly long and convoluted, which is not what I remembered from the first go around.
Basically, I wanted sendmail to take all inbound email and immediately relay it to another host.  In my situation it makes sense because my servers [...]]]></description>
			<content:encoded><![CDATA[<p>I knew I had done this before, but all the explanations I found today were amazingly long and convoluted, which is not what I remembered from the first go around.</p>
<p>Basically, I wanted sendmail to take all inbound email and immediately relay it to another host.  In my situation it makes sense because my servers have no direct access to the outside world (security thing).  But in reality with the complexities involved in sending email these days, why bother setting up every host or every NAT to be capable of dependably delivering email.</p>
<p>So the solution is, setup one host that you know is a good mail host, and one host that you can monitor for throughput, then point all your other hosts at it for delivery.  Piece of cake right?  Odd that it took me 30 minutes and then a final trip to the sendmail documentation to find it.</p>
<p><span id="more-146"></span>In the end we&#8217;re talking about 1 line in your sendmail.mc (I&#8217;ve consistently found that most of life&#8217;s problems can be solved with 5 to 50 characters in the right text file).</p>
<p>At any rate, the directive you are looking for is:</p>
<p><code>define(`SMART_HOST', `smart.host.com')dnl</code></p>
<p>Just replace &#8220;smart.host.com&#8221; with the smtp server you intend to use as the relay.</p>
<p>For those of you who don&#8217;t use the sendmail.mc, you need to modify the DS variable in your sendmail.cf (but really, find something better to do with your time than edit that file).</p>
<p>For all you sendmail.mc users, once that line is in place, run a &#8220;make&#8221; in your /etc/mail directory and then restart sendmail.</p>
<p>Actually, I was using this mess of a line to test:</p>
<p><code>touch /tmp/mail.txt; /etc/init.d/sendmail restart ; mail -s "Test2" me@myemail.com &lt; /tmp/mail.txt ; tail -f /var/log/maillog</code></p>
<p>You&#8217;ll come up in a tail of maillog and you should watch for the relay host accepting your message.  If it doesn&#8217;t get delivered, it&#8217;s time to look at the relay server.</p>
<p>That is all, have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2009/07/10/how-to-make-sendmail-relay-everything/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Strip MP3s from YouTube with ffmpeg.</title>
		<link>http://www.hackadmin.com/2009/07/09/strip-mp3s-from-youtube-with-ffmpeg/</link>
		<comments>http://www.hackadmin.com/2009/07/09/strip-mp3s-from-youtube-with-ffmpeg/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 01:47:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[flv]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=134</guid>
		<description><![CDATA[Here&#8217;s a nifty little script that will take a YouTube URL as an argument, pull down the associated flv and convert it into mp3 format.  It&#8217;s basically all shell but I wrapped it with php.
First:
Take the YouTube URL as an argument
$url = $argv[1];
Next:
Use a little shell magic to grab the video arguments for later [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a nifty little script that will take a YouTube URL as an argument, pull down the associated flv and convert it into mp3 format.  It&#8217;s basically all shell but I wrapped it with php.</p>
<p>First:</p>
<p>Take the YouTube URL as an argument</p>
<p><code>$url = $argv[1];</code></p>
<p><span id="more-134"></span>Next:</p>
<p>Use a little shell magic to grab the video arguments for later use:</p>
<p><code>$vid_args = `lynx -source "$url" | grep video_id | grep fullscreen | awk -F'video_id=' '{print $2}' | awk -F'&amp;title'</code></p>
<p>Next:</p>
<p>use basically the same command to grab the title of the video:</p>
<p><code>$title = 'lynx -source "$url" | grep video_id | grep fullscreen | awk -F'video_id=' '{print $2}' | awk -F'&amp;title=' '{print $2}' ';</code></p>
<p>Then:</p>
<p>Do a little formatting of the title to make it useable:</p>
<p><code>$title = preg_replace("| |", "_", $title);<br />
$title = trim($title);<br />
$title = preg_replace("/^[^a-z0-9]?(.*?)[^a-z0-9]?$/i", "$1", $title);<br />
$title = preg_replace("|'|", "", $title);<br />
$title = preg_replace("|\)|", "", $title);<br />
$title = preg_replace("|\(|", "", $title);<br />
$title = preg_replace("|\/|", "_", $title);</code></p>
<p>Then:</p>
<p>Grab the flv with the video arguments you captured from the line above:</p>
<p><code>'wget -O /tmp/$title.flv "http://www.youtube.com/get_video?video_id=$vid_args"';</code></p>
<p>Next:</p>
<p>Use ffmpeg to break it down to mp3 format:</p>
<p><code>'ffmpeg -i /tmp/$title.flv -ar 44100 -ab 160k -ac 2 /tmp/$title.mp3';</code></p>
<p>Finally:</p>
<p>Dump the flv and enjoy:</p>
<p><code>'rm -f /tmp/$title.flv';</code></p>
<p>These files are of course only for educational purposes when you are finished so make sure you delete them <img src='http://www.hackadmin.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.hackadmin.com/downloads/tubeconverter.php.txt">Download The Whole Script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2009/07/09/strip-mp3s-from-youtube-with-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Chroot Jail for Untrusted Users</title>
		<link>http://www.hackadmin.com/2008/03/29/chroot-jail-for-untrusted-users/</link>
		<comments>http://www.hackadmin.com/2008/03/29/chroot-jail-for-untrusted-users/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 10:55:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[chroot]]></category>
		<category><![CDATA[Chroot Jail]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/2008/03/29/chroot-jail-for-untrusted-users/</guid>
		<description><![CDATA[So we&#8217;ve been buying some websites recently and I&#8217;ve needed to let people into the web server to upload content and such.  I knew I needed to put these folks someplace where they couldn&#8217;t hurt anything else, or more importantly, see anything else on the server.  So, I went digging around for an [...]]]></description>
			<content:encoded><![CDATA[<p>So we&#8217;ve been buying some websites recently and I&#8217;ve needed to let people into the web server to upload content and such.  I knew I needed to put these folks someplace where they couldn&#8217;t hurt anything else, or more importantly, see anything else on the server.  So, I went digging around for an FAQ on how to most effectively get this done and I came across this script:</p>
<p><span id="more-3"></span><a title="Chroot Jail" href="http://www.fuschlberger.net/programs/ssh-scp-sftp-chroot-jail/make_chroot_jail.sh.html">Chroot Jail</a></p>
<p>It&#8217;s quite nice.</p>
<p>Basically, you just pull that script down and get it on your machine.  Then you feed it a username and let it go to work.</p>
<p>When it&#8217;s done, you&#8217;ll have a new user who is isolated to /home/jail.  Their home dir will be in /home/jail/home and they can shell in and do whatever.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2008/03/29/chroot-jail-for-untrusted-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
