<?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>MDLog:/sysadmin &#187; Tools</title> <atom:link href="http://www.ducea.com/category/tools/feed/" rel="self" type="application/rss+xml" /><link>http://www.ducea.com</link> <description>The Journal Of A Linux Sysadmin</description> <lastBuildDate>Tue, 07 Feb 2012 19:40:06 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>Build your own packages easily with FPM</title><link>http://www.ducea.com/2011/08/31/build-your-own-packages-easily-with-fpm/</link> <comments>http://www.ducea.com/2011/08/31/build-your-own-packages-easily-with-fpm/#comments</comments> <pubDate>Wed, 31 Aug 2011 22:13:02 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Centos]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[deb]]></category> <category><![CDATA[debian_packages]]></category> <category><![CDATA[FPM]]></category> <category><![CDATA[rpm]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=1369</guid> <description><![CDATA[Building packages is a task that every system administrator will end up doing. Most of the time this is not a very interesting task but someone has to do it, right? Normally you will end up modifying and tweaking based on your own needs an existing package that was built by the maintainers of the [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p><strong>Building packages</strong> is a task that every system administrator will end up doing. Most of the time this is not a very interesting task but someone has to do it, right? Normally you will end up modifying and tweaking based on your own needs an existing package that was built by the maintainers of the Linux distribution that you are using. In time you might even become familiar with the packaging system you are using (rpm, deb, etc.) and you will be able to write a spec file and start from scratch and build a new package if you need to. Still, this <em>process is complicated and requires a lot of work</em>.</p><p>Luckily, <strong><a
href="http://www.semicomplete.com/blog" target="_blank">Jordan Sissel</a></strong> has built a tool called <strong><a
href="https://github.com/jordansissel/fpm" target="_blank">FPM</a></strong> (Effing Package Management), exactly for this: to ease the pain of building new packages; packages that you will use for your own infrastructure and you want them customized based on your own needs; and you don&#8217;t care about upstream rules and standards and other limitations when building such packages. This can be very useful for people deploying their own applications as rpms (or debs) and can simplify a lot of the process of building those packages.</p><p>FPM can be easily installed on your build system using rubygems:<br
/> <code>gem install fpm</code></p><p>Once installed you can use fpm to build <strong>packages</strong> (targets):</p><ul><li>deb</li><li>rpm</li><li>solaris</li></ul><p>from any of the following <strong>sources</strong>:</p><ul><li>directory (of compiled source of some application)</li><li>gem</li><li>python eggs</li><li>rpm</li><li>node npm packages</li></ul><p><span
id="more-1369"></span>Use the command line help (fpm &#8211;help) or the <a
href="https://github.com/jordansissel/fpm/wiki" target="_blank">wiki</a> to see full details on how to use it. I&#8217;ll show some simple examples on how to build some packages from various input sources that I&#8217;ve found useful myself.</p><h3>1. Package a directory &#8211; output of a &#8216;make install&#8217; command</h3><p>This is how you would usually package an application that you would install with:<br
/> <em>./configure; make; make install</em><br
/> For example, here is how you can create an rpm of the latest version of memcached:<br
/> <code>wget http://memcached.googlecode.com/files/memcached-1.4.7.tar.gz<br
/> tar -zxvf memcached-1.4.7.tar.gz<br
/> cd memcached-1.4.7<br
/> ./configure --prefix=/usr<br
/> make</code><br
/> so far everything looks like a normal manual installation (that would be followed by make install). Still we will now install it in a separate folder so we can capture the output:<br
/> <code>mkdir /tmp/installdir<br
/> make install DESTDIR=/tmp/installdir</code><br
/> and finally using fpm to create the rpm package:<br
/> <code>fpm -s dir -t rpm -n memcached -v 1.4.7 -C /tmp/installdir</code><br
/> where <strong>-s</strong> is the input source type (directory), <strong>-t</strong> is the type of package (rpm), <strong>-n</strong> in the name of the package and <strong>-v</strong> is the version; <strong>-C</strong> is the directory where fpm will look for the files.<br
/> Note: you might need to install various libraries to build your package; for ex. in this case I had to install libevent-dev.</p><p>If you are packaging your own application you can do this just by pointing to your build folder and set the version of the app. Here is an example for an deb package:<br
/> <code>fpm -s dir -t deb -n myapp -v 0.0.1 -C /build/myapp/0.0.1/</code></p><p>There are various other parameters that you can use but basically this is how simple it is to build a package from a directory.<br
/> Here is an example on how to define some dependencies on the package you are building (using <strong>-d</strong>; repeat it as many times as needed):<br
/> <code>fpm -s dir -t deb -n memcached -v 1.4.7 -C /tmp/installdir \<br
/> -d "libstdc++6 (&gt;= 4.4.5)" \<br
/> -d "libevent-1.4-2 (&gt;= 1.4.13)"</code></p><h3>2. Ruby gems or python egg &#8211; converted to packages</h3><p>You can create a deb or rpm from a gem very simple with fpm:<br
/> <code>fpm -s gem -t deb &lt;gem_name&gt;</code><br
/> this will download the gem and create a package named rubygem-&lt;gem_name&gt;<br
/> For example:<br
/> <code>fpm -s gem -t deb fpm</code><br
/> will create a debian package for fpm: rubygem-fpm_0.3.7_all.deb</p><p>You can inspect it with<em> dpkg &#8211;info</em> and you can notice that in this case it will fill nicely all the fields with the maintainer, and dependencies on various other gems. Very cool.</p><p>If you use python and want to package various python eggs this will work exactly the same and you will use -s python (it will download the python packages with easy_install first).</p><p>Overall <strong>FPM</strong> is a great tool and can help you<span
style="text-decoration: underline;"><em> simplify the way you are building your own packages</em></span>. Check it out and let me know what you think and if you found it useful. And if you found this useful don’t forget to thank <strong><a
href="http://www.twitter.com/jordansissel" target="_blank">Jordan</a></strong> for his great work on this awesome tool.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2011/08/31/build-your-own-packages-easily-with-fpm/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Building Vagrant boxes with veewee</title><link>http://www.ducea.com/2011/08/15/building-vagrant-boxes-with-veewee/</link> <comments>http://www.ducea.com/2011/08/15/building-vagrant-boxes-with-veewee/#comments</comments> <pubDate>Tue, 16 Aug 2011 01:49:23 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Configuration management]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MacOSX]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[chef]]></category> <category><![CDATA[puppet]]></category> <category><![CDATA[vagrant]]></category> <category><![CDATA[veewee]]></category> <category><![CDATA[virtualbox]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=1350</guid> <description><![CDATA[If you used vagrant (great tool, right?) you have probably downloaded a basebox from some remote location to get you started. This is a great quick start, and there are many good boxes out there that you can use; vagrantbox.es does a great job in listing various public vagrant boxes. But if you are like [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>If you used <strong><a
href="http://vagrantup.com/" target="_blank">vagrant</a></strong> (great tool, right?) you have probably downloaded a basebox from some remote location to get you started. This is a great quick start, and there are many good boxes out there that you can use; <a
href="http://www.vagrantbox.es/" target="_blank">vagrantbox.es</a> does a great job in listing various public vagrant boxes. But if you are like me, you probably will want to customize the boxes you are using; you might want to install them from scratch based on your own little/or/big customizations. Well if you are like that, then you will be happy to hear that <strong><a
href="http://www.jedi.be/blog" target="_blank">Patrick Debois</a></strong> had exactly the same problem when he decided to write <strong><a
href="https://github.com/jedi4ever/veewee" target="_blank">veewee</a></strong>. And veewee is exactly that missing part of vagrant that allows you to easily build your own vagrant boxes from scratch.</p><p>So let&#8217;s see how we can use veewee. I&#8217;m assuming you already have vagrant installed (and <a
href="http://download.virtualbox.org/virtualbox/" target="_blank">virtualbox</a>), but if you don&#8217;t please install them first. To install <strong>veewee</strong> we just have to install the veewee gem:<br
/> <code>gem install veewee</code><br
/> once you installed veewee you can see a new task added to vagrant: <strong>basebox</strong>.</p><p><span
id="more-1350"></span>Here is the list of the <strong>templates</strong> we get out of the box once we install veewee:<br
/> <code><strong>vagrant basebox templates</strong><br
/> The following templates are available:<br
/> vagrant basebox define '' 'archlinux-i686'<br
/> vagrant basebox define '' 'CentOS-4.8-i386'<br
/> vagrant basebox define '' 'CentOS-5.6-i386'<br
/> vagrant basebox define '' 'CentOS-5.6-i386-netboot'<br
/> vagrant basebox define '' 'Debian-6.0.1a-amd64-netboot'<br
/> vagrant basebox define '' 'Debian-6.0.1a-i386-netboot'<br
/> vagrant basebox define '' 'Fedora-14-amd64'<br
/> vagrant basebox define '' 'Fedora-14-amd64-netboot'<br
/> vagrant basebox define '' 'Fedora-14-i386'<br
/> vagrant basebox define '' 'Fedora-14-i386-netboot'<br
/> vagrant basebox define '' 'freebsd-8.2-experimental'<br
/> vagrant basebox define '' 'freebsd-8.2-pcbsd-i386'<br
/> vagrant basebox define '' 'freebsd-8.2-pcbsd-i386-netboot'<br
/> vagrant basebox define '' 'gentoo-latest-i386-experimental'<br
/> vagrant basebox define '' 'opensuse-11.4-i386-experimental'<br
/> vagrant basebox define '' 'solaris-11-express-i386'<br
/> vagrant basebox define '' 'Sysrescuecd-2.0.0-experimental'<br
/> vagrant basebox define '' 'ubuntu-10.04.2-amd64-netboot'<br
/> vagrant basebox define '' 'ubuntu-10.04.2-server-amd64'<br
/> vagrant basebox define '' 'ubuntu-10.04.2-server-i386'<br
/> vagrant basebox define '' 'ubuntu-10.04.2-server-i386-netboot'<br
/> vagrant basebox define '' 'ubuntu-10.10-server-amd64'<br
/> vagrant basebox define '' 'ubuntu-10.10-server-amd64-netboot'<br
/> vagrant basebox define '' 'ubuntu-10.10-server-i386'<br
/> vagrant basebox define '' 'ubuntu-10.10-server-i386-netboot'<br
/> vagrant basebox define '' 'ubuntu-11.04-server-amd64'<br
/> vagrant basebox define '' 'ubuntu-11.04-server-i386'<br
/> vagrant basebox define '' 'windows-2008R2-amd64-experimental'</code></p><p>This means that we can build a box based on <strong>any</strong> of the above templates. <em>That&#8217;s awesome!</em> Let&#8217;s say we want to build a debian squeeze box using veewee; we would have to run:<br
/> <code>vagrant basebox define 'debian-60' 'Debian-6.0.1a-amd64-netboot'</code><br
/> and this will create a folder definitions/debian-60 with the following files (the content of the veewee template):<br
/> <code>definition.rb<br
/> postinstall.sh<br
/> preseed.cfg</code><br
/> we can modify/tune any of those files based on our custom needs. The file <strong>definition.rb</strong> is the main definition of the template. Here you would define the memory size, disk size, iso file, etc. The content is very easy to understand, but you would normally not have to change many things here. <strong>preseed.cfg</strong> is just a standard preseed file where you would customize the actual install process (you could change here the partitions or their type, timezone setup, etc). And finally <strong>postinstall.sh</strong> that is a bash script that will run at the end of the installation process and it will install ruby, gems , chef and puppet and also the virtualbox guest additions (needed for shared folders).</p><p>If you have the iso already place it in <strong>&#8216;currentdir&#8217;/iso</strong>. If not, veewee will download it and place it in the appropriate folder before starting the install process:<br
/> <code>vagrant basebox build 'debian-60'</code><br
/> this will start the installation and you can see all the steps it takes (the keystrokes as they are entered, etc.). This can take a while… Once it is done you can validate the build with:<br
/> <code>vagrant basebox validate 'debian-60'</code><br
/> (this will run a few basic tests to see if it can connect to the vm as user vagrant, if chef and puppet were installed, if the shared folders are accessible, etc).</p><p>And finally you can export it as a vagrant box with:<br
/> <code>vagrant basebox export 'debian-60'</code><br
/> and add it to vagrant:<br
/> <code>vagrant box add 'debian-60' debian-60.box</code><br
/> and now you can use it in vagrant with:<br
/> <code>vagrant init 'debian-60'</code></p><p>That&#8217;s it. Very simple and now we have our own box built from scratch. As a side note, I found this very useful to test and troubleshoot preseed configurations <img
src='http://www.ducea.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . As you can see there are plenty of templates available in veewee but if you create a new one please consider to share it with others and send it to Patrick on <a
href="https://github.com/jedi4ever/veewee" target="_blank">github</a>. I&#8217;m sure he will be happy to include it in newer versions of veewee. And if you found this useful don&#8217;t forget to thank <a
href="https://twitter.com/#!/patrickdebois" target="_blank">Patrick</a> for his great work on this awesome tool.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2011/08/15/building-vagrant-boxes-with-veewee/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>HowTo install reconnoiter on Debian Lenny</title><link>http://www.ducea.com/2010/07/13/howto-install-reconnoiter-on-debian-lenny/</link> <comments>http://www.ducea.com/2010/07/13/howto-install-reconnoiter-on-debian-lenny/#comments</comments> <pubDate>Tue, 13 Jul 2010 02:03:18 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Debian]]></category> <category><![CDATA[Monitoring]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[reconnoiter]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=1073</guid> <description><![CDATA[Ever since I sow the oscon presentation of reconnoiter I wanted to check it out and play with it. Yesterday, I finally had some time to do this and thought it would be a good idea to document it as a short howto. Most of the infos I used are from the readme (BUILDING), the [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>Ever since I sow the <a
href="http://omniti.com/video/noit-oscon-demo" target="_blank">oscon presentation</a> of <strong><a
href="https://labs.omniti.com/trac/reconnoiter" target="_blank">reconnoiter</a></strong> I wanted to check it out and play with it. Yesterday, I finally had some time to do this and thought it would be a good idea to document it as a short howto. Most of the infos I used are from the readme (BUILDING), the <a
href="https://labs.omniti.com/trac/reconnoiter/wiki" target="_blank">wiki</a> and the excellent writeup of Thomas Dudziak on <a
href="http://tomdzk.wordpress.com/2009/11/24/reconnoiter-on-karmic/" target="_blank">how to install reconnoiter on ubuntu</a>.</p><p>The daemons <strong>noitd</strong> and <strong>stratcond</strong> are written in C, and the database used is postgressql, while the web interface is written in php. We will need to install a few dependencies to be able to compile noitd/stratcond:<span
id="more-1073"></span></p><h3>Dependencies</h3><p><code>apt-get install autoconf build-essential \<br
/> zlib1g-dev uuid-dev libpcre3-dev libssl-dev libpq-dev \<br
/> libxslt-dev libapr1-dev libaprutil1-dev xsltproc \<br
/> libncurses5-dev python libssh2-1-dev libsnmp-dev \<br
/> sun-java6-jdk</code></p><p>In case you don&#8217;t have already installed svn, we will need that also (to download the sources):<br
/> <code>apt-get install subversion</code></p><h3>Compiling</h3><p>Next we will download the source and compile it. I used the trunk version bellow, but you might want use a stable tag (Urskek is the latest when writing this):<br
/> <code>cd /usr/local/src/<br
/> svn co https://labs.omniti.com/reconnoiter/trunk reconnoiter<br
/> cd reconnoiter<br
/> autoconf<br
/> ./configure<br
/> make<br
/> make install</code></p><h3>Database</h3><p>We need to instal <strong>PostgreSQL 8.4 </strong>and this is not available in lenny; the simplest way we can do this is to use the backports package. To enable the <a
href="http://backports.org/" target="_blank">backports</a> sources add this line<br
/> <code>deb http://www.backports.org/debian lenny-backports main contrib non-free</code><br
/> to your <em>/etc/apt/sources.list</em> and run <em>apt-get update</em> to refresh your apt indexes. And finally add the backports key into apt:<br
/> <code>apt-get install debian-backports-keyring</code></p><p>Now we can install postgres 8.4 using:<br
/> <code>apt-get -t lenny-backports install postgresql</code></p><p>Next we&#8217;ll need to edit /etc/postgresql/8.4/main/pg_hba.conf and replace this line<br
/> <code>local   all         all                               ident</code>with<br
/> <code>local   all         all                               trust</code><br
/> and restart postgres:<br
/> <code>/etc/init.d/postgresql-8.4 restart</code><br
/> to allow local access without password.</p><p>Next we can install the dbs, using:<br
/> <code>su postgres<br
/> cd /usr/local/src/reconnoiter/sql<br
/> psql<br
/> \i scaffolding.sql<br
/> \q</code></p><h3>DB crontab</h3><p>You can find a sample crontab in the sql folder that needs to be customized for our particular setup (/opt/psql835/bin -&gt;  /usr/bin/), and it should look like this:</p><pre><code>su postgres
crontab -l
# m h  dom mon dow   command
#rollup jobs
* * * * * /usr/bin/psql -d reconnoiter -U stratcon -c "select stratcon.rollup_metric_numeric(rollup) from metric_numeric_rollup_config order by seconds asc;" &gt;/tmp/rollup.log 2&gt;&amp;1
#cleanup jobs
01 00 * * * /usr/bin/psql -d reconnoiter -U reconnoiter -c "select stratcon.archive_part_maint('noit.metric_numeric_archive', 'whence', 'day', 7);" 1&gt;/dev/null
01 00 * * * /usr/bin/psql -d reconnoiter -U reconnoiter -c "select stratcon.archive_part_maint('noit.metric_text_archive', 'whence', 'day', 7);" 1&gt;/dev/null
01 00 * * * /usr/bin/psql -d reconnoiter -U reconnoiter -c "select stratcon.archive_part_maint('noit.check_status_archive', 'whence', 'day', 7);" 1&gt;/dev/null
01 00 * * * /usr/bin/psql -d reconnoiter -U reconnoiter -c "select stratcon.archive_part_maint('noit.check_archive', 'whence', 'day', 7);" 1&gt;/dev/null
01 00 * * * /usr/bin/psql -d reconnoiter -U reconnoiter -c "delete from prism.saved_graphs where saved = false and last_update/dev/null</code></pre><p><em><span
style="text-decoration: underline;">!!! I would suggest to run the daily crons manually once as they create the needed tables and in case you don&#8217;t have them you will receive various errors (I know I lost a lot of time trying to figure out why those were not there). This should be just like:</span></em><br
/> <code>/usr/bin/psql -d reconnoiter -U reconnoiter -c "select stratcon.archive_part_maint('noit.metric_text_archive', 'whence', 'day', 7);"</code><br
/> and so on for each of the 5 daily crons from above.</p><h3>keys</h3><p>For a production install you will obviously create some real certs, but in my case where I was just testing this out the test certs build by the installer are just fine:<br
/> <code>cd /usr/local/src/reconnoiter/test<br
/> cp test-*.crt test-*.key /usr/local/etc/</code></p><p>In dealing with the configuration files uuid&#8217;s you will find useful the <strong>uuidgen</strong> program from the uuid-runtime package:<br
/> <code>apt-get install uuid-runtime</code><br
/> that will generate a new uuid on each run:<br
/> <code>uuidgen<br
/> 22426aa0-db34-437d-a891-e759ffbdb494</code></p><h3>noitd</h3><p>We will start from the sample configuration:<br
/> <code>mv /usr/local/etc/noit.conf.sample /usr/local/etc/noit.conf</code><br
/> and edit/remove it as needed. Be sure to edit the sslconfig part with the keys you copied above. For more details on the config file look on the <a
href="https://labs.omniti.com/docs/reconnoiter/config.noitd.html" target="_blank">wiki</a>.</p><p>Finally run noitd and see if all is good:<br
/> <code>/usr/local/sbin/noitd -c /usr/local/etc/noit.conf -D</code><br
/> If there are no errors stop it, and run it in the background (without -D):<br
/> <code>/usr/local/sbin/noitd -c /usr/local/etc/noit.conf</code></p><h3>stratcon</h3><p>For stratcon we are going to use a similar approach:<br
/> <code>mv /usr/local/etc/stratcon.conf.sample /usr/local/etc/stratcon.conf</code><br
/> and then customize the config based on our needs. Set the keys in sslconfig section and the db details</p><pre><code>    &lt;dbconfig&gt;
      &lt;host&gt;localhost&lt;/host&gt;
      &lt;dbname&gt;reconnoiter&lt;/dbname&gt;
      &lt;user&gt;stratcon&lt;/user&gt;
      &lt;password&gt;unguessable&lt;/password&gt;
    &lt;/dbconfig&gt;    </code></pre><p>the password is &#8220;stratcon&#8221; or whatever you set in scaffolding.sql if you customized it (a good idea <img
