<?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>Derek Neely &#187; Linux</title>
	<atom:link href="http://derekneely.com/category/linux-references-and-resources/feed/" rel="self" type="application/rss+xml" />
	<link>http://derekneely.com</link>
	<description>...what I care to share...</description>
	<lastBuildDate>Thu, 06 Oct 2011 15:10:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>MJPEG to H.264 Streaming for Mobile with VLC</title>
		<link>http://derekneely.com/2011/10/mjpeg-h264-streaming-mobile-vlc/</link>
		<comments>http://derekneely.com/2011/10/mjpeg-h264-streaming-mobile-vlc/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 15:10:17 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Streaming]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[Encoding]]></category>
		<category><![CDATA[H.264]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[MJPEG]]></category>
		<category><![CDATA[MPMoviePlayerController]]></category>
		<category><![CDATA[Video Encoding]]></category>
		<category><![CDATA[Video Streaming]]></category>
		<category><![CDATA[VLC]]></category>
		<category><![CDATA[VLC Media Player]]></category>
		<category><![CDATA[Web Cam]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=634</guid>
		<description><![CDATA[Dang! Its been a while since I&#8217;ve been able to get out here and post something new. We&#8217;ve been busy, busy, busy here at v4 living the dream. Anyhow, as of recently its been tasked upon us to work with some streaming video. Now, the hardware we will be using for our client are some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://derekneely.com/2011/10/mjpeg-h264-streaming-mobile-vlc/largevlc/" rel="attachment wp-att-651"><img class="alignright size-full wp-image-651" title="VLC Icon" src="http://derekneely.com/wp-content/uploads/2011/10/largeVLC.png" alt="VLC Media Player" width="168" height="168" /></a>Dang! Its been a while since I&#8217;ve been able to get out here and post something new. We&#8217;ve been busy, busy, busy here at <a title="v4 Development" href="http://v4development.com">v4</a> living the dream.</p>
<p>Anyhow, as of recently its been tasked upon us to work with some streaming video. Now, the hardware we will be using for our client are some nice IP/H.264 compatible cameras. Well, I personally do not have one but needed a solution by which I could test and work with. I have one of those little eye ball looking cameras and found some free software (<a title="WebCampXP" href="http://www.webcamxp.com/" target="_blank">WebCamXP</a>) that would run a simple MJPEG stream. (Yea, yea&#8230;its windows but who doesn&#8217;t have a windows box to hack and slash on? Ha!) After this is up and running you have a basic MJPEG stream that is running and accessible via http://10.0.0.99:8080/webcamp_1.cgi (or whatever your internal IP is and the port you configured in the software)</p>
<p><strong>** Note:</strong> This tutorial uses iPhone references as thats what I worked with first. I&#8217;ll update with the Android version later. I am also using Linux (Ubuntu) to do the encoding and serving of the new video stream. Also assuming you have Apache or another web server up and running.</p>
<p>Now, this .cgi page/script &#8216;can&#8217; be placed as the source of a UIWebview and works ok.</p>
<pre>NSString *urlAddress = @"http://10.0.0.99:8080/cam_1.cgi";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[streamWebView loadRequest:requestObj];</pre>
<p>But, ultimately this is not what we&#8217;re looking for. We need to get a nice H.264 compatible stream rolling out so that we can play this directly to the iPhone (MPMoivePlayerController) or be able to hook into a streaming server (as we&#8217;re planning on doing) so that we can re-broadcast to several devices at once.</p>
<p>So&#8230;how might we convert this MJPEG (.cgi) into an H.264 compatible stream? <a title="VideoLan (VLC Media Player)" href="http://www.videolan.org/" target="_blank">VLC Media Player</a> to the rescue.</p>
<p>On your Linux box install VLC and the x264 libraries.</p>
<pre># apt-get install vlc x264</pre>
<p>A few of the tutorials you read on this all reference using the command: <em><strong>vlc</strong></em>. However, if you don&#8217;t have X11 installed on your system (as I do not) you will run into a few errors with regards to this. But, have no fear, VLC provided a command line option: <em><strong>cvlc</strong></em>.</p>
<p>Now what we need to do is fire up VLC with a bunch of options that will read in the MJPEG (.cgi) convert it to H.264 and then provide us with a means of accessing the stream (via the Linux server &#8211; 10.0.0.69). So, on the command prompt do something like:</p>
<pre>cvlc --intf=rc http://10.0.0.99:8080/cam_1.cgi --sout '#transcode{fps=25,
vcodec=h264,venc=x264{aud,profile=baseline,level=30,keyint=30,
bframes=0,ref=1,nocabac},acodec=mp3,ab=56,audio-sync,deinterlace}
:standard{mux=ts,access=http,dst=10.0.0.69:8090/myStream.mp4}'</pre>
<p>Now, on the command prompt you&#8217;ll see a bunch of stuff start scrolling by. This is what you want. Its reading in frames from the original MJPEG stream and converting them. But, you&#8217;re not done yet. In order to get this to play via MPMoviePlayerController on the iPhone, we need to setup the .m3u8 or the playlist file.</p>
<p>In your web server directory create a file myStream.m3u8 and put the following in and save:</p>
<pre>
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10, 

http://10.0.0.69:8090/myStream.mp4
</pre>
<p>Now you&#8217;re ready for some iPhone code to show the stream.</p>
<pre>NSURL *url = [NSURL URLWithString:@"http://10.0.0.69/myStream.m3u8"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
player.controlStyle = MPMovieControlStyleNone;
[player.view setFrame:CGRectMake(0, 120, 320 , 200)];
[self.view addSubview:player.view];
[player play];</pre>
<p>This should basically do it. I don&#8217;t believe I left out any steps. I&#8217;ll update if I run across any missing steps or you guys let me know. When you run the app, it can sometimes take a few seconds before the video starts playing. At one point I set a background color to the mpmovieplayercontroller&#8217;s view so that I could tell where it was being</p>
<p>With MPMoviePlayerController there are several other options you may be interested in using/implementing.</p>
<p>When setting up the player you can have your containing view controller listen for some of the playback events (can help with some debugging) with:</p>
<pre>//Defined in the above MPMoviePlayerController allocation
[[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(moviePlayerPlaybackStateDidChange:)  name:MPMoviePlayerPlaybackStateDidChangeNotification  object:nil];</pre>
<pre>//NSNotification callback function
- (void)moviePlayerPlaybackStateDidChange:(NSNotification*)notification {
     NSLog(@"playbackDidChanged");
     MPMoviePlayerController *moviePlayer = notification.object;

     MPMoviePlaybackState playbackState = moviePlayer.playbackState;

     if(playbackState == MPMoviePlaybackStateStopped) {
          NSLog(@"MPMoviePlaybackStateStopped");
     } else if(playbackState == MPMoviePlaybackStatePlaying) {
          NSLog(@"MPMoviePlaybackStatePlaying");
     } else if(playbackState == MPMoviePlaybackStatePaused) {
          NSLog(@"MPMoviePlaybackStatePaused");
     } else if(playbackState == MPMoviePlaybackStateInterrupted) {
          NSLog(@"MPMoviePlaybackStateInterrupted");
     } else if(playbackState == MPMoviePlaybackStateSeekingForward) {
          NSLog(@"MPMoviePlaybackStateSeekingForward");
     } else if(playbackState == MPMoviePlaybackStateSeekingBackward) {
          NSLog(@"MPMoviePlaybackStateSeekingBackward");
     }
}</pre>
<p>Please <a href="mailto:feedback@derekneely.com">let me know</a> if I&#8217;ve left out any steps or you have any issues and I&#8217;ll be happy to help and work through it with you. This was a quick and dirty how-to with a ways to go before I push anything out to production. Just wanted to share my research and discovery. Good luck!</p>
<p>References:<br />
<a title="Apple - Reference:MPMoviePlayerController" href="http://developer.apple.com/LIBRARY/IOS/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html">Apple &#8211; Reference: MPMoviePlayerController</a><br />
<a title="StackOverflow" href="http://stackoverflow.com/questions/2663637/http-stream-without-extension-in-mpmovieplayercontroller">StackOverflow &#8211; HTTP stream without extension in MPMoviePlayerController</a></p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2011/10/mjpeg-h264-streaming-mobile-vlc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 10.04 USB Lock-Ups</title>
		<link>http://derekneely.com/2010/07/ubuntu-10-04-usb-lock-ups/</link>
		<comments>http://derekneely.com/2010/07/ubuntu-10-04-usb-lock-ups/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 17:39:18 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Freeze]]></category>
		<category><![CDATA[Lock-up]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=589</guid>
		<description><![CDATA[I recently installed Ubuntu 10.04 LTS on one of my desktop PCs here at home. Love Ubuntu. Easy to use, very compatible with most devices, good plug and play. Don&#8217;t get me wrong (for those hardcore Linux folks) I like tinkering with Linux as much as anyone, but I also have work to get done. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://derekneely.com/wp-content/uploads/2010/07/ubuntu_icon.png"><img class="alignright size-full wp-image-588" title="Ubuntu" src="http://derekneely.com/wp-content/uploads/2010/07/ubuntu_icon.png" alt="" width="143" height="143" /></a>I recently installed Ubuntu 10.04 LTS on one of my desktop PCs here at home. Love Ubuntu. Easy to use, very compatible with most devices, good plug and play. Don&#8217;t get me wrong (for those hardcore Linux folks) I like tinkering with Linux as much as anyone, but I also have work to get done. Fighting for hours getting dual monitors or the right drivers working keeps me from getting that work done. Ok, sorry for the quick rant, back to the subject.</p>
<p>I noticed after installation when I would go to start plugging in some of my external devices via USB the dang thing would lock up on me. That is, desktop completely frozen, unable to remotely ssh into the box, just plain dead.</p>
<p>So, I tried various things and what have you and nothing appeared to help.</p>
<p>My solution was:</p>
<blockquote><p>apt-get remove modemmanager</p></blockquote>
<p>Simple as that. I haven&#8217;t had any lock-ups, system has been up for several days and I&#8217;ve been able to add my alfa wireless and my magic jack to the box without any crashes. Hope this may help you too!</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2010/07/ubuntu-10-04-usb-lock-ups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pure-FTP with Database Authentication</title>
		<link>http://derekneely.com/2009/07/pure-ftp-with-database-authentication/</link>
		<comments>http://derekneely.com/2009/07/pure-ftp-with-database-authentication/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 12:35:18 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Postgres]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Pure-FTP]]></category>
		<category><![CDATA[User Accounts]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=374</guid>
		<description><![CDATA[Pure-FTP is  a powerful ftp server. If you are like me however, you don&#8217;t like to create system accounts for each individual user. Well, this is where we are in luck! Pure-FTP has the ability to tie into both PostgreSQL and MySQL.  In this example I have tied it into a PostgreSQL database. I will [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-284" title="Linux" src="http://derekneely.com/wp-content/uploads/2009/06/linux.jpg" alt="Linux" width="113" height="142" />Pure-FTP is  a powerful ftp server. If you are like me however, you don&#8217;t like to create system accounts for each individual user. Well, this is where we are in luck! Pure-FTP has the ability to tie into both PostgreSQL and MySQL.  In this example I have tied it into a PostgreSQL database. I will also include the MySQL snippet of the configuration but it hasn&#8217;t been tested by me. Also note that this is a Gentoo based installation but the general configuration should be the same.</p>
<p>Install Pure-FTP with MySQL and/or PostgreSQL support:</p>
<blockquote><p># &gt; vi /etc/make.conf<br />
&#8211; add &#8216;postgres&#8217; and/or &#8216;mysql&#8217; to the USE flag or:</p>
<p>#&gt; USE=&#8221;mysql postgres&#8221; emerge -av net-ftp/pure-ftpd</p></blockquote>
<p>Now that Pure-FTP is installed with the various database support, we can configure Pure-FTP to authenticate off of a database. You may need to tailor the SQL queries to match the schema of your database.</p>
<p>PostgreSQL:</p>
<blockquote><p>#&gt;  vi /etc/pureftpd-pgsql.conf</p>
<p># If PostgreSQL listens to a TCP socket<br />
PGSQLServer localhost<br />
PGSQLPort 5432<br />
# *or* if PostgreSQL can only be reached through a local Unix socket<br />
# PGSQLServer /tmp<br />
# PGSQLPort .s.PGSQL.5432<br />
# Mandatory : user to bind the server as.<br />
PGSQLUser [pureftpd]<br />
# Mandatory : user password. You *must* have a password.<br />
PGSQLPassword [pureftpd_password]<br />
# Mandatory : database to open.<br />
PGSQLDatabase [pureftpd_database]<br />
# Mandatory : how passwords are stored<br />
# Valid values are : &#8220;cleartext&#8221;, &#8220;crypt&#8221;, &#8220;md5&#8243; and &#8220;any&#8221;<br />
#PGSQLCrypt cleartext<br />
PGSQLCrypt crypt</p>
<p># In the following directives, parts of the strings are replaced at<br />
# run-time before performing queries :<br />
#<br />
# \L is replaced by the login of the user trying to authenticate.<br />
# \I is replaced by the IP address the user connected to.<br />
# \P is replaced by the port number the user connected to.<br />
# \R is replaced by the IP address the user connected from.<br />
# \D is replaced by the remote IP address, as a long decimal number.<br />
#<br />
# Very complex queries can be performed using these substitution strings,<br />
# especially for virtual hosting.<br />
# Query to execute in order to fetch the password<br />
PGSQLGetPW SELECT password FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
# Query to execute in order to fetch the system user name or uid<br />
PGSQLGetUID SELECT uid FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
# Optional : default UID &#8211; if set this overrides PGSQLGetUID<br />
#PGSQLDefaultUID 1000<br />
# Query to execute in order to fetch the system user group or gid<br />
PGSQLGetGID SELECT gid FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
# Optional : default GID &#8211; if set this overrides PGSQLGetGID<br />
#PGSQLDefaultGID 1000<br />
# Query to execute in order to fetch the home directory<br />
PGSQLGetDir SELECT dir FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
#########OPTIONAL SETTINGS#############<br />
# Optional : query to get the maximal number of files<br />
# Pure-FTPd must have been compiled with virtual quotas support.<br />
# PGSQLGetQTAFS SELECT QuotaFiles FROM users WHERE User=&#8217;\L&#8217;<br />
# Optional : query to get the maximal disk usage (virtual quotas)<br />
# The number should be in Megabytes.<br />
# Pure-FTPd must have been compiled with virtual quotas support.<br />
# PGSQLGetQTASZ SELECT QuotaSize FROM users WHERE User=&#8217;\L&#8217;<br />
# Optional : ratios. The server has to be compiled with ratio support.<br />
PGSQLGetRatioUL SELECT ul_ratio FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
PGSQLGetRatioDL SELECT dl_ratio FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
# Optional : bandwidth throttling.<br />
# The server has to be compiled with throttling support.<br />
# Values are in KB/s .<br />
PGSQLGetBandwidthUL SELECT ul_bandwidth FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
PGSQLGetBandwidthDL SELECT dl_bandwidth FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;</p></blockquote>
<p>Now we need to modify the pure-ftpd config file (keep in mind this is Gentoo)</p>
<blockquote><p>#&gt; vi /etc/conf.d/pure-ftpd</p>
<p>Look for the line: AUTH=&#8221;-l unix&#8221; and change to:</p>
<p>AUTH=&#8221;-l pgsql:/etc/pureftpd-pgsql.conf</p>
<p>#&gt; /etc/init.d/pure-ftpd restart</p></blockquote>
<p>This should conclude your intstallation of Pure-FTP with Postgres database support.</p>
<p>MySQL Config File:</p>
<blockquote><p>Coming Soon!</p></blockquote>
<p>A couple of little tweaks that I&#8217;ve had to use for some of the configurations.</p>
<p>If you want all users to go to the same directory and don&#8217;t have or want to store the directory information in the database you can change this line in the pureftpd-pgsql.conf:</p>
<blockquote><p>PGSQLGetDir SELECT &#8216;/home/ftpdir&#8217; FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/07/pure-ftp-with-database-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Interface Bonding (Gentoo)</title>
		<link>http://derekneely.com/2009/06/simple-interface-bonding-gentoo/</link>
		<comments>http://derekneely.com/2009/06/simple-interface-bonding-gentoo/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 15:16:43 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bond]]></category>
		<category><![CDATA[Bonding]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Interfaces]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Redundancy]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=343</guid>
		<description><![CDATA[Its often necessary to add bonding (NIC teaming &#8211; in windows world) to a linux config. This gives you 2 things: higher throughput on the interfaces and redundancy (if a card or switch happens to die). I made this post just as a quick reference for how to do such on a Gentoo system. This [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-348" title="Gentoo" src="http://derekneely.com/wp-content/uploads/2009/06/gentoo.png" alt="Gentoo" width="107" height="114" />Its often necessary to add bonding (NIC teaming &#8211; in windows world) to a linux config. This gives you 2 things: higher throughput on the interfaces and redundancy (if a card or switch happens to die). I made this post just as a quick reference for how to do such on a Gentoo system.</p>
<p>This article assumes that you have the proper kernel configuration to support bonded interfaces.</p>
<blockquote><p>Device Driver =&gt; Network device support =&gt; &lt;M&gt; Bonding driver support</p></blockquote>
<p>Load the necessary modules for bonding and install the necessary packages.</p>
<blockquote><p>linux# modprobe bonding<br />
linux# echo &#8220;bonding&#8221; &gt;&gt; /etc/modules.autoload.d/kernel-2.6<br />
linux# emerge net-misc/ifenslave</p></blockquote>
<p>Configure the interfaces: vi /etc/conf.d/net</p>
<blockquote><p>config_eth0=( &#8220;null&#8221; )<br />
config_eth1=( &#8220;null&#8221; )<br />
slaves_bond0=&#8221;eth0 eth1&#8243;<br />
config_bond0=( &#8220;10.10.10.69/24&#8243; )<br />
routes_bond0=( &#8220;default gw 10.10.10.1&#8243; )</p></blockquote>
<p>Start the interface and setup to start on boot.</p>
<blockquote><p>linux# ln -s /etc/init.d/net.lo /etc/init.d/net.bond0<br />
linux# rc-update add net.bond0 default<br />
linux# /etc/init.d/net.bond0 start</p>
<p>If you have eth0 and/or eth1 setup to start on boot already you will need to delete those init scripts.<br />
linux# rc-update del net.eth0; rc-update del net.eth1</p></blockquote>
<p>Test</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/06/simple-interface-bonding-gentoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache mod_log_sql (review)</title>
		<link>http://derekneely.com/2009/05/apache-mod_log_sql-review/</link>
		<comments>http://derekneely.com/2009/05/apache-mod_log_sql-review/#comments</comments>
		<pubDate>Thu, 28 May 2009 21:05:42 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[mod_log_sql]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=225</guid>
		<description><![CDATA[After some reading of consolidation options for Apache logs, I ran across mod_log_sql (we are hating spread) which will take Apache logs and log them off to a MySQL database. Sounded great! We could then run scripts to go through and parse the values and run statistics on. Twas perfect for our needs. RIGHT!!! At [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-284" title="Linux" src="http://derekneely.com/wp-content/uploads/2009/06/linux.jpg" alt="Linux" width="97" height="122" />After some reading of consolidation options for Apache logs, I ran across mod_log_sql (we are hating spread) which will take Apache logs and log them off to a MySQL database. Sounded great! We could then run scripts to go through and parse the values and run statistics on. Twas perfect for our needs. RIGHT!!!</p>
<p>At my company we run about 12 vhosts over about 5-6 load balanced web servers. All of them were configured to log to our loganalysis server which is a pretty beefy machine. The logging all in all worked well with a few major exceptions listed below.</p>
<p><strong>1)</strong> I used the directive:</p>
<blockquote><p>LogSQLRequestIgnore .gif .jpg .css .ico .png .js</p></blockquote>
<p>This directive is supposed to be used to ignore any pages ending with that extension. This did not work at all and I had to create a script to actually delete those before analyzing the logs. Bummer but not that big of a deal.</p>
<p><strong>2)</strong> While working with the server to optimize the database, there were various times when I would need to restart the MySQL service and a few times I needed to reboot the server. During these periods of time, the web servers were unable to log to the database which brought them to their knees. The inability of the module to handle a database outage gracefully was a major deal breaker for us. I feel this issue is a result of intense disk IO when the database is down. The server is logging to its Apache logs, the the backup SQL logs, and to the Apache error logs for every failed request. This becomes emense with thousands of requests per second. Should this server die or needing maintenance would have ultimately brought our company to a hault.</p>
<p>Long story short, we&#8217;re scrapping mod_log_sql and going with an NFS mount out to all the web services which we can then parse and run statistics on using some custom scripts and/or AWStats or Splunk.</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/05/apache-mod_log_sql-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Squid Proxy (how-to)</title>
		<link>http://derekneely.com/2009/05/squid-proxy-how-to/</link>
		<comments>http://derekneely.com/2009/05/squid-proxy-how-to/#comments</comments>
		<pubDate>Wed, 27 May 2009 03:42:23 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=100</guid>
		<description><![CDATA[While I enjoy using the SSH Tunnels to encrypt traffic out of the random local networks that I may be sitting on, sometimes there is a need to establish a more permanent proxy server. For instance, if you don&#8217;t have a means to use an SSH client or you have several machines that you would [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-284" title="Linux" src="http://derekneely.com/wp-content/uploads/2009/06/linux.jpg" alt="Linux" width="97" height="122" />While I enjoy using the <a title="SSH Proxy (how-to)" href="http://derekneely.com/2009/05/ssh-proxy-how-to/" target="_self">SSH Tunnels</a> to encrypt traffic out of the random local networks that I may be sitting on, sometimes there is a need to establish a more permanent proxy server. For instance, if you don&#8217;t have a means to use an SSH client or you have several machines that you would like to service without the need to establish dedicated SSH tunnels/forwards for each machine (administrative nightmare).</p>
<p>I chose <a title="Squid Proxy Server" href="http://www.squid-cache.org/" target="_blank">Squid</a> for just this function. It was extremely easy to setup and has worked like a charm! Below are some of the basic steps for setting up and using your Squid proxy.</p>
<p><strong>Install Squid:</strong></p>
<blockquote><p><strong>Gentoo</strong>:<br />
#&gt; emerge squid</p>
<p><strong>Red Hat/CentOS</strong>:<br />
#&gt; yum install squid</p>
<p><strong>Ubuntu/Debian</strong>:<br />
#&gt; apt-get install squid</p>
<p><strong>OpenBSD</strong>:<br />
#&gt; export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/<br />
#&gt; pkg_add squid</p></blockquote>
<p><strong>Basic Configuration for Transparent Proxy:</strong></p>
<blockquote><p>#&gt; vi /etc/squid/squid.conf</p></blockquote>
<p>Look for the sections listed below and modify accordingly. This is a sample of my ACLs and configurations outside of some of the defaults.</p>
<blockquote><p><strong>#/etc/squid/squid.conf</strong><br />
acl all src 0.0.0.0/0.0.0.0<br />
acl trusted_hosts 192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0<br />
acl localhost src 127.0.0.1/255.255.255.255<br />
acl SSL_ports port 443<br />
acl Safe_ports port 80          # http<br />
acl Safe_ports port 443         # https<br />
acl Safe_ports port 21         # ftp<br />
acl CONNECT method CONNECT</p>
<p># Deny requests to unknown ports<br />
http_access deny !Safe_ports<br />
# Deny CONNECT to other than SSL ports<br />
http_access deny CONNECT !SSL_ports</p>
<p>http_access allow localhost<br />
http_access allow trusted_hosts<br />
http_access deny all</p>
<p># Listening port (default 3128)<br />
http_port 3128</p>
<p># Visible Hostname (may not be needed but doesn&#8217;t hurt)<br />
visible_hostname yourserverhostname</p></blockquote>
<p>This is the basic configuration that should get you going. More advanced configuration options will be coming soon.</p>
<p><strong>Start up Squid:</strong></p>
<blockquote><p>#&gt; /etc/init.d/squid start</p></blockquote>
<p>Set Squid to start on-boot (optional)</p>
<blockquote><p><strong>Gentoo</strong>:<br />
#&gt; rc-update add squid default</p>
<p><strong>Red Hat/CentOS</strong>:<br />
#&gt; chkconfig squid on</p>
<p><strong>Ubuntu/Debian</strong>:<br />
#&gt; update-rc.d squid defaults</p>
<p><strong>OpenBSD</strong>:<br />
#&gt; vi /etc/rc.local<br />
Code coming soon&#8230;</p></blockquote>
<p><strong>Configure your Browser:</strong><br />
This is an example Firefox setup. Preferences &#8211;&gt; Advanced &#8211;&gt; Network &#8211;&gt; Connection &#8211;&gt; Settings. Select &#8216;Manual proxy configuration:&#8217; Set the HTTP Proxy: value to your Squid server&#8217;s IP (public or private depending on how you are going to use it and based on the ACLs above). Then select &#8216;Use this proxy server for all protocols&#8217; if you want to go ahead and use this same proxy for all connections.  Setup any exceptions to not proxy (i.e. &#8211; locally connected servers). Here&#8217;s a screen shot of my configuration.</p>
<p><img class="alignnone" title="Firefox Squid Proxy Configuration" src="http://gallery.derekneely.com/images/screen_shots/squid_proxy_config/firefox_squid_proxy_config.png" alt="" width="425" height="356" /></p>
<p><strong>SSL Configuration:</strong><br />
Coming soon&#8230;</p>
<p><strong>Advanced Configurations:</strong><br />
Coming soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/05/squid-proxy-how-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Proxy (how-to)</title>
		<link>http://derekneely.com/2009/05/ssh-proxy-how-to/</link>
		<comments>http://derekneely.com/2009/05/ssh-proxy-how-to/#comments</comments>
		<pubDate>Sat, 23 May 2009 20:57:32 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=83</guid>
		<description><![CDATA[SSH Proxying is one of my every day tools. Sitting at work with a Barracuda firewall looking, snooping, and possibly blocking everything that I do. Hanging at a coffee shop when you see a suspicious person most likely snooping your information out of the air. In the first case I&#8217;m primarily just trying to get [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-286" title="Terminal" src="http://derekneely.com/wp-content/uploads/2009/06/terminal.png" alt="Terminal" width="117" height="103" />SSH Proxying is one of my every day tools. Sitting at work with a Barracuda firewall looking, snooping, and possibly blocking everything that I do. Hanging at a coffee shop when you see a suspicious <a title="Huggs" href="#" target="_blank">person</a> most likely snooping your information out of the air. In the first case I&#8217;m primarily just trying to get around a hurdle. In both cases I want my traffic encrypted and hidden from 3rd parties.</p>
<p>What is SSH Proxying?<br />
This is a means of setting up a Secure Shell (SSH) and then piping your various web requests across this pipe or tunnel.</p>
<p>I&#8217;ve got 2 different SSH Proxies that I use daily.</p>
<p><strong>Web Traffic &#8211; SSH Tunnel/Proxy:</strong></p>
<blockquote><p>ssh -CqN -D 8080 [username]@[hostname]</p></blockquote>
<p>For above tunnel I&#8217;m using the following:</p>
<blockquote><p>-D: bind port &#8211; in this case 8080 locally<br />
-C: enables compression<br />
-q: quiet mode (suppresses any warnings)<br />
-N: don&#8217;t execute any remote commands</p></blockquote>
<p>The -CqN are just some bells and whistles I use for the connection but not required. Please see below on configuring your browser to use the newly established SSH Tunnel.</p>
<p><strong>Various other traffic (IRC, VNC, Torrent, etc&#8230;) &#8211; SSH Port Forwarding</strong></p>
<blockquote><p>ssh -L 6667:irc.[hostname]:6667 [username]@[hostname]</p></blockquote>
<p>In this example, I&#8217;m binding a local port (-L 6667) to a remote boxes port (6667) through the server I have SSH&#8217;ed into. You can also add some of the bells and whistles from the web proxy to this one as well. Please see below for using this port forward with and IRC client.</p>
<p><strong>Configuring the Browser:<br />
</strong>The general idea (for Firefox) is to go to: Preferences &#8211;&gt; Advanced &#8211;&gt; Network &#8211;&gt; Connection &#8211;&gt; Settings. Select &#8216;Manual proxy configuration&#8217;. Set SOCKS Host: localhost Port: 8080. Click OK/Save and you should be good to go.</p>
<p>Here&#8217;s a screen shot of my settings:</p>
<p><img title="Firefox SSH Proxy Config" src="http://derekneely.com/MyImages/SSH_Proxy/Firefox_SSH_Proxy_Config.png" alt="Firefox SSH Proxy Config" width="450" height="376" /></p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/05/ssh-proxy-how-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adventures in Apache Rewrite Rules</title>
		<link>http://derekneely.com/2009/05/adventures-in-apache-rewrite-rules/</link>
		<comments>http://derekneely.com/2009/05/adventures-in-apache-rewrite-rules/#comments</comments>
		<pubDate>Sat, 23 May 2009 04:04:47 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Rewrite]]></category>
		<category><![CDATA[Rules]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=358</guid>
		<description><![CDATA[I feel as a big newb when it comes to the rewrite rules. Not sure where my head&#8217;s been but it hasn&#8217;t been here. I&#8217;m finally grasping the concept of them. Here are some of my notes and resources that help me maintain some sanity with it. Shortened file path RewriteCond %{HTTP_HOST}    (.*) RewriteRule ^images/(.*) [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-thumbnail wp-image-284" title="Linux" src="http://derekneely.com/wp-content/uploads/2009/06/linux-150x150.jpg" alt="Linux" width="95" height="95" />I feel as a big newb when it comes to the rewrite rules. Not sure where my head&#8217;s been but it hasn&#8217;t been here. I&#8217;m finally grasping the concept of them. Here are some of my notes and resources that help me maintain some sanity with it.</p>
<p>Shortened file path</p>
<blockquote><p>RewriteCond %{HTTP_HOST}    (.*)<br />
RewriteRule ^images/(.*) sites/%1/files/images/$1 [L]</p></blockquote>
<p>I used this one with a multi-site Drupal setup where the image paths wound up being something such as http://[domain]/sites/[domain]/files/images/image.jpg. Afterwards the URL was: http://[domain]/images/image.jpg.</p>
<p><strong>References and Resources:</strong><br />
<a title="Apache Rewrite Guide" href="http://httpd.apache.org/docs/1.3/misc/rewriteguide.html" target="_blank">Apache Rewrite Guide and Examples</a><br />
<a title="mod_rewrite Cheat Sheet" href="http://gallery.derekneely.com/images/references_and_resources/geeky_cheat_sheets/mod_rewrite-cheat-sheet-v2.png" target="_blank">mod_rewrite Cheat Sheet</a></p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/05/adventures-in-apache-rewrite-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bwm-ng (command line bandwidth monitor)</title>
		<link>http://derekneely.com/2009/05/bwm-ng/</link>
		<comments>http://derekneely.com/2009/05/bwm-ng/#comments</comments>
		<pubDate>Fri, 22 May 2009 02:47:54 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Applications]]></category>
		<category><![CDATA[bwm-ng]]></category>
		<category><![CDATA[System Tools]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=67</guid>
		<description><![CDATA[bwm-ng is a great little command line bandwidth monitor. HUGE fan. Its available with most all distros so use your favorite package manager to add it. Works on all *nix distributions including the Mac too. bwm-ng home page: http://www.gropp.org/?id=projects&#38;sub=bwm-ng On the Mac it works great with a little application called GeekTool (will cover more later) [...]]]></description>
			<content:encoded><![CDATA[<p><a title="bwm-ng" href="http://www.gropp.org/?id=projects&amp;sub=bwm-ng" target="_blank">bwm-ng</a> is a great little command line bandwidth monitor. HUGE fan. Its available with <img class="alignright" title="Terminal" src="http://derekneely.com/MyImages/Icons/terminal.png" alt="" width="131" height="116" />most all distros so use your favorite package manager to add it. Works on all *nix distributions including the Mac too.</p>
<p>bwm-ng home page: <a title="bwm-ng" href="http://www.gropp.org/?id=projects&amp;sub=bwm-ng" target="_blank">http://www.gropp.org/?id=projects&amp;sub=bwm-ng</a></p>
<p>On the Mac it works great with a little application called <a title="GeekTool" href="http://projects.tynsoe.org/en/geektool/" target="_blank">GeekTool</a> (will cover more later) with the following options:</p>
<blockquote><p>/Users/derek/Applications/bwm-ng/bin/bwm-ng -o plain -c 1</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/05/bwm-ng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gentoo XFCE4 Install (issue resolved)</title>
		<link>http://derekneely.com/2009/05/gentoo-xfce4-install-issue-resolved/</link>
		<comments>http://derekneely.com/2009/05/gentoo-xfce4-install-issue-resolved/#comments</comments>
		<pubDate>Fri, 22 May 2009 01:07:04 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[XFCE4]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=60</guid>
		<description><![CDATA[Per a co-workers recommendation for my old thinkpad I enherited from me mom, I&#8217;m installing XFCE4 instead of Gnome on my Gentoo lappy (http://www.gentoo.org/doc/en/xfce-config.xml). I ran into a pretty big issue where I could not get &#8216;media-libs/netpbm&#8217; installed. Well, after numerous: &#8216;emerge &#8211;depclean&#8217; and &#8216;emerge &#8211;update &#8211;newuse world&#8217;s I&#8217;ve finally got it installed. There seemed [...]]]></description>
			<content:encoded><![CDATA[<p>Per a co-workers recommendation for my old thinkpad I enherited from me mom, I&#8217;m <a href="http://www.gentoo.org"><img class="alignright" title="Gentoo" src="http://derekneely.com/MyImages/Icons/gentoo.png" alt="" width="104" height="111" /></a>installing XFCE4 instead of Gnome on my Gentoo lappy (<a title="Gentoo XFCE4 Install" href="http://www.gentoo.org/doc/en/xfce-config.xml" target="_blank">http://www.gentoo.org/doc/en/xfce-config.xml</a>). I ran into a pretty big issue where I could not get &#8216;media-libs/netpbm&#8217; installed. Well, after numerous: &#8216;emerge &#8211;depclean&#8217; and &#8216;emerge &#8211;update &#8211;newuse world&#8217;s I&#8217;ve finally got it installed. There seemed to be an issue with &#8216;getline&#8217; which after some research is part of a C++ library. Well, I wound up seeing that the folowing packages weren&#8217;t even installed:</p>
<blockquote><p>sys-libs/libstdc++-v3<br />
virtual/libstdc++</p></blockquote>
<p>I&#8217;m not sure which exactly did it, but I installed both and was able to get netpbm installed. Whoohoo!</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/05/gentoo-xfce4-install-issue-resolved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

