<?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>Development Cycle &#187; Sysadmin</title>
	<atom:link href="http://www.development-cycle.com/category/sysadmin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.development-cycle.com</link>
	<description>Binary Bits &#38; Pieces</description>
	<lastBuildDate>Fri, 04 May 2012 05:21:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Quick Recursive Code Count</title>
		<link>http://www.development-cycle.com/2012/05/quick-recursive-code-count/</link>
		<comments>http://www.development-cycle.com/2012/05/quick-recursive-code-count/#comments</comments>
		<pubDate>Fri, 04 May 2012 05:18:03 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Project Metrics]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=548</guid>
		<description><![CDATA[Although the &#8220;lines of code&#8221; in a project is not the worlds most useful metric. Curiosity sometimes gets the better of us and after many days / weeks of typing you think &#8220;gee I wonder exactly how many lines of code are in that project?&#8221;. Wonder no more! By embracing the power of the command [...]]]></description>
			<content:encoded><![CDATA[<p>Although the &#8220;lines of code&#8221; in a project is not the worlds most useful metric. Curiosity sometimes gets the better of us and after many days / weeks of typing you think &#8220;gee I wonder exactly how many lines of code are in that project?&#8221;.</p>
<p>Wonder no more! By embracing the power of the command line you can easily count the lines in every file recursively. Simply execute the following line in the directory of your project (changing .php to the file extension of the files you would like to count the line of):</p>
<p>find . -name &#8216;*.php&#8217; | xargs wc -l</p>
<p><span id="more-548"></span></p>
<p>This will give you a simple breakdown for your project that looks similar to below:</p>
<p>59 ./upload-video.php<br />
15 ./views/settings/configuration_required.php<br />
215 ./views/settings/plugin-settings.php<br />
66 ./views/playlist-management/edit-playlist.php<br />
91 ./views/playlist-management/playlist-management.php<br />
57 ./views/playlist-management/reorder-playlist.php<br />
74 ./views/playlist-management/create-playlist.php<br />
60 ./views/video-management/play-playlist.php<br />
117 ./views/video-management/existing-videos.php<br />
59 ./views/video-management/upload-video.php<br />
44 ./views/video-management/play-video.php<br />
25 ./views/video-management/preview-video.php<br />
58 ./includes/shared.php<br />
29 ./includes/reorder_playlist.php<br />
40 ./includes/plugin_setup.php<br />
100 ./includes/playlist_management.php<br />
1921 ./includes/s3.php<br />
40 ./includes/video_tracking.php<br />
371 ./s3-video.php<br />
3441 total</p>
<p>Sure its not the most detailed or elegant report but its quick and gives you a code count of your project with a minimum of fuss.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2012/05/quick-recursive-code-count/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace The Default Firefox Google Search In Linux Mint</title>
		<link>http://www.development-cycle.com/2011/08/replace-the-default-firefox-google-search-in-linux-mint/</link>
		<comments>http://www.development-cycle.com/2011/08/replace-the-default-firefox-google-search-in-linux-mint/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 11:56:14 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Linux Mint]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=524</guid>
		<description><![CDATA[The recent release of Ubuntu&#8217;s Natty Narwhal forced me to reassess my usage of Ubuntu on my work and home machines. As I found the Unity interface drives me crazy and the release on a whole to be very buggy. So I decided to give Linux Mint a go, it has grown in popularity (#2 [...]]]></description>
			<content:encoded><![CDATA[<p>The recent release of Ubuntu&#8217;s Natty Narwhal forced me to reassess my usage of Ubuntu on my work and home machines. As I found the Unity interface drives me crazy and the release on a whole to be very buggy. So I decided to give Linux Mint a go, it has grown in popularity (<a title="Linux Distrowatch" href="http://distrowatch.com/">#2 according to Distrowatch</a>)  over the last few years so I figured they must be doing something right and Linux Mint 11 still uses no frills Gnome 2.32.</p>
<p>The migration went smooth, but by default the Linux Mint Firefox Google search functionality is useless, but luckily it wasn&#8217;t too much effort to fix.<br />
<span id="more-524"></span><br />
<img class="aligncenter size-full wp-image-528" title="linux_mint_google" src="http://www.development-cycle.com/wp-content/uploads/2011/08/linux_mint_google1.png" alt="" width="574" height="198" /></p>
<p>First step is to change the home page by choosing &#8220;preferences&#8221; from the &#8220;edit&#8221; toolbar and changing the URL on the general tab. This still doesn&#8217;t help your results though if you search for something in the search box in the top right corner of the browser. To fix this <a title="Firefox Search Provider Plugins" href="http://mycroft.mozdev.org/google-search-plugins.html" target="_blank">head to this site, and look down the page until you find the link for your countries Google</a> search. Click the link and it will be added to the search providers in the search box.</p>
<p><img class="aligncenter size-full wp-image-527" title="Google_Australia_Search" src="http://www.development-cycle.com/wp-content/uploads/2011/08/Google_Australia_Search.png" alt="" width="831" height="85" /> To remove the Linux Mint search provider and make your selected plugin default click on the search provider icon on the left hand side of the search box and select &#8220;manage search engines&#8221;. Select the default and click the remove button, then highlight your chosen provider and simply move to the top of the list with the &#8220;move up&#8221; button.</p>
<p><img class="aligncenter size-full wp-image-529" title="Manage Search Engines" src="http://www.development-cycle.com/wp-content/uploads/2011/08/manage_search_engines.png" alt="" width="465" height="377" /></p>
<p><strong>Related Posts:</strong></p>
<p><strong></strong><a title="Restore The Refresh Button Placement In Firefox 4" href="http://www.development-cycle.com/2011/03/restore-the-refresh-button-placement-in-firefox-4/">Restore The Refresh Button Placement In Firefox 4</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/08/replace-the-default-firefox-google-search-in-linux-mint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Anonymizing CURL Scripts With TOR &amp; Polipo</title>
		<link>http://www.development-cycle.com/2011/08/anonymizing-curl-scripts-with-tor-polipo/</link>
		<comments>http://www.development-cycle.com/2011/08/anonymizing-curl-scripts-with-tor-polipo/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 10:45:09 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[Polipo]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[TOR]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=511</guid>
		<description><![CDATA[Last week I received a typical run of the mill phishing email littered with the usual bad Engrish making the instructions far from believable but being bored I decided to take a look at the link they were pushing. They had created a believable enough looking Paypal form asking clueless punters to enter their credit [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="TOR Logo" src="http://www.development-cycle.com/files/u1/tor_logo.png" alt="" width="200" height="127" />Last week I received a typical run of the mill phishing email littered with the usual bad Engrish making the instructions far from believable but being bored I decided to take a look at the link they were pushing.</p>
<p>They had created a believable enough looking Paypal form asking clueless punters to enter their credit card details in order to avoid having their account being suspended. After playing around with the form for <a title="Firefox Web Development Extension" href="http://getfirebug.com/" target="_blank">awhile in Firebug</a> I decided to create a quick script to poison their data by submitting a new fake 16 digit VISA number along with random card holder name, CVV number and expiry date every couple of seconds.</p>
<p>After running this script for half an hour I decided that the script while it did the job would be a lot better if the posted data was coming from an anonymous IP address. Here I will run you through the process of setting up TOR &amp; Polipo on a machine to add an element of anonymity to the data being sent and received by your CURL based script using.<br />
<span id="more-511"></span><br />
<strong>Installation &amp; Configuration</strong><br />
I am going to use Debian 6 in my examples although getting everything working on your distro of choice shouldn&#8217;t be too complicated.</p>
<p><em>apt-get update</em><br />
<em> apt-get install tor polipo</em></p>
<p>TOR is very easy to use and should straight run out of the box without any configuration, but if you plan on running Polipo on a different box to the TOR service or want to run the service on a different port to the default 9050 you will need to edit the config file at /etc/tor-tsock.conf.</p>
<p>The Polipo configuration is a little more in-depth with a few changes that will have to be made so that the service can forward incoming requests to TOR. Edit the Polipo config file:</p>
<p><em>pico /etc/polipo/config</em></p>
<p>Uncomment line 17 with the &#8220;<em>proxyAddress&#8221;</em> directive and add the external IP address of your machine, mine is set to:</p>
<p><em>proxyAddress = &#8220;192.168.20.123&#8243;</em></p>
<p>Go down to line 23 uncomment the &#8220;<em>allowedClients</em>&#8221; directive and edit to suit your needs in my case its:</p>
<p><em>allowedClients = 127.0.0.1, 192.168.20.0/24</em></p>
<p>Also edit line 40 with the directive <em>&#8220;socksParentProxy&#8221;</em> and change it to point at your TOR service mine is:</p>
<p><em>socksParentProxy = &#8220;localhost:9050&#8243;</em></p>
<p>Uncomment line 41 with the <em>&#8220;socksProxyType</em>&#8221; directive and also uncomment lines 115 &amp; 116 for a bit more security.</p>
<p>Restart the Polipo service so your changes to the configuration file take effect:</p>
<p><em>/etc/init.d/polipo restart</em></p>
<p><strong>Proxy Testing</strong></p>
<p>Its now time to test the set-up and see if its working correctly. I find this test is performed easiest using a browser, simply configure your browser to use your Polipo proxy and visit the site <a title="Find Out Your Current IP Address" href="http://www.whatismyip.com/" target="_blank">whatismyip.com</a>. With any luck you will appear to be coming from a completely different IP to your normal network gateway address.</p>
<p><em>Protip:</em> If you want to use the proxy for anonymous browsing as well, I recommend using the <a title="Foxy Proxy Firefox Plugin" href="https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/" target="_blank">Foxy Proxy plugin for Firefox as it makes switching between</a> your normal gateway and proxies a breeze.</p>
<p><strong>Configuring CURL</strong><br />
By now you should have a configured and tested proxy service now its just a case of fo configuring your script to use the proxy. To use a proxy from CURL you simply need to add the <em>CURLOPT_PROXY</em> option to your script with the IP address and port of your proxy service i.e</p>
<p><em>curl_setopt($ch, CURLOPT_PROXY, &#8216;http://192.168.20.123:8123&#8242;);</em></p>
<p><strong>Further Reading:</strong><br />
<a title="Polipo Homepage" href="http://www.pps.jussieu.fr/~jch/software/polipo/" target="_blank">Polipo Homepage</a><br />
<a title="The Onion Router Project Homepage" href="https://www.torproject.org/" target="_blank">TOR Homepage</a></p>
<p><strong>Related Reading:</strong><br />
<a title="Installing TOR Onion Router On Ubuntu 8.0.4 (Hardy Heron)" href="http://www.development-cycle.com/2008/07/tor-on-ubuntu-hardy/">Installing TOR On Ubuntu 8.04</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/08/anonymizing-curl-scripts-with-tor-polipo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Near Realtime File Replication With Lsyncd</title>
		<link>http://www.development-cycle.com/2011/07/near-realtime-file-replication-with-lsyncd/</link>
		<comments>http://www.development-cycle.com/2011/07/near-realtime-file-replication-with-lsyncd/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 08:28:46 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOs]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Lua]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=436</guid>
		<description><![CDATA[Ever wanted real time backups of  directories on your server? To replicate static media files for a website to a separate box to reduce load? An easy solution lays with lsyncd it allows you to watch a directory structure on your file system, and replicate any changes on a remote system. How It Works: inotify [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted real time backups of  directories on your server? To replicate static media files for a website to a separate box to reduce load? An easy <a title="lsyncd home a Google Code" href="http://code.google.com/p/lsyncd/" target="_blank">solution lays with lsyncd</a> it allows you to watch a directory structure on your file system, and replicate any changes on a remote system.</p>
<p title="Rsync Software Homepage"><strong>How It Works:</strong><br />
<a title="inotify wikipedia page" href="http://en.wikipedia.org/wiki/Inotify" target="_blank">inotify is a Linux subsystem available</a> from the 2.6.13 release of the Linux kernel that monitors changes made to a file system and reports these changes to interested applications. lsyncd is an application <a title="The Lua Programming Language" href="http://www.lua.org/" target="_blank">written in lua</a> that uses the inotify service to inform it of changes made to monitored directories and then when notified of a change <a title="Rsync Software Homepage" href="http://rsync.samba.org/" target="_blank">uses rsync to replicate</a> the changes on a remote service.</p>
<p><strong>Getting lsyncd</strong><br />
The <a title="lsyncd downloads" href="http://code.google.com/p/lsyncd/downloads/list" target="_blank">lsyncd sourcecode can be downloaded from Google Code</a> and compiled but depending on the distribution your server is running, the install process be even easier as lsyncd is included in the repositories of many popular Linux distros.</p>
<p><strong>Installing On Debian / Ubuntu</strong><br />
While lsyncd is included in both the repositories of Debian and Ubuntu but unfortunately its an outdated version so check what version you are going to get beforehand with the command:</p>
<p><em>apt-cache show lsyncd</em></p>
<p>If apt-cache tells you that only one of the 1.x versions are available, I would recommend grabbing one of the 2.x versions from the <a title="Debian GNU / Linux" href="http://www.debian.org/" target="_blank">Debian</a> testing repository instead, the <a title="lsyncd 2.0.4 package for amd64" href="http://packages.debian.org/wheezy/amd64/lsyncd/download or the i386" target="_blank">amd64 package can be found here</a>  and one for the <a title="i386 Debian lsyncd 2.0.4 package" href="http://packages.debian.org/wheezy/i386/lsyncd/download" target="_blank">i386 architecture here</a>. Then install using the dpkg command i.e</p>
<p><em>cd /root</em><br />
<em> wget wget http://ftp.au.debian.org/debian/pool/main/l/lsyncd/lsyncd_2.0.4-1_amd64.deb</em><br />
<em> apt-get install lua5.1 rsync</em><br />
<em> dpkg -i lsyncd_2.0.4-1_amd64.deb</em></p>
<p><span id="more-436"></span><strong>CentOS 5 Installation</strong></p>
<p><em>yum install lsyncd.x86_64</em></p>
<p><strong>Preparation</strong><br />
First step for getting started with lsync over two hosts is to create a shared SSH key to allow authentication without a password.</p>
<p><em>ssh-keygen</em></p>
<p>Now transfer the servers newly generated public key to the second server you are going to mirror content to.</p>
<p><em>scp ~/.ssh/id_rsa.pub root@my2ndserver:/tmp</em></p>
<p>After copying the file the second server add the public key to the ssh <em>authorized_keys</em> file.</p>
<p><em>cat /tmp/id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys</em></p>
<p>While you are logged into the second machine also double check that rsync is installed and install it if it isn&#8217;t. Now decide the directory you would like to mirror across your machines. In this example I am just going to keep it simple by starting fresh and creating a new directory in the same location on both of my servers:</p>
<p><em>mkdir /home/mirror</em></p>
<p><strong>Quick Test Run</strong><br />
<em>cd /home/mirror</em><br />
<em>touch test_file</em><br />
<em>lsyncd -log all -nodaemon -rsyncssh /home/mirror sync@my2ndserver /home/mirror</em></p>
<p>(<em><strong>Note:</strong></em> Unlike the <a title="Secure Copy Manpage" href="http://linux.die.net/man/1/scp" target="_blank">scp command</a> the target host and directory are given as two separate arguments to lsyncd at the command line)</p>
<p>Which should produce output that looks something similar to:</p>
<p><em>kernels clocks_per_sec=100</em><br />
<em>Call: configure()</em><br />
<em>Inotify: inotify fd = 3</em><br />
<em>Call: initialize()</em><br />
<em>10:08:17 Function: Inotify.addWatch(/home/mirror/, (true), (nil), (nil))</em><br />
<em>10:08:17 Inotify: addwatch(/home/mirror/)-&gt;1</em><br />
<em>10:08:17 Normal: recursive startup rsync: /home/mirror/ -&gt; sync@192.168.20.127:/home/mirror/</em><br />
<em>10:08:17 Exec: /usr/bin/rsync [--delete] [-r] [-lts] [/home/mirror/] [sync@192.168.20.127:/home/mirror/]</em><br />
<em>10:08:17 Call: getAlarm()</em><br />
<em>10:08:17 Debug: getAlarm returns: (false)</em><br />
<em>10:08:17 Masterloop: going into select (no timeout).</em><br />
<em>10:08:17 Call: collectProcess()</em><br />
<em>10:08:17 Delay: collected an event</em><br />
<em>10:08:17 Normal: Startup of &#8216;/home/mirror/&#8217; finished.</em><br />
<em>10:08:17 Normal: Finished Blanket on /home/mirror/ = 0</em><br />
<em>10:08:17 Delay: Finish of Blanket on /home/mirror/ = 0</em><br />
<em>10:08:17 Call: cycle()</em><br />
<em>10:08:17 Function: invokeActions(&#8216;Sync1&#8242;,(Timestamp: 17184171.29))</em><br />
<em>10:08:17 Call: getAlarm()</em><br />
<em>10:08:17 Debug: getAlarm returns: (false)</em><br />
<em>10:08:17 Masterloop: going into select (no timeout).</em></p>
<p>Look in the mirror directory on the second server and with any luck you should see your test file has migrated across from the first server.</p>
<p><strong>Potential Issues</strong><br />
When performing the test run you may get some output that appears similar to the text below:</p>
<p><em>kernels clocks_per_sec=100</em><br />
<em>Call: configure()</em><br />
<em>Inotify: inotify fd = 3</em><br />
<em>Call: initialize()</em><br />
<em>10:14:39 Function: Inotify.addWatch(/home/mirror/, (true), (nil), (nil))</em><br />
<em>10:14:39 Inotify: addwatch(/home/mirror/)-&gt;1</em><br />
<em>10:14:39 Normal: recursive startup rsync: /home/mirror/ -&gt; root@192.168.20.131:/home/mirror/</em><br />
<em>10:14:39 Exec: /usr/bin/rsync [--delete] [-r] [-lts] [/home/mirror/] [root@192.168.20.131:/home/mirror/]</em><br />
<em>10:14:39 Call: getAlarm()</em><br />
<em>10:14:39 Debug: getAlarm returns: (false)</em><br />
<em>10:14:39 Masterloop: going into select (no timeout).</em><br />
<em>rsync: on remote machine: -sltre.iLsf: unknown option</em><br />
<em>rsync error: syntax or usage error (code 1) at main.c(1231) [server=2.6.8]</em><br />
<em>rsync: connection unexpectedly closed (0 bytes received so far) [sender]</em><br />
<em>rsync error: error in rsync protocol data stream (code 12) at io.c(601) [sender=3.0.7]</em><br />
<em>10:14:39 Call: collectProcess()</em><br />
<em>10:14:39 Delay: collected an event</em><br />
<em>10:14:39 Error: Failure on startup of &#8216;/home/mirror/&#8217;.</em></p>
<p>This tends to happen if you are using an older version of rsync on the 2nd server, no need to stress though I found when creating a config file for lysncd removing the -s rsync option seemed to solve this issue.</p>
<p><strong>Creating A Config File</strong><br />
Fire up your preferred editor and create a new file to store your configuration:</p>
<p><em>nano /etc/lsyncd.conf</em></p>
<p>With the contents:</p>
<p><em>settings = {</em><br />
<em>   logfile    = &#8220;/var/log/lsyncd.log&#8221;,</em><br />
<em>}</em></p>
<p><em>sync{default.rsync, source=&#8221;/home/mirror&#8221;, target=&#8221;192.168.20.131:/home/mirror&#8221;, rsyncOps=&#8221;-rltvu&#8221;}</em></p>
<p>Then start the deamon with the comand:</p>
<p><em>lsyncd /etc/lsyncd.conf</em></p>
<p>This will start the daemon in the background, go create a new file in your mirror directory then watch the log with the tail command:</p>
<p><em>tail -f /var/log/lsyncd.log</em></p>
<p>With any luck you should be able to see your newly created file getting picked up by lsyncd and mirrored on your second server.</p>
<p><em>Sun Jul 17 11:03:09 2011 Normal: Calling rsync with filter-list of new/modified files/dirs</em><br />
<em>/myfile.txt</em><br />
<em>/</em><br />
<em>building file list &#8230; done</em><br />
<em>./</em><br />
<em>myfile.txt</em></p>
<p><em>sent 139 bytes  received 48 bytes  374.00 bytes/sec</em><br />
<em>total size is 0  speedup is 0.00</em><br />
<em>Sun Jul 17 11:03:09 2011 Normal: Finished a list = 0</em></p>
<p>As you can see the process is not instantaneous with around a 5 &#8211; 15 second delay before initiating a transfer and obviously the delay while the file itself transfers across but it is handy for backups and other situations where a small delay is not too much of a concern.</p>
<p><strong>Further Reading:</strong></p>
<p><a title="lsyncd manual" href="http://code.google.com/p/lsyncd/wiki/Lsyncd20Manual" target="_blank">The lsyncd manual<strong></strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/07/near-realtime-file-replication-with-lsyncd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tracking Bandwidth Usage With vnStat</title>
		<link>http://www.development-cycle.com/2011/07/tracking-bandwidth-usage-with-vnstat/</link>
		<comments>http://www.development-cycle.com/2011/07/tracking-bandwidth-usage-with-vnstat/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 06:06:01 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOs]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[vnStat]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=383</guid>
		<description><![CDATA[Outside of internal networks bandwidth is paid often for by the gigabyte and as such it becomes important to be able to see the bandwidth consumption of machines and plan future quotas accordingly as usage grows. There are plenty of packages available that fill this void like darkstat, ntop etc, but they tend to be [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.development-cycle.com/wp-content/uploads/2011/07/utp_cable.png"><img class="alignright size-full wp-image-384" title="utp_cable" src="http://www.development-cycle.com/wp-content/uploads/2011/07/utp_cable.png" alt="" width="200" height="119" /></a>Outside of internal networks bandwidth is paid often for by the gigabyte and as such it becomes important to be able to see the bandwidth consumption of machines and plan future quotas accordingly as usage grows. There are plenty of packages available that fill this void like <a title="Darkstat network graphing" href="http://unix4lyfe.org/darkstat/" target="_blank">darkstat</a>, <a title="ntop software" href="http://humdi.net/vnstat/" target="_blank">ntop</a> etc, but they tend to be overkill in a lot of situations were you don&#8217;t need pretty graphs you just want to know how much data is entering and leaving an interface.  Enter vnStat a simple console based tool that allows you to monitor traffic flow to and from interfaces on your servers.<br />
<span id="more-383"></span><br />
<strong>Installing vnStat</strong></p>
<p>On a Debian / Ubuntu based machine simply execute:</p>
<p><em>apt-get update</em><br />
<em>apt-get install vnstat</em></p>
<p>CentOS is a little more difficult here as vnStat is unfortunately not available in the default repositories so you will have to grab it from a 3rd party source.</p>
<p><em>rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm</em><br />
<em>yum install vnstat</em></p>
<p>Now that vnStat is installed on your system you need to initialise a database to store information for the interface you would like to monitor. For example the command below would create a database for the eth0 interface:</p>
<p><em>sudo vnstat -u -i eth0</em></p>
<p>This will give a message similar to:</p>
<p><em>Error:</em><br />
<em>Unable to read database &#8220;/var/lib/vnstat/eth0&#8243;.</em><br />
<em>-&gt; A new database has been created.</em></p>
<p>After this you just have to give it some time to start gathering data if you run the command before it has enough data for the chosen interface you will get an error similar to:</p>
<p><em>eth0: Not enough data available yet.</em></p>
<p><strong>Reporting</strong></p>
<p>After vnStat has enough data getting information backout is easy for a high level summary simply execute the command on its on for a report similar to:</p>
<p><em>Database updated: Tue Jul  5 15:15:01 2011</em></p>
<p><em>    eth0</em></p>
<p><em>       received:       9.90 GB (7.5%)</em><br />
<em>    transmitted:     122.09 GB (92.5%)</em><br />
<em>          total:     131.99 GB</em></p>
<p><em>                    rx     |     tx     |  total</em><br />
<em>    &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;</em><br />
<em>    yesterday      4.04 MB |    6.82 MB |   10.86 MB</em><br />
<em>        today      2.64 MB |    4.20 MB |    6.84 MB</em><br />
<em>    &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;</em><br />
<em>    estimated         3 MB |       6 MB |       9 MB</em></p>
<p>For a look at bandwidth usage per day over the last 30 days simply add the -d flag.<br />
<em>vnstat -i eth0 -d</em></p>
<p>To see a breakdown of the last 7 days, the current week and the previous week use the -w flag.<br />
<em>vnstat -i eth0 -w</em></p>
<p>Last but not least if you want a monthly breakdown of bandwidth usage use the -m flag.<br />
<em>vnstat -i eth0 -m</em></p>
<p><strong>Reports delivered straight to you</strong><br />
Logging in and running the command to get your usage is one thing but in the long run you are probably going to want something a bit more automated. The solution, run the vnstat command as a cron job and email the output to yourself with something similar to below:</p>
<p><em>55 22 * * 6 /usr/bin/vnstat -i eth0 -w | /usr/bin/mail myemail@mailserver.com -s &#8220;host.myserver.com Weekly Bandwidth stats&#8221; &gt; /dev/null 2&gt;&amp;1</em></p>
<p><strong>Related Links:</strong></p>
<p><a title="vnStat bandwidth monitoring " href="http://humdi.net/vnstat/" target="_blank">The home of vnStat</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/07/tracking-bandwidth-usage-with-vnstat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu Natty Narwhal Invisible Scroll Bars In Eclipse</title>
		<link>http://www.development-cycle.com/2011/05/ubuntu-natty-narwhal-invisible-scroll-bars-in-eclipse/</link>
		<comments>http://www.development-cycle.com/2011/05/ubuntu-natty-narwhal-invisible-scroll-bars-in-eclipse/#comments</comments>
		<pubDate>Wed, 04 May 2011 12:44:06 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[11.04]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Natty Narwhal]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=297</guid>
		<description><![CDATA[Since its release on April 28th Natty Narwhal (11.04) seems to have gained it fair share of haters. The Unity interface is a huge change to the UI and in most peoples experience its buggy and doesn&#8217;t seem ready for the prime time. No issue I thought after I upgraded I will just use the [...]]]></description>
			<content:encoded><![CDATA[<p>Since its release on April 28th Natty Narwhal (11.04) seems to have gained it fair share of haters. The Unity interface is a huge change to the UI and in most peoples experience its buggy and doesn&#8217;t seem ready for the prime time.</p>
<p>No issue I thought after I upgraded I will just use the &#8220;Ubuntu Classic&#8221; option at login until the new Unity interface matures, unfortunately whilst coding in Eclipse earlier today I noticed using the classic interface or not some issues are still there. I was looking at a wide piece of code in Eclipse and started to become alarmed, what the hell has happened to my editors scroll bars? </p>
<p>I didn&#8217;t really pick up on the missing vertical scroll straight away as the scroll wheel on the mouse still got me where I was headed without issue, but I was left without any easy way to browse to the far right if the code was wider than the display area.</p>
<p><img class="aligncenter size-full wp-image-299" title="no_scrollbars" src="http://www.development-cycle.com/wp-content/uploads/2011/05/no_scrollbars.png" alt="No Horizontal Scrollbar in Eclipse" width="450" height="59" /></p>
<p>I am told the scroll bars are supposed to appear when the mouse hovers in their vicintiy although this doesn&#8217;t seem to happen when using Eclipse at present. Luckily it seems pretty easy to fix, I just wrote a 3 line bash file that gives me back the classic scroll bars I have come to love.</p>
<div><em>#!/bin/sh</em></div>
<div><em>LIBOVERLAY_SCROLLBAR=0 eclipse</em></div>
<div><em>/usr/bin/eclipse</em></div>
<p></p>
<p>Simply saved the file made it executable with:</p>
<div><em>chmod +x start_eclipse.sh</em></div>
<p></p>
<p>Updated my menu and desktop shortcuts to point to my script rather than directly to the Eclipse executable, restarted the application and thankfully problem solved!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/05/ubuntu-natty-narwhal-invisible-scroll-bars-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Easily Rip Youtube Videos On Ubuntu Maverick</title>
		<link>http://www.development-cycle.com/2011/03/easily-rip-youtube-videos-on-ubuntu-maverick/</link>
		<comments>http://www.development-cycle.com/2011/03/easily-rip-youtube-videos-on-ubuntu-maverick/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 01:50:09 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[Youtube]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=277</guid>
		<description><![CDATA[Downloading youtube videos to your local machine for offline veiwing is easily on Ubuntu 10.10 with the youtube-dl utility. Simply open a terminal window and execute: apt-get update apt-get install youtube-dl You can run the command with the url of the youtube video you would like to download e.g youtube-dl &#8220;http://www.youtube.com/watch?v=0cbTPKmjHl8&#8243; If the output comes [...]]]></description>
			<content:encoded><![CDATA[<p>Downloading youtube videos to your local machine for offline veiwing is easily on Ubuntu 10.10 with the <a title="youtube-dl at Github" href="http://rg3.github.com/youtube-dl/" target="_blank">youtube-dl utility</a>.</p>
<p>Simply open a terminal window and execute:</p>
<p><em>apt-get update</em><br />
<em> apt-get install youtube-dl</em></p>
<p><span id="more-277"></span></p>
<p>You can run the command with the url of the youtube video you would like to download e.g</p>
<p><em>youtube-dl &#8220;http://www.youtube.com/watch?v=0cbTPKmjHl8&#8243;</em></p>
<p>If the output comes back with the error below you may have to update your copy of youtube-dl.</p>
<p><em>[youtube] Setting language</em><br />
<em> [youtube] 0cbTPKmjHl8: Downloading video webpage</em><br />
<em> [youtube] 0cbTPKmjHl8: Downloading video info webpage</em><br />
<em> [youtube] 0cbTPKmjHl8: Extracting video information</em><br />
<em> ERROR: unable to download video (format may not be available)</em></p>
<p>Luckily update process is very easy, simply execute run youtube-dl as a superuser with the -U option.</p>
<p><em>sudo youtube-dl -U</em><br />
<em> Updating to latest stable version&#8230;</em><br />
<em> Updated to version github</em></p>
<p>Chances are you will have to run the command twice, to update it properly on the second run it will output something similar to below:</p>
<p><em>sudo youtube-dl -U</em><br />
<em> Updating to latest stable version&#8230;</em><br />
<em> Updated to version 2011.02.25c</em></p>
<p>Now if you try and grab the video you wanted again you should be successful.</p>
<p><em>youtube-dl &#8220;http://www.youtube.com/watch?v=0cbTPKmjHl8&#8243;</em><br />
<em> [youtube] Setting language</em><br />
<em> [youtube] 0cbTPKmjHl8: Downloading video webpage</em><br />
<em> [youtube] 0cbTPKmjHl8: Downloading video info webpage</em><br />
<em> [youtube] 0cbTPKmjHl8: Extracting video information</em><br />
<em> [download] Destination: 0cbTPKmjHl8.mp4</em><br />
<em> [download] 100.0% of 24.21M at  192.89k/s ETA 00:00 </em></p>
<p>The file will be save in your current directory and will look something similar to 0cbTPKmjHl8.mp4, you can then open this file up in VLC or movie player to ensure it downloaded correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/03/easily-rip-youtube-videos-on-ubuntu-maverick/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disabling CPU Scaling With Ubuntu 10.04</title>
		<link>http://www.development-cycle.com/2010/05/disabling-cpu-scaling-with-ubuntu-10-04/</link>
		<comments>http://www.development-cycle.com/2010/05/disabling-cpu-scaling-with-ubuntu-10-04/#comments</comments>
		<pubDate>Thu, 06 May 2010 06:19:10 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[10.04]]></category>
		<category><![CDATA[Lucid Lynx]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=268</guid>
		<description><![CDATA[If your like me it annoys you that your desktop keeps messing with your CPU speeds when all you wan&#8217;t is performance. Fortunately its easy enough to fix. Open a terminal windows and execute: sudo apt-get update sudo apt-get install rcconf (Chances are you may already have the rcconf installed.) sudo rcconf Scroll down the [...]]]></description>
			<content:encoded><![CDATA[<p>If your like me it annoys you that your desktop keeps messing with your CPU speeds when all you wan&#8217;t is performance. Fortunately its easy enough to fix.</p>
<p>Open a terminal windows and execute:</p>
<p><em>sudo apt-get update</p>
<p>sudo apt-get install rcconf</em></p>
<p>(Chances are you may already have the rcconf installed.)</p>
<p><em>sudo rcconf</em></p>
<p>Scroll down the list of services till you find the service labelled &#8220;Ondemand&#8221;, this is the service that controls the CPU scaling. Unselect the option and hit Ok to exit, now when you reboot your system should run at full speed all the time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2010/05/disabling-cpu-scaling-with-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu Lucid Lynx A Quick Look</title>
		<link>http://www.development-cycle.com/2010/04/ubuntu-lucid-lynx-a-quick-look/</link>
		<comments>http://www.development-cycle.com/2010/04/ubuntu-lucid-lynx-a-quick-look/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 08:43:07 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[10.04]]></category>
		<category><![CDATA[Lucid Lynx]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=238</guid>
		<description><![CDATA[The newest Long Term Support (LTS) version of the Ubuntu distro labelled Lucid Lynx was released earlier today. This release is packed with new packages and enhancements, making me keen to try it out. Not being brave enough to gamble with my current desktop machine running Karmic Koala I decided to download the .iso and [...]]]></description>
			<content:encoded><![CDATA[<p>The newest <a rel="nofollow" href="https://wiki.ubuntu.com/LTS" target="_blank">Long Term Support (LTS)</a> version of the Ubuntu distro labelled Lucid Lynx was released earlier today. This release is packed with new packages and enhancements, making me keen to try it out. Not being brave enough to gamble with my current desktop machine running Karmic Koala I decided to download the .iso and play with it in a virtual machine first to give me a feel of what to expect.</p>
<p><span id="more-238"></span></p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/1-e1272606802434.png"><img class="aligncenter size-full wp-image-239" title="Virtual Box Setup" src="http://www.development-cycle.com/wp-content/uploads/2010/04/1-e1272606802434.png" alt="" width="500" height="371" /></a><strong>VM Setup In Virtual Box</strong></p>
<p>To have a bit of a play first up I set up a virtual machine using <a title="Sun Virtual Box" href="http://www.virtualbox.org/" target="_blank">VirtualBox</a> with 2099MB Ram and a 25GB hard drive.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/2.png"><img class="aligncenter size-full wp-image-240" title="Lucid Lynx Language Selection" src="http://www.development-cycle.com/wp-content/uploads/2010/04/2.png" alt="" width="500" height="375" /></a>Lucid Lynx has apparently made alot of positive changes to the installation process, unfortunately though by force of habit I had down loaded the &#8220;alternate&#8221; install image.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/10.png"><img class="aligncenter size-full wp-image-243" title="Installing the base system" src="http://www.development-cycle.com/wp-content/uploads/2010/04/10.png" alt="" width="500" height="145" /></a>Installing the system&#8230;.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/16.png"><img class="aligncenter size-full wp-image-244" title="Installation Complete" src="http://www.development-cycle.com/wp-content/uploads/2010/04/16.png" alt="" width="500" height="218" /></a></p>
<p>Having used the alternate install disc the install process was pretty uneventful and took a little over 40 minutes to complete. Although this would of probably been a bit quicker had I been installing the operating system on a physical machine rather than a virtual one.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/17.png"><img class="aligncenter size-full wp-image-245" title="Ubuntu first boot" src="http://www.development-cycle.com/wp-content/uploads/2010/04/17.png" alt="" width="500" height="372" /></a>The new release has a new look boot screen, pretty plain and I am not a fan of the purple background but that is not where the major improvements lay. A lot of changes have been made to Lucid Lynx in order to speed things up. Timing the boot process from bios to login screen on my VM gave 19.48 seconds, I also had a a virtual machine running Karmic Koala to time which gave 40.03 second, which is an improvement of over 51%!</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/18.png"><img class="aligncenter size-full wp-image-246" title="Lucid Login" src="http://www.development-cycle.com/wp-content/uploads/2010/04/18.png" alt="" width="500" height="343" /></a>After booting we are brought to the login screen, its only marginally different to the Karmic Koala login. Personally I think it doesn&#8217;t look as sharp in this release due to the theme having less contrast.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/19.png"><img class="aligncenter size-full wp-image-247" title="Lucid Desktop" src="http://www.development-cycle.com/wp-content/uploads/2010/04/19.png" alt="" width="500" height="376" /></a>After logging in we are greeted by the new look theme named &#8220;Ambience&#8221;, the old brown colour scheme is gone and replaced by purple. Ubuntu 10.04 also comes with another new theme named &#8220;Radiance&#8221; which is basically just a light coloured version of the Ambience theme.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/20.png"><img class="aligncenter size-full wp-image-248" title="System Menu" src="http://www.development-cycle.com/wp-content/uploads/2010/04/20.png" alt="" width="500" height="378" /></a>The administration menu is almost identical to 9.10 the only thing striking me as being slightly different is rename &#8220;USB Startup Creator&#8221; to just plain old &#8220;Startup Disk Creator&#8221;.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/21.png"><img class="aligncenter size-full wp-image-249" title="Preferences Menu" src="http://www.development-cycle.com/wp-content/uploads/2010/04/21.png" alt="" width="500" height="375" /></a>The preference menu like the administration menu is almost unchanged, except for new entries labelled &#8220;Messaging &amp; VoIP Apllications&#8221;, &#8220;Ubuntu One&#8221; and &#8220;Broadcast Preferences&#8221;.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/22.png"><img class="aligncenter size-full wp-image-250" title="Gnome Places" src="http://www.development-cycle.com/wp-content/uploads/2010/04/22.png" alt="" width="500" height="373" /></a>The places menu is unchanged.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/23.png"><img class="aligncenter size-full wp-image-251" title="Purple Terminal" src="http://www.development-cycle.com/wp-content/uploads/2010/04/23.png" alt="" width="500" height="375" /></a>Installing the additions for Virtual Box, as you can see in the image the minimize / maximize / close button up the top of application windows have moved from the right side to the left.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/24.png"><img class="aligncenter size-full wp-image-252" title="Software Manager" src="http://www.development-cycle.com/wp-content/uploads/2010/04/24-e1272614021397.png" alt="" width="500" height="376" /></a>The software manager has under gone a very welcome make over, with software categories being further categorised  into sub categories. This makes life a lot easier when your looking for a particular application in one of the more populated categories. A new root category has also been added called fonts that covers all your typeface needs.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/25.png"><img class="aligncenter size-full wp-image-253" title="Rythm Box no MP3 support" src="http://www.development-cycle.com/wp-content/uploads/2010/04/25.png" alt="" width="500" height="372" /></a>Like all the Ubuntu releases before it proprietary codecs etc are not installed with the base install due to licensing, copyright and patent issues that go against the <a rel="nofollow" href="http://www.ubuntu.com/community/ubuntustory/philosophy" target="_blank">Ubuntu Free Software Philosophy</a>.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/26.png"><img class="aligncenter size-full wp-image-254" title="Ubuntu One" src="http://www.development-cycle.com/wp-content/uploads/2010/04/26.png" alt="" width="500" height="374" /></a>Rythm Box now contains a tab for the Ubuntu One Music Store, this is a new addition. The range at the moment is somewhat limited at present when compared to something like iTunes, and the appearance rather bland but nevertheless  a great feature which will only get better as it matures.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/27.png"><img class="aligncenter size-full wp-image-256" title="Ubuntu Lucid iPod" src="http://www.development-cycle.com/wp-content/uploads/2010/04/27.png" alt="" width="500" height="375" /></a>A lot of work has also been done on improving Ubuntu&#8217;s handling of the iPhone and iPod touch, music can even be played in Rhythm Box from the device. Unfortunately though you cannot write music to the device so we are still stuck using that abomination iTunes to sync content for the time being.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/28.png"><img class="aligncenter size-full wp-image-257" title="Social Network Broadcast" src="http://www.development-cycle.com/wp-content/uploads/2010/04/28.png" alt="" width="500" height="373" /></a>The new version of Gnome integrates social network into the desktop itself, just configure your account details and you can be tweeting or updating your facebook status directly from the desktop.</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2010/04/30.png"><img class="aligncenter size-full wp-image-258" title="Ubuntu One Cloud Storage" src="http://www.development-cycle.com/wp-content/uploads/2010/04/30.png" alt="" width="300" height="378" /></a>Lucid Lynx also brings inbuilt integration with the Ubuntu One cloud storage. Like the very popular <a rel="nofollow" href="https://www.dropbox.com/referrals/NTU5OTQ5NzM5" target="_blank">Dropbox service</a> this allows users 2Gb of storage space for free in the cloud  to store and share files etc.</p>
<p>Overall I was very impressed with the latest Ubuntu release very polished and some great new features, over the next few days after backing up my data I will definitely be upgrading my Desktop.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2010/04/ubuntu-lucid-lynx-a-quick-look/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up PowerDNS With A MySQL Backend On Ubuntu 9.10</title>
		<link>http://www.development-cycle.com/2009/12/setting-up-powerdns-with-a-mysql-backend-on-ubuntu-9-10/</link>
		<comments>http://www.development-cycle.com/2009/12/setting-up-powerdns-with-a-mysql-backend-on-ubuntu-9-10/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 02:21:39 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PowerDNS]]></category>
		<category><![CDATA[Replication]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=201</guid>
		<description><![CDATA[Bind9 has treated us well over the years, but its lack of support for database back ends in a default install is very annoying, especially when an application needs to control DNS services dynamically. PowerDNS is a powerful alternative it supports a wide variety of back ends and can also be configured to serve different [...]]]></description>
			<content:encoded><![CDATA[<p>Bind9 has treated us well over the years, but its lack of support for database back ends in a default install is very annoying, especially when an application needs to control DNS  services dynamically. PowerDNS is a powerful alternative it supports a wide variety of back ends and can also be configured to serve different records dependant on the clients Geographical location making it a valuable asset in these coming days of private clouds gaining traction.</p>
<p>This article will walk you through the process of setting up a PowerDNS server with a replicated MySQL back end on two Ubuntu 9.10 systems.</p>
<h2>Step 1 &#8211; Configuring the Master Nameserver</h2>
<p>This nameserver is going to be your primary server, any changes that need to be made to the DNS records are made on this server and they will be replicated on the the slave. To get started log into your primary name server via SSH and execute:</p>
<p><i><br />
apt-get update<br />
apt-get install apt-get install pdns-server pdns-backend-mysql mysql-server<br />
</i></p>
<p>When prompted by the installer create a password for the MySQL root user and then configure the MySQL service itself:</p>
<p><i>pico /etc/mysql/my.cnf</i></p>
<p>Go down to line 53, it should look like the line below comment it out.</p>
<p><i>bind-address  = 127.0.0.1 </i> <strong><- becomes -></strong> <i># bind-address  = 127.0.0.1 </i></p>
<p>This is needed so the slave server can talk to the master and be aware of any changes made to its records. Save the file, then restart the MySQL service to make your changes active.</p>
<p><i>/etc/init.d/mysql restart</i></p>
<p>Okay now its time to sort out the database side of things by creating a MySQL user for PowerDNS to use and the database for the storage of its DNS records:</p>
<p><i>mysql -u root -p</i></p>
<p>Whilst in the MySQL client execute the following commands:</p>
<p><i>CREATE DATABASE dns_server;</i></p>
<p><i>GRANT ALL ON dns_server.* TO &#8216;pdns&#8217;@'localhost&#8217; IDENTIFIED BY &#8216;pdns_pass&#8217;;</i></p>
<p><strong>NOTE:</strong> Be sure to change the password for the pdns user to something a tad stronger.</p>
<p><i>GRANT ALL ON dns_server.* TO &#8216;pdns&#8217;@'localhost.localdomain&#8217; IDENTIFIED BY &#8216;pdns_pass&#8217;;</i></p>
<p><i>FLUSH PRIVILEGES;</i></p>
<p><i>USE dns_server;</i></p>
<p><i>CREATE TABLE domains (<br />
id INT auto_increment,<br />
name VARCHAR(255) NOT NULL,<br />
master VARCHAR(128) DEFAULT NULL,<br />
last_check INT DEFAULT NULL,<br />
type VARCHAR(6) NOT NULL,<br />
notified_serial INT DEFAULT NULL,<br />
account VARCHAR(40) DEFAULT NULL,<br />
primary key (id)<br />
);</i></p>
<p><i>CREATE UNIQUE INDEX name_index ON domains(name);</i></p>
<p><i>CREATE TABLE records (<br />
id INT auto_increment,<br />
domain_id INT DEFAULT NULL,<br />
name VARCHAR(255) DEFAULT NULL,<br />
type VARCHAR(6) DEFAULT NULL,<br />
content VARCHAR(255) DEFAULT NULL,<br />
ttl INT DEFAULT NULL,<br />
prio INT DEFAULT NULL,<br />
change_date INT DEFAULT NULL,<br />
primary key(id)<br />
);</i></p>
<p><i>CREATE INDEX rec_name_index ON records(name);</i><br />
<i>CREATE INDEX nametype_index ON records(name,type);</i><br />
<i>CREATE INDEX domain_id ON records(domain_id);</i><br />
<i><br />
CREATE TABLE supermasters (<br />
ip VARCHAR(25) NOT NULL,<br />
nameserver VARCHAR(255) NOT NULL,<br />
account VARCHAR(40) DEFAULT NULL<br />
);</i></p>
<p>Then exit the MySQL client with the command:</p>
<p><i>exit;</i></p>
<p>Alternatively if you don&#8217;t feel that comfortable using the command line MySQL client you could install phpmyadmin and use that to create the database and user within web based environment.</p>
<p>Now that the database has been setup we need to configure PowerDNS to use our newly created MySQL database and user for any lookups it needs to make.</p>
<p><i>pico /etc/powerdns/pdns.conf</i></p>
<p>Go down to line 82 or thereabouts and find the line:</p>
<p><i># launch=</i></p>
<p>Uncomment this line and modify so that it reads:</p>
<p><i>launch=gmysql </i></p>
<p>Edit the file /etc/powerdns/pdns.d/pdns.local</p>
<p>:</p>
<p><i>pico ﻿ /etc/powerdns/pdns.d/pdns.local</i></p>
<p>Add the following lines so that PowerDNS can connect with the MySQL service. </p>
<p><i>gmysql-host=127.0.0.1</i><br />
<i>gmysql-user=pdns</i><br />
<i>gmysql-password=pdns_pass</i><br />
<i>gmysql-dbname=dns_server</i></p>
<p>Save the file and its show time, just restart the PowerDNS service for your changes to take effect and the DNS side of your server should be good to go!</p>
<p><i>/etc/init.d/pdns restart</i></p>
<h2>Step 2 &#8211; Setting up PowerAdmin</h2>
<p>Okay its working but not very useful at the present, as it has no DNS records to serve. So lets install PowerAdmin so we can manage our DNS records using a web based interface. I am assuming the server you are working on already has Apache2, PHP and its modules installed already. If this is not the case you will need to install these before continuing as they are required for the operation PowerAdmin.</p>
<p>PowerAdmin also requires the mdb2 module to work properly, which i doubt many people will have installed already. So:</p>
<p><i>apt-get install php-mdb2-driver-mysql </i></p>
<p>Or on some older versions of Ubuntu it wont be in the repository so make sure you have PEAR installed and</p>
<p><i>apt-get install php-pear</i><br />
<i>pear install MDB2-2.5.0b2</i><br />
<i>pear install MDB2_Driver_mysql-1.5.0b2</i></p>
<p>Then continue the poweradmin install with:</p>
<p><i>cd /tmp</i><br />
<i>wget https://www.poweradmin.org/download/poweradmin-2.1.3.tgz</i><br />
<i>tar zxvf poweradmin-2.1.3.tgz</i><br />
<i>mv poweradmin-2.1.3 /var/www/poweradmin</i><br />
<i>cd /var/www/poweradmin</i></p>
<p>Now the code base is in place open your browser and point it at the Poweradmin location to continue the install process e.g <i>http://ns1.mydomain.com/poweradmin/install</i></p>
<p>Follow the install instructions and when you reach step 6 of the install process copy the PHP code displayed on screen, go back to your terminal window create the file:</p>
<p><i>pico /var/www/poweradmin/inc/config.inc.php</i></p>
<p>Then paste the code from the browser window into the new file and save.</p>
<p><strong>NOTE:</strong> The browser gives you the code with white space between some of the lines make sure these have been removed before saving the file. Otherwise after logging in you will be greeted by a &#8220;<strong>Warning: Cannot modify header information</strong>&#8221; PHP error.</p>
<p>Step 7 is the last step of the install process and simply asks you to delete the install directory. If you fail to complete this step,  the program will not let you login!</p>
<p><i>rm -rf /var/www/poweradmin/install</i></p>
<p>The operation of PowerAdmin is pretty straight forward although if you have only used Bind in the past you may find some of the terms a little confusing. A quick look at the <a href="http://www.powerdns.com/en/documentation.aspx" target="_blank" rel="nofollow">PowerDNS documentation</a> should point you in the right direction though.</p>
<h2>Step 3 &#8211; Replicating Changes on the Slave Server</h2>
<p>Log in to the server you will be using as your MySQL slave. Update the repositories and then install the MySQL server application:</p>
<p><em>apt-get update</em><br />
<em>apt-get install mysql-server</em></p>
<p>On your master server edit the <em>/etc/mysql/my.cnf</em> file go down to around line 92. Uncomment and modify the lines that regard replication so they resemble:</p>
<p><em>server-id               = 1</em><br />
<em>log_bin                 = /var/log/mysql/mysql-bin.log</em><br />
<em>expire_logs_days        = 10</em><br />
<em>max_binlog_size         = 100M</em><br />
<em>binlog_do_db            = dns_server</em></p>
<p>Save your changes to the file and then open up the MySQL client to create a new user for the replication process:</p>
<p><em>﻿CREATE USER &#8216;replication_user&#8217;@&#8217;192.168.0.2&#8242; IDENTIFIED BY &#8216;mypassword&#8217;;</em></p>
<p><em> GRANT REPLICATION SLAVE ON * . * TO &#8216;replication_user&#8217;@&#8217;192.168.0.2&#8242; IDENTIFIED BY &#8216;mypassword&#8217;;</em></p>
<p><strong>NOTE:</strong> replace the IP address &#8216;<em>192&#8242;.168.0.2</em>&#8216; with the IP of your slave server, and change the password to something a bit stronger than &#8216;<em>mypassword</em>&#8216;</p>
<p>Now edit the <em>/etc/mysql/my.cnf</em> file of your slave server and append the following lines after the [mysqld] declaration so that the slave can connect to its master:</p>
<p><em>﻿server-id=2</em><br />
<em>master-host = 192.168.0.1</em><br />
<em>master-user = replication_user</em><br />
<em>master-password = mypassword</em><br />
<em>master-port = 3306</em></p>
<p>Be sure to change the ip address of the master server and the users password to match your setup. Save the file and restart the MySQL service on both the Master and Slave nodes so that your changes will take effect.</p>
<p>On the slave now use the <em>mysql</em> command line tool and execute the following commands:
<p><em>start slave;</em><br />
<em>show slave status\G;</em></p>
<p>You you should see something like:</p>
<p><em><br />
*************************** 1. row ***************************<br />
             Slave_IO_State: Waiting for master to send event<br />
                Master_Host: 192.168.0.1<br />
                Master_User: replication_user<br />
                Master_Port: 3306<br />
              Connect_Retry: 60<br />
            Master_Log_File: mysqld-bin.000001<br />
        Read_Master_Log_Pos: 98<br />
             Relay_Log_File: mysqld-relay-bin.000002<br />
              Relay_Log_Pos: 236<br />
      Relay_Master_Log_File: mysqld-bin.000001<br />
           Slave_IO_Running: Yes<br />
          Slave_SQL_Running: Yes<br />
            Replicate_Do_DB:<br />
        Replicate_Ignore_DB:<br />
         Replicate_Do_Table:<br />
     Replicate_Ignore_Table:<br />
    Replicate_Wild_Do_Table:<br />
Replicate_Wild_Ignore_Table:<br />
                 Last_Errno: 0<br />
                 Last_Error:<br />
               Skip_Counter: 0<br />
        Exec_Master_Log_Pos: 98<br />
            Relay_Log_Space: 236<br />
            Until_Condition: None<br />
             Until_Log_File:<br />
              Until_Log_Pos: 0<br />
         Master_SSL_Allowed: No<br />
         Master_SSL_CA_File:<br />
         Master_SSL_CA_Path:<br />
            Master_SSL_Cert:<br />
          Master_SSL_Cipher:<br />
             Master_SSL_Key:<br />
      Seconds_Behind_Master: 0<br />
1 row in set (0.00 sec)</em></p>
<p>Now test it by creating a record on the master and with any luck you will also be able to see it on the slave. That said i stuffed around a bit when setting mine up and the slave service wouldn&#8217;t start as it was looking for the wrong bin file on the master. I was able to <a rel="nofollow" target="_blank" href="http://forums.mysql.com/read.php?26,94292,134637#msg-134637">follow these instructions</a> though to point the slave in the right direction to get it working again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2009/12/setting-up-powerdns-with-a-mysql-backend-on-ubuntu-9-10/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.development-cycle.com @ 2012-05-19 20:54:31 -->