src='http://www.ducea.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).<br
/> and finally run it with debuging in the foreground:<br
/> <code>/usr/local/sbin/stratcond -c /usr/local/etc/stratcon.conf -D</code><br
/> and if all is good (you did ran the db creation task, right?) you can start it in the background without -D and move to the final step:<br
/> <code>/usr/local/sbin/stratcond -c /usr/local/etc/stratcon.conf</code></p><h3>Web interface</h3><p>Finally the last step is to configure the web interface. For this we need to be sure we have apache/php installed and the pgsql module:<br
/> <code>apt-get install apache2 libapache2-mod-php5 php5-pgsql</code><br
/> and to enable the rewrite module<br
/> <code>a2enmod rewrite</code><br
/> Next we would copy the web files ui to some place like /var/www/ui and create a vhost for reconnoiter inside /etc/apache2/sites-available:</p><pre><code>&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/ui/web/htdocs

  &lt;Directory "/"&gt;
      Options None
      AllowOverride None
      Order allow,deny
      Deny from all
  &lt;/Directory&gt;
  &lt;FilesMatch "^\.ht"&gt;
      Order allow,deny
      Deny from all
      Satisfy All
  &lt;/FilesMatch&gt;
  &lt;Directory "/var/www/ui/web/htdocs/"&gt;
      php_value include_path /var/www/ui/web/lib
      php_value short_open_tag off
      Options FollowSymLinks Indexes
      AllowOverride All
      Order deny,allow
      Allow from all
  &lt;/Directory&gt;

  LogLevel warn
  LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common

  ErrorLog /var/www/ui/web/logs/error_log
  CustomLog /var/www/ui/web/logs/access_log common

  AddType application/x-compress .Z
  AddType application/x-gzip .gz .tgz
  AddType application/x-httpd-php .php
  DefaultType text/plain

  RewriteEngine On
  RewriteRule ^(/data/.+)$ http://localhost:80$1 [P,L,QSA]
&lt;/VirtualHost&gt;
</code></pre><p>enable the config:<br
/> <code>a2ensite reconnoiter</code><br
/> and restart apache to enable it: /etc/init.d/apache2 restart</p><p>After this hopefully you can open the web interface and start adding some metrics. My goal was to test this with collectd and if there is interest I could describe the details on how to make reconnoiter work with collectd in another post. let me know&#8230;</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2010/07/13/howto-install-reconnoiter-on-debian-lenny/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Playing with Google command line tools on MacOSX</title><link>http://www.ducea.com/2010/06/21/playing-with-google-command-line-tools-on-macosx/</link> <comments>http://www.ducea.com/2010/06/21/playing-with-google-command-line-tools-on-macosx/#comments</comments> <pubDate>Mon, 21 Jun 2010 07:12:41 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[MacOSX]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[cli]]></category> <category><![CDATA[google]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=1045</guid> <description><![CDATA[With the release of GoogleCL, the command line tool for the Google data APIs, Google reconfirmed if that was needed that it&#8217;s a geeky company (I mean you would not expect something like this form M$, right?) and they like command line tools. They released some basic command line tools for calendar, contacts, docs, picassa, [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>With the release of <a
href="http://code.google.com/p/googlecl/" target="_blank"><strong>GoogleCL</strong></a>, the <strong>command line tool</strong> for the Google data APIs, Google reconfirmed if that was needed that it&#8217;s a geeky company (I mean you would not expect something like this form M$, right?) and they like command line tools. They released some basic command line tools for calendar, contacts, docs, picassa, blogger and youtube. Of course, coming from google the tools are written in their preferred language, <strong>python</strong>.</p><p><code>~$ google<br
/> &gt; help<br
/> Welcome to the Google CL tool!<br
/> Commands are broken into several parts: service, task, options, and arguments.<br
/> For example, in the command<br
/> "&gt; picasa post --title "My Cat Photos" photos/cats/*"<br
/> the service is "picasa", the task is "post", the single option is a name of "My Cat Photos", and the argument is the path to the photos.<br
/> The available services are 'picasa', 'blogger', 'youtube', 'docs', 'contacts', 'calendar'<br
/> Enter "&gt; help &lt;service&gt;" for more information on a service.<br
/> Or, just "quit" to quit.</code></p><p><span
id="more-1045"></span>There is a deb package <a
href="http://code.google.com/p/googlecl/downloads/list" target="_blank">available</a> for ubuntu/debian_lenny, and source package for other distributions. The only requirement is <strong>Python 2.5</strong> or <strong>2.6</strong> and the <a
href="http://code.google.com/p/gdata-python-client/" target="_blank">gdata python client library</a>.<br
/> You can install the package manually just as any python package:<br
/> <code>sudo python setup.py install</code></p><p>For <strong>MacOSX</strong> if you are running <strong>MacPorts</strong>, it is easier to install gdata and googlecl from ports (also easier to keep them updated in the future). The install should be as simple as:<br
/> <code>sudo port install googlecl</code><br
/> in case you don&#8217;t see it in your source list, just run a port selfupdate:<br
/> <code>sudo port selfupdate</code></p><h3>Usage</h3><p>There are several good <a
href="http://code.google.com/p/googlecl/wiki/ExampleScripts" target="_blank">examples</a> on the project page, but basically each service has the ability to list, add and delete. Here are some simple examples for calendar:</p><p>List events for today only:<br
/> <code>google calendar today</code></p><p>and the same with some nicer formatting:<br
/> <code>google calendar today when,title --delimiter " | "<br
/> Jun 21 09:30 - Jun 21 10:00 | Very important call</code></p><p>we can also do a query after some strinng:<br
/> <code>google calendar list --query velocity</code></p><p>and adding a new event:<br
/> <code>google calendar add "Very important call today at 10am"</code></p><p>or delete an event:<br
/> <code>google calendar delete --title "Meeting with John"</code></p><p>Calendar is definitely the most important one for me, but contacts and docs are also great to be controlled from the command line. I would like to see the same for Gmail in the future <img
src='http://www.ducea.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2010/06/21/playing-with-google-command-line-tools-on-macosx/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>iptables geoip match on debian lenny</title><link>http://www.ducea.com/2009/03/18/iptables-geoip-match-on-debian-lenny/</link> <comments>http://www.ducea.com/2009/03/18/iptables-geoip-match-on-debian-lenny/#comments</comments> <pubDate>Wed, 18 Mar 2009 13:56:31 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Debian]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[Tips & Tricks]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[geoip]]></category> <category><![CDATA[iptables]]></category> <category><![CDATA[kernel_modules]]></category> <category><![CDATA[lenny]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=818</guid> <description><![CDATA[The geoip iptables extension allows you to filter, nat or mangle packets based on the country&#8217;s source or destination. This does exactly what the geoip apache module does, or the regular geoip binary, but at the iptables level. I would not go into the details why you would want to use that, but there are [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>The <strong>geoip iptables extension</strong> allows you to filter, nat or mangle packets based on the country&#8217;s source or destination. This does exactly what the geoip apache module does, or the regular geoip binary, but at the iptables level. I would not go into the details <strong>why </strong>you would want to use that, but there are many &#8216;positive&#8217; ways it can be useful&#8230; For example myself I use it in a project where we want to<em> serve customized content for different countries</em>. Since this is a high traffic site running on many web servers behind a loadbalanced setup, we prefer to split this at the <em>loadbalancer level</em> and not at apache level, to simplify our setup. We serve customized content to the US based visitors, while for the other countries we serve another international site.</p><p>Now this has been working fine for a long time now, using the <a
href="http://people.netfilter.org/peejix/geoip/" target="_blank">original geoip module</a> and <strong>patch-o-matic-ng</strong> method of installation (similar to what is very well <a
href="http://www.debian-administration.org/articles/518" target="_blank">described here</a>). Still, this is unmaintained, and starting with <strong>kernel 2.6.22</strong> it is no longer working. There is a <a
href="http://bjerkeset.com/patches/geoip-match-2.6.22.patch.gz" target="_blank">patch</a> that will make it work with a newer kernel, but if you run <strong>iptables 1.4.x</strong> this will again fail and even if there are some manual walkarounds this is still not the best solution.</p><p>The solution is called <strong>Xtables-addons</strong>. <a
href="http://xtables-addons.sourceforge.net/" target="_blank">Xtables-addons</a> is the successor to patch-o-matic-ng. Likewise, <em>it contains extensions that were not, or are not yet, accepted in the main kernel/iptables packages. Xtables-addons is different from patch-o-matic in that you do not have to patch or recompile the kernel, sometimes recompiling iptables is also not needed.</em><br
/> The latest version <strong>1.12</strong> <a
href="http://xtables-addons.git.sourceforge.net/git/gitweb.cgi?p=xtables-addons;a=blob;hb=master;f=INSTALL" target="_blank">supports</a>: iptables &gt;= 1.4.1 and kernel-source &gt;= 2.6.17.</p><p><span
id="more-818"></span>The installation is very simple and requires only the following steps exemplified on a <strong>debian lenny</strong> machine (kernel 2.6.26 and iptables 1.4.2):</p><p><strong>1.</strong> Install the needed <strong>dependencies</strong>: kernel headers and iptables dev:<br
/> <code>aptitude install linux-headers-2.6.26-1-amd64 iptables-dev</code><br
/> <em>libtext-csv-xs-perl</em> will be also needed if you plan to update the database (normally you will want this to be able to update the db from time to time):<br
/> <code>aptitude install libtext-csv-xs-perl</code></p><p><strong>2.</strong> <strong>Download </strong>the xtables-addons package and the supplied <a
href="http://jengelh.medozas.de/files/geoip/" target="_blank">database</a> (or the <a
href="http://jengelh.medozas.de/files/geoip/geoip_src.tar.bz2" target="_blank">sources</a> to build your own):<br
/> <code>wget http://switch.dl.sourceforge.net/sourceforge/xtables-addons/xtables-addons-1.12.tar.bz2<br
/> wget http://jengelh.medozas.de/files/geoip/geoip_iv0_database-20090201.tar.bz2<br
/> </code><br
/> <strong>3.</strong> Configure and <strong>compile </strong>the package. There are several iptables modules included; you can leave them all enabled or choose to compile and install only the ones needed. For this edit the <strong>mconfig </strong>file and leave only the ones you want:<br
/> <code>build_CHAOS=m<br
/> build_DELUDE=m<br
/> build_DHCPADDR=m<br
/> build_ECHO=<br
/> build_IPMARK=m<br
/> build_LOGMARK=m<br
/> build_SYSRQ=m<br
/> build_TARPIT=m<br
/> build_TEE=m<br
/> build_condition=m<br
/> build_fuzzy=m<br
/> <strong>build_geoip=m</strong><br
/> build_ipp2p=m<br
/> build_ipset=m<br
/> build_length2=m<br
/> build_lscan=m<br
/> build_quota2=m</code></p><p>Compile and install:<br
/> <code>./configure --with-xtlibdir=/lib/xtables<br
/> make<br
/> make install</code></p><p>this will add the iptables extension <strong>/lib/xtables/libxt_geoip.so</strong> and the kernel module in /lib/modules/&lt;kernel&gt;<strong>/extra/xt_geoip.ko</strong></p><p><strong>4.</strong> Now we have to put the <strong>geoip database files</strong> under the expected location (<strong>/var/geoip</strong>); this is hardcoded in the code, but you can change it if really needed and recompile. I would like to add that even if this uses the same geoip source (the <a
href="http://www.maxmind.com/app/geolitecountry" target="_blank">free GeoLite Country database</a>) as the original geoip iptables module, but the format has changed. You can either get the database from the source, or build your own with the supplied script. Once you have that copy the files to /var/geoip</p><p><code>wget http://www.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip<br
/> unzip GeoIPCountryCSV.zip<br
/> ./runme.sh<br
/> cp -R var/geoip/ /var/</code></p><p>That&#8217;s it! All you have to do is use the module based on your needs. The syntax is the same as the original geoip iptables module:<br
/> <em> [!] &#8211;src-cc, &#8211;source-country country[,country...] = Match packet coming from (one of) the specified country(ies)<br
/> [!] &#8211;dst-cc, &#8211;destination-country country[,country...] = Match packet going to (one of) the specified country(ies)<br
/> NOTE:  The country is inputed by its ISO3166 code.</em></p><p>We use something like this to mark and send each type of traffic to its own destination:<br
/> <code>iptables -t mangle -A PREROUTING -p tcp -m geoip --src-cc US -d &lt;IP&gt; --dport 80 -j MARK --set-mark 1<br
/> iptables -t mangle -A PREROUTING -p tcp -m geoip ! --src-cc US -d &lt;IP&gt; --dport 80 -j MARK --set-mark 2</code></p><p>I hope you found this article useful, and as me, are grateful that <strong>Xtables-addons</strong> project took over the patch-o-matic-ng broken modules and made them available on current distributions. Xtables-addons was also accepted in debian repository (in <a
href="http://packages.debian.org/squeeze/xtables-addons-source" target="_blank">testing</a>) and this will make it even simpler to install and use in the future.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/18/iptables-geoip-match-on-debian-lenny/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>Migrating from Trac to Redmine</title><link>http://www.ducea.com/2009/03/12/migrating-from-trac-to-redmine/</link> <comments>http://www.ducea.com/2009/03/12/migrating-from-trac-to-redmine/#comments</comments> <pubDate>Thu, 12 Mar 2009 14:26:07 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Tools]]></category> <category><![CDATA[redmine]]></category> <category><![CDATA[trac]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=756</guid> <description><![CDATA[I just finished the migration of my trac installation to redmine. The redmine migrate_from_trac documentation helped a lot, but there were some issues that didn&#8217;t work quite as described; this post will describe the correct steps I had to follow in order to import my old trac data (tickets, wiki pages, etc) in redmine. 1. [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>I just finished the migration of my <a
href="http://trac.edgewall.org/" target="_blank"><strong>trac</strong></a> installation to <a
href="http://www.redmine.org/" target="_blank"><strong>redmine</strong></a>. The redmine <a
href="http://www.redmine.org/wiki/redmine/RedmineMigrate" target="_blank">migrate_from_trac</a> documentation helped a lot, but there were <em>some issues</em> that didn&#8217;t work quite as described; this post will describe the correct steps I had to follow in order to import my <em>old trac data (tickets, wiki pages, etc) in redmine</em>.</p><h3>1. Use Redmine 0.8.x stable</h3><p>I lost some time with the current <strong>trunk </strong>version (r2571) until I realized that <em>the importer is broken in trunk</em>. Use the latest <strong>stable 0.8.x</strong> version, and if you want to use trunk, upgrade to it after you have the trac data inside redmine. While using trunk all was working fine (no error or anything strange), just the wiki pages were not imported in the redmine project. Anyway, I will assume you have a working clean installation of redmine 0.8.x before we will move on.<span
id="more-756"></span></p><h3>2. Import Trac data</h3><p>My <strong>trac </strong>(0.11.2) database was using <strong>sqlite3</strong>; meaning I had to install first <strong>sqlite3-ruby</strong>:<br
/> <code>gem install sqlite3-ruby</code><br
/> Next I ran the import script from inside the root redmine folder:<br
/> <code>rake redmine:migrate_from_trac RAILS_ENV="production"</code><br
/> and entered the following:</p><pre><code>Trac directory []: /var/trac/project
Trac database adapter (sqlite, sqlite3, mysql, postgresql) [sqlite]: <strong>sqlite3</strong>
Database encoding [UTF-8]:
Target project identifier []: project</code></pre><p>if for your trac installation uses <strong>sqlite </strong>then use the <a
href="http://www.redmine.org/wiki/redmine/RedmineMigrate" target="_blank">original doc</a> steps. For the target project identifier use a name for a new project in redmine that will have the trac data imported (small caps).</p><p>The script showed a summary of the imported objects, and hopefully you will find them inside the redmine new project. In my case most of the wiki pages were ok, but some had <em>wrong formatting</em> and needed to be manually fixed (minor issues). Overall I am very happy on how this worked and that I have now all my old trac data inside redmine.</p><h3>3. Upgrade to trunk (only if you want to use trunk)</h3><p>If you wanted to use trunk (like me) you can now migrate the redmine installation to trunk using svn (make backups first, etc):<br
/> <code>svn sw http://redmine.rubyforge.org/svn/trunk .<br
/> rake db:migrate RAILS_ENV="production"<br
/> rake config/initializers/session_store.rb</code><br
/> and restart redmine, and you should be running trunk.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/12/migrating-from-trac-to-redmine/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>HowTo install iotop on Debian Etch</title><link>http://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/</link> <comments>http://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/#comments</comments> <pubDate>Wed, 11 Mar 2009 09:26:37 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Debian]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[debian-etch]]></category> <category><![CDATA[iotop]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=741</guid> <description><![CDATA[In my previous post, I introduced iotop a very cool tool that displays a table of current I/O usage by processes on the system; just as useful as top, but for I/O monitoring. Unfortunately, iotop requires Python &#62;= 2.5 and a Linux kernel &#62;= 2.6.20 to work, and even if the installation is very simple [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>In my <a
href="http://www.ducea.com/2009/03/10/iotop-simple-top-like-io-monitor/">previous post</a>, I introduced <a
href="http://guichaz.free.fr/iotop/" target="_blank"><strong>iotop</strong></a> a very cool tool that displays a table of current <strong>I/O usage by processes</strong> on the system; just as useful as top, but for I/O monitoring. Unfortunately, iotop requires <strong>Python &gt;= 2.5</strong> and a Linux <strong>kernel &gt;= 2.6.20</strong> to work, and even if the installation is very simple as presented in my last post, getting it to run on older distributions might not be so easy. This post will show how you can <strong>run iotop on debian etch</strong>, describing how we can solve the dependencies and make iotop run just fine on etch.<br
/> <span
id="more-741"></span></p><h3>1. Kernel</h3><p>The default <strong>etch </strong>kernel is <strong>2.6.18</strong> and even if this will not block us from installing iotop, there will be no result unless we run a kernel newer than 2.6.20. Luckily debian etch provides <strong><a
href="http://www.ducea.com/2008/07/28/debian-gnulinux-40r4-updated-and-etch-and-a-half/">etchnhalf</a> </strong>that made available a newer kernel <strong>2.6.24</strong> in etch. Another approach is to build your own kernel of course, where you will probably use the latest stable version at that time. Still if you run this on many machines it will probably wise to use the etchnhalf kernel or pack your own deb with a newer one. For our needs we will just use the <strong>2.6.24 etchnhalf kernel</strong>:<br
/> <code>aptitude install linux-image-2.6.24-etchnhalf.1-amd64</code> if you run on amd64 debian etch, or:<br
/> <code>aptitude install linux-image-2.6.24-etchnhalf.1-686</code>if you use the regular i386.</p><p><em>Note</em>: there are some limitations that you should be aware of (please see debian <a
href="http://www.debian.org/News/2008/20080726" target="_blank">etchnhalf release notes</a> for more details), mainly there is no xen compatible image (meaning if you use xen don&#8217;t do this), and missing of bnx2 firmware from the build-in kernel (see my <a
href="http://www.ducea.com/2008/10/21/bnx2-missing-from-stock-debian-2624-etchnhalf-kernel/">post about this</a>).</p><p>Ok, once this is done, reboot and after your system is up and running with the new kernel we can move on:<br
/> <code>uname -a<br
/> Linux srv02 2.6.24-etchnhalf.1-686-bigmem #1 SMP Fri Dec 26 04:53:15 UTC 2008 i686 GNU/Linux</code></p><h3>2. Python 2.5</h3><p>The default version of python in debian etch is <strong>2.4</strong> (while for <em>lenny it is 2.5</em>). Still <strong>python2.5</strong> is <a
href="http://packages.debian.org/etch/python2.5" target="_blank">available</a> in etch also, and can be installed using:<br
/> <code>aptitude install python2.5 python2.5-minimal python2.5-dev</code></p><p>That&#8217;s it. Most (so I don&#8217;t say all) of the python modules in the etch repo <em>are working only</em> with the default python version 2.4. For example for <strong>iotop </strong>build we need <a
href="http://pypi.python.org/pypi/setuptools" target="_blank">setuptools</a>, but installing python2.5-setuptools fails for some reason; anyway the idea is that we were able to install python2.5 easily from the repo, but we will have to install the rest of the extra python 2.5 modules from source and point them to python2.5. I am doing this assuming you will want to keep python2.4 as the default system python version as probably you have some tools depending on it (like we have bcfg2 for example), so we don&#8217;t mess with that.</p><p>Let&#8217;s download <a
href="http://pypi.python.org/pypi/setuptools#downloads" target="_blank">setuptools for python2.5</a> and install it:<br
/> <code>wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py2.5.egg<br
/> sh setuptools-0.6c9-py2.5.egg</code></p><h3>3. Finally iotop</h3><p>All what is left is to install <strong>iotop</strong>, now that we have all the dependencies in place.<br
/> <code>git clone git://repo.or.cz/iotop.git<br
/> cd iotop</code><br
/> and change inside <strong>setup.py</strong> the first line to use <strong>python2.5</strong> like this:<br
/> <code>#!/usr/bin/env python2.5</code><br
/> and run setup:<br
/> <code>./setup.py install</code><br
/> hopefully this will install just fine, and you should have iotop running using the python2.5 binary.</p><p>I hope this post will be useful to users of debian etch showing them a quick way to install iotop on their existing system.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>iotop: simple top-like i/o monitor</title><link>http://www.ducea.com/2009/03/10/iotop-simple-top-like-io-monitor/</link> <comments>http://www.ducea.com/2009/03/10/iotop-simple-top-like-io-monitor/#comments</comments> <pubDate>Tue, 10 Mar 2009 16:04:05 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[iotop]]></category> <category><![CDATA[vmstat]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=717</guid> <description><![CDATA[iotop does for I/O usage what top does for CPU usage. It watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes on the system. This tool is written by Guillaume Chazarain and requires Python &#62;= 2.5 and a Linux kernel &#62;= [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p><strong><a
href="http://guichaz.free.fr/iotop/" target="_blank">iotop</a> </strong>does for <strong>I/O usage</strong> what <strong>top </strong>does for <strong>CPU usage</strong>. It watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes on the system. This tool is written by <em>Guillaume Chazarain</em> and requires <strong>Python &gt;= 2.5</strong> and a <strong>Linux kernel &gt;= 2.6.20</strong> to run. This post introduces this very useful tool and shows how we can install it and use it.</p><p><a
href="http://www.ducea.com/images/iotop_big.png"><img
class="alignright" title="iotop" src="http://www.ducea.com/images/iotop.png" alt="" width="150" height="99" /></a>iotop can be <a
href="http://guichaz.free.fr/iotop/" target="_blank">downloaded</a> either as source package or a rpm package. Starting with <strong>lenny</strong>, <em>debian includes <a
href="http://packages.debian.org/lenny/iotop" target="_blank">iotop</a></em> in the main repository and it can be installed just as simple as running:<br
/> <code>aptitude install iotop</code>This is very cool indeed and kudos to the debian team to include iotop in lenny <img
src='http://www.ducea.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br
/> <span
id="more-717"></span><br
/> For other distributions, we can install it from source using the following simple steps (be sure to have python2.5 before trying this); I am using git and this will download the latest trunk version 3, if this is not what you want download the tar.gz (ver 0.2.1) and use the stable version instead.<br
/> <code>git clone git://repo.or.cz/iotop.git<br
/> cd iotop<br
/> ./setup.py install</code><br
/> after this <strong>iotop </strong>will be installed under <strong>/usr/bin</strong>.</p><p>Let’s see what are the program parameters:</p><pre><code>iotop -h
Usage: /usr/bin/iotop [OPTIONS]

DISK READ and DISK WRITE are the block I/O bandwidth used during the sampling
period. SWAPIN and IO are the percentages of time the thread spent respectively
while swapping in and waiting on I/O more generally. PRIO is the I/O priority at
which the thread is running (set using the ionice command).
Controls: left and right arrows to change the sorting column, r to invert the
sorting order, o to toggle the --only option, p to toggle the --processes
option, q to quit, any other key to force a refresh.

Options:
--version             show program's version number and exit
-h, --help            show this help message and exit
-o, --only            only show processes or threads actually doing I/O
-b, --batch           non-interactive mode
-n NUM, --iter=NUM    number of iterations before ending [infinite]
-d SEC, --delay=SEC   delay between iterations [1 second]
-p PID, --pid=PID     processes/threads to monitor [all]
-u USER, --user=USER  users to monitor [all]
-P, --processes       only show processes, not all threads</code></pre><p>We can run it interactively, just like top, by simply typing: <strong>iotop</strong>, or add some parameters like<br
/> <code>iotop -o -d 2</code><br
/> We can also run it in batch mode using <strong>-b</strong>:<br
/> <code>iotop -b -o -d 5<br
/> ...<br
/> Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s<br
/> TID PRIO USER      DISK READ  DISK WRITE   SWAPIN    IO    COMMAND<br
/> Total DISK READ: 0.00 B/s | Total DISK WRITE: 2.49 M/s<br
/> TID PRIO USER      DISK READ  DISK WRITE   SWAPIN    IO    COMMAND<br
/> 19215 be/1 mysql       0.00 B/s    1.24 M/s  0.00 %  2.58 % mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock<br
/> 11670 be/1 mysql       0.00 B/s  152.28 K/s  0.00 %  0.64 % mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock<br
/> 11656 be/1 mysql       0.00 B/s    1.11 M/s  0.00 %  0.00 % mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock</code></p><p>Other similar tools are <strong>iopp </strong>(presented in a <a
href="http://www.ducea.com/2009/03/09/iopp-howto-get-io-information-per-process/">previous post</a>) and <strong>pidstat </strong>from newer sysstat packages (&gt;= Sysstat 8.0.0). <span
style="text-decoration: line-through;">Stay tuned for a future post on</span> <a
href="http://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/">here is how</a> you can run iotop on debian etch (that uses by default python2.4).</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/10/iotop-simple-top-like-io-monitor/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>iopp: howto get i/o information per process</title><link>http://www.ducea.com/2009/03/09/iopp-howto-get-io-information-per-process/</link> <comments>http://www.ducea.com/2009/03/09/iopp-howto-get-io-information-per-process/#comments</comments> <pubDate>Mon, 09 Mar 2009 10:30:16 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Centos]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[iopp]]></category> <category><![CDATA[vmstat]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=712</guid> <description><![CDATA[We all know and love vmstat, but wouldn&#8217;t it be nice to get such information on a per process basis, to be able to better understand what is causing i/o problems? This is exactly what iopp, written by Mark Wong and released as open source does: &#8220;It&#8217;s a custom tool to go through the Linux [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>We all know and love <strong>vmstat</strong>, but wouldn&#8217;t it be nice to get such information on a <strong>per process</strong> basis, to be able to better understand what is causing <strong>i/o</strong> problems? This is exactly what <strong>iopp</strong>, written by <em>Mark Wong</em> and released as open source does:<br
/> <em>&#8220;It&#8217;s a custom tool to go through the Linux process table to get i/o statistics per process. It is open source and can be downloaded from: <a
href="http://git.postgresql.org/?p=~markwkm/iopp.git;a=summary" target="_blank">http://git.postgresql.org/?p=~markwkm/iopp.git;a=summary</a>&#8220;</em></p><p>Now this sounds interesting, and I am sure anyone that has dealt with i/o issues in the past will probably find this very useful. Let&#8217;s see how we can <strong>install </strong>it and what kind of reporting we get. We will install this from source and here are some quick steps to do this (you will need git and cmake for this):<br
/> <code>git clone git://git.postgresql.org/git/~markwkm/iopp.git<br
/> cd iopp<br
/> cmake CMakeLists.txt<br
/> make</code></p><p><span
id="more-712"></span>And install it:<br
/> <code>make install DESTDIR=/usr<br
/> [100%] Built target iopp<br
/> Install the project...<br
/> -- Install configuration: ""<br
/> -- Installing /usr/bin/iopp<br
/> -- Installing /usr/share/man/man8/iopp.8</code><br
/> after this <strong>iopp </strong>will be installed into <strong>/usr/bin</strong>.</p><p>Let&#8217;s see what are the program parameters:<br
/> <code>iopp -h<br
/> usage: iopp -h|--help<br
/> usage: iopp [-ci] [-k|-m] [delay [count]]<br
/> -c, --command display full command line<br
/> -h, --help display help<br
/> -i, --idle hides idle processes<br
/> -k, --kilobytes display data in kilobytes<br
/> -m, --megabytes display data in megabytes<br
/> -u, --human-readable display data in kilo-, mega-, or giga-bytes</code></p><p>And finally let&#8217;s test it:<br
/> <code>iopp -i -u 5<br
/> pid rchar wchar    syscr    syscw reads writes cwrites command<br
/> 2464    0B    0B        0        0    0B  8192B      0B kjournald<br
/> 3364  515K    0B     1336        0    0B     0B      0B mysqld<br
/> 4664    0B  134B        0        4    0B     0B      0B apache2<br
/> 4685  803K  114K      454       80    0B     0B      0B collectd<br
/> 20758   82K   82K      329      329    0B    84K      0B cronolog<br
/> 26236   67K 3754B       59       27    0B     0B      0B apache2<br
/> ...</code></p><p>The manual page explains each output field:</p><ul><li> <strong>pid</strong>: The process id.</li><li> <strong>rchar</strong>: The number of bytes which this task has caused to be read from storage.</li><li> <strong>wchar</strong>: The number of bytes which this task has caused, or shall cause to be written to disk.</li><li> <strong>syscr</strong>: Count of the number of read I/O operations.</li><li> <strong>syscw</strong>: Count of the number of write I/O operations.</li><li> <strong>rbytes rkb rmb reads</strong>: Count of the number of bytes which this process really did cause to be fetched from the storage layer.</li><li> <strong>wbytes wkb wmb writes</strong>: Count of the number of bytes which this process really did cause to be sent to the storage layer.</li><li> <strong>cwbytes cwkb cwmb cwrites</strong>: The number of bytes which this process caused to not happen, by truncating pagecache.</li><li> <strong>command</strong>: Filename of the executable.</li></ul><p>Other similar tools are <strong><a
href="http://guichaz.free.fr/iotop/" target="_blank">iotop</a> </strong>and <strong>pidstat </strong>from newer <strong>sysstat </strong>packages and I will describe them in a future post.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/09/iopp-howto-get-io-information-per-process/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Mdadm Cheat Sheet</title><link>http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/</link> <comments>http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/#comments</comments> <pubDate>Sun, 08 Mar 2009 11:19:20 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Centos]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Tips & Tricks]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[cheatsheet]]></category> <category><![CDATA[mdadm]]></category> <category><![CDATA[raid]]></category> <category><![CDATA[tips]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=691</guid> <description><![CDATA[Mdadm is the modern tool most Linux distributions use these days to manage software RAID arrays; in the past raidtools was the tool we have used for this. This cheat sheet will show the most common usages of mdadm to manage software raid arrays; it assumes you have a good understanding of software RAID and [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p><strong>Mdadm </strong>is the modern tool most Linux distributions use these days to manage <strong>software RAID</strong> arrays; in the past <em>raidtools </em>was the tool we have used for this. This cheat sheet will show the most <em>common usages of mdadm</em> to manage software raid arrays; it assumes you have a good understanding of software RAID and Linux in general, and it will just explain the commands line usage of mdadm. The examples bellow use RAID1, but they can be adapted for any RAID level the Linux kernel driver supports.</p><h3>1. Create a new RAID array</h3><p>Create (mdadm &#8211;create) is used to create a new array:<br
/> <code>mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb2</code><br
/> <span
id="more-691"></span>or using the compact notation:<br
/> <code>mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[ab]1</code></p><h3>2. /etc/mdadm.conf</h3><p>/etc/mdadm.conf or /etc/mdadm/mdadm.conf (on debian) is the main configuration file for mdadm. After we create our RAID arrays we add them to this file using:<br
/> <code>mdadm --detail --scan &gt;&gt; /etc/mdadm.conf</code><br
/> or on debian<br
/> <code>mdadm --detail --scan &gt;&gt; /etc/mdadm/mdadm.conf</code></p><h3>3. Remove a disk from an array</h3><p>We can&#8217;t remove a disk directly from the array, unless it is failed, so we first have to fail it (if the drive it is failed this is normally already in failed state and this step is not needed):<br
/> <code>mdadm --fail /dev/md0 /dev/sda1</code><br
/> and now we can remove it:<br
/> <code>mdadm --remove /dev/md0 /dev/sda1</code></p><p>This can be done in a single step using:<br
/> <code>mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1</code></p><h3>4. Add a disk to an existing array</h3><p>We can add a new disk to an array (replacing a failed one probably):<br
/> <code>mdadm --add /dev/md0 /dev/sdb1</code></p><h3>5. Verifying the status of the RAID arrays</h3><p>We can check the status of the arrays on the system with:<br
/> <code>cat /proc/mdstat</code><br
/> or<br
/> <code>mdadm --detail /dev/md0</code></p><p>The output of this command will look like:</p><pre><code>cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

md1 : active raid1 sdb3[1] sda3[0]
19542976 blocks [2/2] [UU]

md2 : active raid1 sdb4[1] sda4[0]
223504192 blocks [2/2] [UU]</code></pre><p>here we can see both drives are used and working fine &#8211; <strong>U</strong>. A failed drive will show as <strong>F</strong>, while a degraded array will miss the second disk <strong>-</strong></p><p>Note: while monitoring the status of a RAID rebuild operation using watch can be useful:<br
/> <code>watch cat /proc/mdstat</code></p><h3>6. Stop and delete a RAID array</h3><p>If we want to completely remove a raid array we have to stop if first and then remove it:<br
/> <code>mdadm --stop /dev/md0<br
/> mdadm --remove /dev/md0</code><br
/> and finally we can even delete the superblock from the individual drives:<br
/> <code>mdadm --zero-superblock /dev/sda</code></p><p>Finally in using RAID1 arrays, where we create <strong>identical partitions</strong> on both drives this can be useful to copy the partitions from sda to sdb:<br
/> <code>sfdisk -d /dev/sda | sfdisk /dev/sdb</code></p><p>(this will dump the partition table of sda, removing completely the existing partitions on sdb, so be sure you want this before running this command, as it will not warn you at all).</p><p>There are many other usages of <strong>mdadm </strong>particular for each type of RAID level, and I would recommend to use the manual page (<em>man mdadm</em>) or the help (<em>mdadm &#8211;help</em>) if you need more details on its usage. Hopefully these quick examples will put you on the fast track with how mdadm works.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/feed/</wfw:commentRss> <slash:comments>58</slash:comments> </item> </channel> </rss>
<!-- Served from: www.ducea.com @ 2012-02-08 10:12:28 by W3 Total Cache -->
