<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0" xml:base="http://meinit.nl">
<channel>
 <title>Me in IT - Articles</title>
 <link>http://meinit.nl/articles</link>
 <description>Adventures in Red Hat Enterprise Linux, CentOS, Fedora, OpenBSD and other open source solutions.</description>
 <language>en</language>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MeInIt" /><feedburner:info uri="meinit" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>MeInIt</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FMeInIt" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FMeInIt" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FMeInIt" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/MeInIt" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FMeInIt" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FMeInIt" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FMeInIt" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><item>
 <title>Access thepiratebay.org from The Netherlands</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/GZPPaKh_WEA/access-thepiratebayorg-netherlands</link>
 <description>&lt;p&gt;Long story short: &lt;b&gt;Visit &lt;a href="/thepiratebay.se/"&gt;The Pirate Bay through Me in IT Consultancy&lt;/a&gt; instead of typing it in the URL directly&lt;/b&gt; and you'll be able to download torrents again, because from &lt;a href="http://zoeken.rechtspraak.nl/detailpage.aspx?ljn=BV0549&amp;amp;u_ljn=BV0549"&gt;The Netherlands, using Ziggo or XS4All, it's going to be difficult to access thepiratebay.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Short story long: With &lt;a href="http://www.apache.org/"&gt;Apache&lt;/a&gt;, &lt;a href="http://httpd.apache.org/docs/2.0/mod/mod_proxy.html"&gt;mod_proxy&lt;/a&gt; and &lt;a href="http://apache.webthing.com/mod_proxy_html/"&gt;mod_proxy_html&lt;/a&gt; you can make other website available through a &lt;a href="http://httpd.apache.org/docs/2.1/mod/core.html#location"&gt;Location&lt;/a&gt; on another website. If the web server is in a different region, chances are you'll be able to visit "blocked" websites.&lt;/p&gt;
&lt;p&gt;To technically make this work, I used these ingredients:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;CentOS - I used 5, but 6 should work too.&lt;/li&gt;
&lt;li&gt;Apache - Just install it with "yum install httpd".&lt;/li&gt;
&lt;li&gt;mod_proxy_html - I created &lt;a href="/sites/meinit.nl/files/mod_proxy_html-3.1.2-1.src.rpm"&gt;an SRC RPM for mod_proxy_html&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;configuration files - See below.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The configuration looks like this:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;&amp;lt;VirtualHost *.80&amp;gt;&lt;br /&gt;...&lt;br /&gt; ProxyRequests off&lt;br /&gt;&lt;br /&gt; ProxyPass /thepiratebay.org/ http://thepiratebay.org/&lt;br /&gt; ProxyPass /static.thepiratebay.org/ http://static.thepiratebay.org/&lt;br /&gt; ProxyPass /rss.thepiratebay.org/ http://rss.thepiratebay.org/&lt;br /&gt; ProxyPass /torrents.thepiratebay.org http://torrents.thepiratebay.org&lt;br /&gt;&lt;br /&gt; &amp;lt;Location /thepiratebay.org/&amp;gt;&lt;br /&gt;&amp;nbsp; ProxyPassReverse /&lt;br /&gt;&amp;nbsp; ProxyHTMLEnable On&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://thepiratebay.org /thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://static.thepiratebay.org /static.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://rss.thepiratebay.org /rss.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap //static.thepiratebay.org /static.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://torrents.thepiratebay.org /torrents.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap / /thepiratebay.org/&lt;br /&gt;&amp;nbsp; RequestHeader unset Accept-Encoding&lt;br /&gt; &amp;lt;/Location&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;Location /static.thepiratebay.org/&amp;gt;&lt;br /&gt;&amp;nbsp; ProxyPassReverse /&lt;br /&gt;&amp;nbsp; ProxyHTMLEnable On&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://thepiratebay.org /thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://static.thepiratebay.org /static.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://rss.thepiratebay.org /rss.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap //static.thepiratebay.org /static.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://torrents.thepiratebay.org /torrents.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap / /static.thepiratebay.org/&lt;br /&gt;&amp;nbsp; RequestHeader unset Accept-Encoding&lt;br /&gt; &amp;lt;/Location&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;Location /rss.thepiratebay.org/&amp;gt;&lt;br /&gt;&amp;nbsp; ProxyPassReverse /&lt;br /&gt;&amp;nbsp; ProxyHTMLEnable On&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://thepiratebay.org /thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://static.thepiratebay.org /static.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://rss.thepiratebay.org /rss.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap //static.thepiratebay.org /static.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://torrents.thepiratebay.org /torrents.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap / /rss.thepiratebay.org/&lt;br /&gt;&amp;nbsp; RequestHeader unset Accept-Encoding&lt;br /&gt; &amp;lt;/Location&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;Location /torrents.thepiratebay.org/&amp;gt;&lt;br /&gt;&amp;nbsp; ProxyPassReverse /&lt;br /&gt;&amp;nbsp; ProxyHTMLEnable On&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://thepiratebay.org /thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://static.thepiratebay.org /static.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://rss.thepiratebay.org /rss.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap http://torrents.thepiratebay.org /torrents.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap //static.thepiratebay.org /static.thepiratebay.org&lt;br /&gt;&amp;nbsp; ProxyHTMLURLMap / /rss.thepiratebay.org/&lt;br /&gt;&amp;nbsp; RequestHeader unset Accept-Encoding&lt;br /&gt; &amp;lt;/Location&amp;gt;&lt;br /&gt;...&lt;br /&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/access-thepiratebayorg-netherlands#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 17 Jan 2012 13:22:10 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">448 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/access-thepiratebayorg-netherlands</feedburner:origLink></item>
<item>
 <title>Zabbix triggers with "flap-detection" and a grace period.</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/U40C4IHes0A/zabbix-triggers-flap-detection-and-grace-period</link>
 <description>&lt;p&gt;Monitoring an environment with some monitoring system gives control, so it's pretty important. But it can be a challenge to setup a monitoring system; it should not alert too fast, but also not too slow.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.nagios.org/"&gt;Nagios&lt;/a&gt; uses "flap detection" to prevent many ERROR's and OK's being sent right after each other. &lt;a href="http://www.zabbix.com/"&gt;Zabbix&lt;/a&gt; calls this "hysteresis". Zabbix's hysteresis is rather difficult to understand, so I'd like to share some triggers that I have setup for Zabbix that implement both flap detection/hysteresis and grace.&lt;/p&gt;
&lt;p&gt;Grace can be defined like this: "When a value is higher (or lower) then a threshold, make sure it's a little lower (or higher) as the threshold that caused the trigger to alert, before recovering a trigger." I know; it's not easy to understand... Let's look at some examples.&lt;/p&gt;
&lt;h2&gt;Thresholds that should be above a certain value&lt;/h2&gt;
&lt;p&gt;With values that need to be below a threshold, like cpu load, number of users logged in or number of processes running:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;({TRIGGER.VALUE}=0&amp;amp;{TEMPLATE:CHECK[ITEM].min(300)&amp;gt;ALERTVALUE)|({TRIGGER.VALUE}=1&amp;amp;{TEMPLATE:CHECK[ITEM].max(300)&amp;lt;RECOVERYVALUE)&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Just to clarify the different part of the trigger:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;{TRIGGER.VALUE} makes sure the first part (before the |) is evaluated when there is no alert, the part after | indicates the trigger should be on/in alert.&lt;/li&gt;
&lt;li&gt;.min(300) makes sure the values are minimally as high as ALERTVALUE for 300 seconds.&lt;/li&gt;
&lt;li&gt;The last part (after the |) makes sure the trigger recovers when the measured value is lower than RECOVERYVALUE for 300 seconds.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example CPU load with an ALERTVALUE of 5 and a RECOVERYVALUE of 4:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;({TRIGGER.VALUE}=0&amp;amp;{Template_Linux:system.cpu.load[,avg1].min(300)}&amp;gt;5)|({TRIGGER.VALUE}=1&amp;amp;{Template_Linux:system.cpu.load[,avg1].max(300)}&amp;lt;4)&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Thresholds that should be below a certain value&lt;/h2&gt;
&lt;p&gt;With values that need to be above a threshold, like percentage diskspace free, number of inodes free or number of httpd processes running:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;({TRIGGER.VALUE}=0&amp;amp;{TEMPLATE:CHECK[ITEM].max(300)&amp;lt;ALERTVALUE)|({TRIGGER.VALUE}=1&amp;amp;{TEMPLATE:CHECK[ITEM].min(300)&amp;gt;RECOVERYVALUE)&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;For example disk space of /var free in percent with an ALERTVALUE of 10 and a RECOVERYVALUE of 11:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;({TRIGGER.VALUE}=0&amp;amp;{Template_Linux:vfs.fs.size[/var,pfree].max(300)}&amp;lt;10)|({TRIGGER.VALUE}=1&amp;amp;{Template_Linux:vfs.fs.size[/var,pfree].min(300)}&amp;gt;11)&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;These rather complex triggers will prevent spikes of load or diskusage to cause an alert, but the drawback it that you might miss certain interesting spikes too. Overall my opinion is that a monitoring system should not drive people crazy because alerts will be ignored when too many are received.&lt;/p&gt;
</description>
 <comments>http://meinit.nl/zabbix-triggers-flap-detection-and-grace-period#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Wed, 09 Nov 2011 10:03:26 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">447 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/zabbix-triggers-flap-detection-and-grace-period</feedburner:origLink></item>
<item>
 <title>Examples for batch on linux</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/0skAFmbVlL0/examples-batch-linux</link>
 <description>&lt;p&gt;Linux has a few ways to schedule jobs to be executed. I am sure most are familiar with &lt;a href="http://en.wikipedia.org/wiki/Cron"&gt;crontab&lt;/a&gt; and &lt;a href="http://linux.about.com/library/cmd/blcmdl1_at.htm"&gt;at&lt;/a&gt;, but batch is lesser known.&lt;/p&gt;
&lt;p&gt;"batch" can be used to: (from the man-page on batch)&lt;br /&gt;
&lt;code&gt;executes commands when system load levels permit; in other words, when the load average drops below 0.8, or the value specified in the invocation of atrun.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;crontab&lt;/b&gt; is used for periodic scheduling.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;at&lt;/b&gt; is used for executing something once at a specific time.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;batch&lt;/b&gt; can be used to execute commands when your system has resourses.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also combine crontab and batch. Imagine you need to run a sequence of command in a specific order every hour. crontab does not guarantee one command is finished when it executs the next command.&lt;br /&gt;
batch can be used from crontab like so:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;crontab -l&lt;br /&gt;0 * * * * /usr/bin/batch now /usr/local/bin/prepare-something.sh&lt;br /&gt;1 * * * * /usr/bin/batch now /usr/local/bin/process-something.sh&lt;br /&gt;2 * * * * /usr/bin/batch now /usr/local/bin/report-something.sh&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This batches these three commands in a specific order, one after the other, when the systemload is not too high.&lt;/p&gt;
&lt;p&gt;One specific situation where I use this; Drupal needs to run a program (cron.php) every hour. crontab would be perfect for that, but when the load is too high, it's not a problem that this program is executed a little later. This is what I have setup:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;0 * * * * /usr/bin/batch now /usr/bin/wget -o /dev/null -O /dev/null http://1.example.com/cron.php&lt;br /&gt;1 * * * * /usr/bin/batch now /usr/bin/wget -o /dev/null -O /dev/null http://2.example.com/cron.php&lt;br /&gt;2 * * * * /usr/bin/batch now /usr/bin/wget -o /dev/null -O /dev/null http://3.example.com/cron.php&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This ensures that every hour cron.php is ran, but not if the systemload is too high (0.8 or more). One disadvantage of this solution; when your system is overloaded for a long period of time, these batch jobs pile up, then when the load drops below 0.8, all batched commands will be executed. Happily Drupals cron.php will not consume that much resources when it's ran twice.&lt;/p&gt;
</description>
 <comments>http://meinit.nl/examples-batch-linux#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Wed, 26 Oct 2011 11:25:58 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">443 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/examples-batch-linux</feedburner:origLink></item>
<item>
 <title>Release scheme for RPM based Linux distributions</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/NABECnAlWP4/release-scheme-rpm-based-linux-distributions</link>
 <description>&lt;p&gt;It can be rather confusing what the differences and similarities are on Fedora, Red Hat Enterprise Linux and CentOS. Especially with different versions. This article explains what release schedule and relations the various RPM based Linux distributions have.&lt;/p&gt;
&lt;p&gt;Fedora is a Red Hat sponsored community project. &lt;a href="http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle"&gt;Fedora is release approximately &lt;b&gt;every 6 month&lt;/b&gt;&lt;/a&gt;. Fedora "supports" (supplies updates) for 13 month only. Clearly this is a development distribution.&lt;/p&gt;
&lt;p&gt;Red Hat picks up a Fedora version and adds a few patches and call that "Red Hat Enterprise Linux". Red Hat supports that version for quite some time. &lt;a href="http://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux#Relationship_to_free_and_community_distributions"&gt;Red Hat releases more conservatively; &lt;b&gt;every 2 years&lt;/b&gt;&lt;/a&gt;. Red Hat supports a release for about 5 years after releasing, making this distribution much more "enterprise".&lt;/p&gt;
&lt;table&gt;
&lt;caption&gt;Fedora - Red Hat release relationship&lt;/caption&gt;
&lt;tr&gt;
&lt;td&gt;Fedora release&lt;/td&gt;
&lt;td&gt;Red Hat release&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fedora Core 3&lt;/td&gt;
&lt;td&gt;Red Hat Enterprise Linux 4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fedora Core 6&lt;/td&gt;
&lt;td&gt;Red Hat Enterprise Linux 5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fedora Core 13&lt;/td&gt;
&lt;td&gt;Red Hat Enterprise Linux 6&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;CentOS picks up the source code that Red Hat published for Red Hat Enterprise Linux. The CentOS community patches the artwork and very few other things. &lt;b&gt;CentOS "supports" (provides updates) for as long as Red Hat supplies updates to Red Hat Enterprise Linux&lt;/b&gt;.&lt;br /&gt;
Interesting to know; once you have choosen to use a certain main version of CentOS, you'll automatically update to the most recent child-version of that release when using "yum update". So; if you install "CentOS 5.0" and run "yum update", you will automatically have "CentOS 5.7". (at the time of this writing.)&lt;/p&gt;
&lt;p&gt;So; this makes this image:&lt;br /&gt;
&lt;img src="/files/images/Releases.PNG" /&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/release-scheme-rpm-based-linux-distributions#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 27 Sep 2011 06:58:46 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">440 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/release-scheme-rpm-based-linux-distributions</feedburner:origLink></item>
<item>
 <title>Apache Tomcat 7 spec file RPM</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/40brxt0srBQ/apache-tomcat-7-spec-file-rpm</link>
 <description>&lt;p&gt;I tried to find an RPM for &lt;a href="http://tomcat.apache.org/"&gt;Apache Tomcat&lt;/a&gt; version 7, but could not find one. You can use this one, it requires the source code, downloadable from Apache Tomcat's website, under "&lt;a href="http://tomcat.apache.org/download-70.cgi#Source_Code_Distributions"&gt;Source Code Distributions&lt;/a&gt;".&lt;/p&gt;
&lt;p&gt;This SPEC file creates an RPM "apache-tomcat" that installs in /opt/tomcat, and the default web applications (apache-tomcat-manager, apache-tomcat-ROOT, apache-tomcat-docs, apache-tomcat-examples, apache-tomcat-host-manager). An init-script is included at the bottom, that needs to be available in the SOURCES directory, named "apache-tomcat-iniscript".&lt;/p&gt;
&lt;p&gt;Downloads:&lt;br /&gt;
SOURCE:&lt;br /&gt;
&lt;a href="http://meinit.nl/sites/meinit.nl/files/apache-tomcat-7.0.20-1.src.rpm"&gt;Apache Tomcat SRC rpm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;x86_64:&lt;br /&gt;
&lt;a href="http://meinit.nl/sites/meinit.nl/files/apache-tomcat-7.0.20-1.x86_64.rpm"&gt;Apache Tomcat 86_64 rpm&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://meinit.nl/sites/meinit.nl/files/apache-tomcat-ROOT-7.0.20-1.x86_64.rpm"&gt;Apache Tomcat ROOT application 86_64 rpm&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://meinit.nl/sites/meinit.nl/files/apache-tomcat-docs-7.0.20-1.x86_64.rpm"&gt;Apache Tomcat docs 86_64 rpm&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://meinit.nl/sites/meinit.nl/files/apache-tomcat-examples-7.0.20-1.x86_64.rpm"&gt;Apache Tomcat example application 86_64 rpm&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://meinit.nl/sites/meinit.nl/files/apache-tomcat-host-manager-7.0.20-1.x86_64.rpm"&gt;Apache Tomcat host manager application 86_64 rpm&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://meinit.nl/sites/meinit.nl/files/apache-tomcat-manager-7.0.20-1.x86_64.rpm"&gt;Apache Tomcat manager application 86_64 rpm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So far it's been fine, but any comments would be appreciated.&lt;/p&gt;
&lt;p&gt;apache-tomcat.spec:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;Name: apache-tomcat&lt;br /&gt;Version: 7.0.20&lt;br /&gt;Release: 1&lt;br /&gt;Summary: Open source software implementation of the Java Servlet and JavaServer Pages technologies.&lt;br /&gt;Group: Productivity/Networking/Web/Servers&lt;br /&gt;License: Apache Software License.&lt;br /&gt;Url: http://tomcat.apache.org&lt;br /&gt;Source: %{name}-%{version}-src.tar.gz&lt;br /&gt;&lt;br /&gt;BuildRoot: %{_tmppath}/%{name}-%{version}-build&lt;br /&gt;BuildRequires: ant&lt;br /&gt;BuildRequires: ant-trax&lt;br /&gt;Requires: java-1.6.0-openjdk&lt;br /&gt;BuildArch: x86_64&lt;br /&gt;&lt;br /&gt;%description&lt;br /&gt;Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed under the Java Community Process.&lt;br /&gt;&lt;br /&gt;%package manager&lt;br /&gt;Summary: The management web application of Apache Tomcat.&lt;br /&gt;Group: System Environmnet/Applications&lt;br /&gt;Requires: %{name}-%{version}-%{release}&lt;br /&gt;BuildArch: noarch&lt;br /&gt;&lt;br /&gt;%description manager&lt;br /&gt;The management web application of Apache Tomcat.&lt;br /&gt;&lt;br /&gt;%package ROOT&lt;br /&gt;Summary: The ROOT web application of Apache Tomcat.&lt;br /&gt;Group: System Environmnet/Applications&lt;br /&gt;Requires: %{name}-%{version}-%{release}&lt;br /&gt;BuildArch: noarch&lt;br /&gt;&lt;br /&gt;%description ROOT&lt;br /&gt;The ROOT web application of Apache Tomcat.&lt;br /&gt;&lt;br /&gt;%package docs&lt;br /&gt;Summary: The docs web application of Apache Tomcat.&lt;br /&gt;Group: System Environmnet/Applications&lt;br /&gt;Requires: %{name}-%{version}-%{release}&lt;br /&gt;BuildArch: noarch&lt;br /&gt;&lt;br /&gt;%description docs&lt;br /&gt;The docs web application of Apache Tomcat.&lt;br /&gt;&lt;br /&gt;%package examples&lt;br /&gt;Summary: The examples web application of Apache Tomcat.&lt;br /&gt;Group: System Environmnet/Applications&lt;br /&gt;Requires: %{name}-%{version}-%{release}&lt;br /&gt;BuildArch: noarch&lt;br /&gt;&lt;br /&gt;%description examples&lt;br /&gt;The examples web application of Apache Tomcat.&lt;br /&gt;&lt;br /&gt;%package host-manager&lt;br /&gt;Summary: The host-manager web application of Apache Tomcat.&lt;br /&gt;Group: System Environmnet/Applications&lt;br /&gt;Requires: %{name}-%{version}-%{release}&lt;br /&gt;BuildArch: noarch&lt;br /&gt;&lt;br /&gt;%description host-manager&lt;br /&gt;The host-manager web application of Apache Tomcat.&lt;br /&gt;&lt;br /&gt;%prep&lt;br /&gt;&lt;br /&gt;%setup -q -n %{name}-%{version}-src&lt;br /&gt;# This tells ant to install software in a specific directory.&lt;br /&gt;cat &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; build.properties&lt;br /&gt;base.path=%{buildroot}/opt/apache-tomcat&lt;br /&gt;EOF&lt;br /&gt;&lt;br /&gt;%build&lt;br /&gt;ant&lt;br /&gt;&lt;br /&gt;%install&lt;br /&gt;rm -Rf %{buildroot}&lt;br /&gt;mkdir -p %{buildroot}/opt/apache-tomcat&lt;br /&gt;mkdir -p %{buildroot}/opt/apache-tomcat/pid&lt;br /&gt;mkdir -p %{buildroot}/opt/apache-tomcat/webapps&lt;br /&gt;mkdir -p %{buildroot}/etc/init.d/&lt;br /&gt;mkdir -p %{buildroot}/var/run/apache-tomcat&lt;br /&gt;%{__cp} -Rip ./output/build/{bin,conf,lib,logs,temp,webapps} %{buildroot}/opt/apache-tomcat&lt;br /&gt;%{__cp} %{_sourcedir}/apache-tomcat-initscript %{buildroot}/etc/init.d/apache-tomcat&lt;br /&gt;&lt;br /&gt;%clean&lt;br /&gt;rm -rf %{buildroot}&lt;br /&gt;&lt;br /&gt;%pre&lt;br /&gt;getent group tomcat &amp;gt; /dev/null || groupadd -r tomcat&lt;br /&gt;getent passwd tomcat &amp;gt; /dev/null || useradd -r -g tomcat tomcat&lt;br /&gt;&lt;br /&gt;%post&lt;br /&gt;chkconfig --add %{name}&lt;br /&gt;&lt;br /&gt;%preun&lt;br /&gt;if [ &amp;quot;$1&amp;quot; = &amp;quot;0&amp;quot; ] ; then&lt;br /&gt; service %{name} stop &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt; chkconfig --del %{name}&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;%files&lt;br /&gt;%defattr(-,tomcat,tomcat,-)&lt;br /&gt;%dir /opt/apache-tomcat&lt;br /&gt;%config /opt/apache-tomcat/conf/*&lt;br /&gt;/opt/apache-tomcat/bin&lt;br /&gt;/opt/apache-tomcat/lib&lt;br /&gt;/opt/apache-tomcat/logs&lt;br /&gt;/opt/apache-tomcat/temp&lt;br /&gt;/opt/apache-tomcat/pid&lt;br /&gt;%dir /opt/apache-tomcat/webapps&lt;br /&gt;/var/run/apache-tomcat&lt;br /&gt;%attr(0755,root,root) /etc/init.d/apache-tomcat&lt;br /&gt;&lt;br /&gt;%files manager&lt;br /&gt;/opt/apache-tomcat/webapps/manager&lt;br /&gt;&lt;br /&gt;%files ROOT&lt;br /&gt;/opt/apache-tomcat/webapps/ROOT&lt;br /&gt;&lt;br /&gt;%files docs&lt;br /&gt;/opt/apache-tomcat/webapps/docs&lt;br /&gt;&lt;br /&gt;%files examples&lt;br /&gt;/opt/apache-tomcat/webapps/examples&lt;br /&gt;&lt;br /&gt;%files host-manager&lt;br /&gt;/opt/apache-tomcat/webapps/host-manager&lt;br /&gt;&lt;br /&gt;%changelog&lt;br /&gt;* Fri Aug 19 2011 - robert (at) meinit.nl&lt;br /&gt;- Updated to apache tomcat 7.0.20&lt;br /&gt;- Split (example) applications into their own RPM.&lt;br /&gt;* Mon Jul 4 2011 - robert (at) meinit.nl&lt;br /&gt;- Initial release.&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;apache-tomcat-initscript:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# apache-tomcat&lt;br /&gt;#&lt;br /&gt;# chkconfig: - 85 15&lt;br /&gt;# description: Jakarta Tomcat Java Servlets and JSP server&lt;br /&gt;# processname: java&lt;br /&gt;# pidfile: /var/run/apache-tomcat/pid&lt;br /&gt;&lt;br /&gt;. /etc/rc.d/init.d/functions&lt;br /&gt;&lt;br /&gt;# Set Tomcat environment.&lt;br /&gt;USER=tomcat&lt;br /&gt;LOCKFILE=/var/lock/apache-tomcat&lt;br /&gt;export BASEDIR=/opt/apache-tomcat&lt;br /&gt;export TOMCAT_HOME=$BASEDIR&lt;br /&gt;export CATALINA_PID=/var/run/apache-tomcat/pid&lt;br /&gt;export CATALINA_OPTS=&amp;quot;-DHOME=$BASEDIR/home -Xmx512m -Djava.awt.headless=true&amp;quot;&lt;br /&gt;&lt;br /&gt;case &amp;quot;$1&amp;quot; in&lt;br /&gt;&amp;nbsp; start)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo -n &amp;quot;Starting apache-tomcat: &amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status -p $CATALINA_PID apache-tomcat &amp;gt; /dev/null &amp;amp;&amp;amp; failure || (su -p -s /bin/sh $USER -c &amp;quot;$TOMCAT_HOME/bin/catalina.sh start&amp;quot; &amp;gt; /dev/null &amp;amp;&amp;amp; (touch $LOCKFILE ; success))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; stop)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo -n &amp;quot;Shutting down apache-tomcat: &amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status -p $CATALINA_PID apache-tomcat &amp;gt; /dev/null &amp;amp;&amp;amp; su -p -s /bin/sh $USER -c &amp;quot;$TOMCAT_HOME/bin/catalina.sh stop&amp;quot; &amp;gt; /dev/null &amp;amp;&amp;amp; (rm -f $LOCKFILE ; success) || failure&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; restart)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $0 stop&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $0 start&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; condrestart)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ -e $LOCKFILE ] &amp;amp;&amp;amp; $0 restart&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; status)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status -p $CATALINA_PID apache-tomcat&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; *)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Usage: $0 {start|stop|restart|condrestart|status}&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;esac&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/apache-tomcat-7-spec-file-rpm#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Thu, 14 Jul 2011 14:14:56 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">438 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/apache-tomcat-7-spec-file-rpm</feedburner:origLink></item>
<item>
 <title>service status somedaemon - status: unrecognized service</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/LQ3vnmvp4Oc/service-status-somedaemon-status-unrecognized-service</link>
 <description>&lt;p&gt;I created an initscript for a daemon recently it works well for starting and stopping, but "service status somedaemon" would return "status: unrecognized service"&lt;/p&gt;
&lt;p&gt;After a bit of googling I found that the top few lines of the initscript are critical. It should be a describe here:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# somedaemon&lt;br /&gt;#&lt;br /&gt;# chkconfig: - 85 15&lt;br /&gt;# description: Some daemon&lt;br /&gt;# processname: somedaemon&lt;br /&gt;# pidfile: /var/run/somedaemon.pid&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Here is what these lines do.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;#!/bin/sh - This is a shell script.&lt;/li&gt;
&lt;li&gt;# somedaemon - This is the name of the service used with for "service status somedaemon". If this is missing, you'll see: "status: unrecognized service".&lt;/li&gt;
&lt;li&gt;chkconfig: - 85 15 - This tells chkconfig three things, firstly (the dash) at what runlevel to start it. A dash means default. Secondly at what priority to start and lastly at what priority to stop.&lt;/li&gt;
&lt;li&gt;description: Some daemon - Not used.&lt;/li&gt;
&lt;li&gt;processname: somedaemon - Not used.&lt;/li&gt;
&lt;li&gt;pidfile: /var/run/somedaemon.pid - Used in /etc/rc.d/init.d/functions to determine if the process is running or not.&lt;/li&gt;
&lt;/ol&gt;
</description>
 <comments>http://meinit.nl/service-status-somedaemon-status-unrecognized-service#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Fri, 08 Jul 2011 09:35:55 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">437 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/service-status-somedaemon-status-unrecognized-service</feedburner:origLink></item>
<item>
 <title>Linux interview questions</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/jatI7VHLTCw/linux-interview-questions</link>
 <description>&lt;p&gt;From time to time you might need to interview somebody for a Linux role. It's hard to think of good questions; you don't want to scare somebody with your questions, but you do want to know if the person is knowledgable.&lt;/p&gt;
&lt;h1&gt;Questions for a junior.&lt;/h1&gt;
&lt;p&gt;"People that use your Linux server complain it's slow. What tools would you use to check resource usage?"&lt;br /&gt;
top, sar, netstat -an, iostat, free, df.&lt;/p&gt;
&lt;p&gt;"You discover a disk is full on your Linux server. What do you use to discover where the bigest files/directories are?"&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To create a short report on the largest directories: du -sk * | sort -nr | head -n10&lt;/li&gt;
&lt;li&gt;You might use "find" to find large files: find / -size +100M&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;"A system needs more disk space. You want to add a partition /var/log. You add a drive to the machine, it becomes /dev/sdb. What actions do you take to use this disk?"&lt;br /&gt;
Depending if you use LVM or not. If you don't use LVM:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;"fdisk /dev/sdb" to add one partition so /dev/sdb1 becomes available.&lt;/li&gt;
&lt;li&gt;"mkfs /dev/sdb1" to create a filesystem on it.&lt;/li&gt;
&lt;li&gt;"mount /dev/sdb1 /var/log". Actually the data needs to be copied into the new /var/log.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you do use LVM:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;"fdisk /dev/sdb" to add one partition so /dev/sdb1 becomes available.&lt;/li&gt;
&lt;li&gt;"pvcreate /dev/sdb1" to make it an LVM device.&lt;/li&gt;
&lt;li&gt;"vgextend SomeVolumeGroup /dev/sdb1" to extend an existing Volume Group.&lt;/li&gt;
&lt;li&gt;"lvcreate -L 1G -n SomeLogicalVolumeName SomeVolumeGroup" to create a new Logical Volume.&lt;/li&gt;
&lt;li&gt;"mkfs /dev/SomeVolumeGroup/SomeLogicalVolumeName" to create a filesystem on it.&lt;/li&gt;
&lt;li&gt;"mount /dev/SomeVolumeGroup/SomeLogicalVolumeName /var/log". Actually the data needs to be copied into the new /var/log.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;Questions for a medior.&lt;/h1&gt;
&lt;p&gt;"People that use your Linux server complain it's slow. You've seen the disk usage is high. What can you do to improve this?"&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Move away services, devide them over different server.&lt;/li&gt;
&lt;li&gt;Add more memory so disk caching can be used better.&lt;/li&gt;
&lt;li&gt;Look into the application, why is it reading/writing so much.&lt;/li&gt;
&lt;li&gt;User faster disks.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;"What happens in relation to DNS, SMTP and IMAP when I send send an email to example@example.com?"&lt;br /&gt;
My computer is likely to be configure to send the email to a mail server on port 25, SMTP protocol. That mailserver will query the DNS for the MX records of example.com. The mailserver that show up with the lowest priority will be contacted to deliver the email. That mailserver at example.com can accept the email and put in into the imap folder for the user or alias of example@example.com.&lt;/p&gt;
&lt;p&gt;"You need to setup 100 Red Hat Enterprise Linux systems. If you don't want to walk around and eject and insert a boot CD 100 times, what options would you have?"&lt;br /&gt;
Kickstarting would help out. Install one machine as you like it, save /root/anaconda-ks.cfg to a webserver. Setup a PXE (DHCP, TFTP, HTTP, DNS) environment and use that kickstart file to install the rest.&lt;/p&gt;
&lt;h1&gt;Questions for a senior.&lt;/h1&gt;
&lt;p&gt;"You have destroyed /etc/pam.d/system-auth and can't login anymore. Another machine has a propper version of /etc/pam.d/system-auth. How would you fix that broken machine?"&lt;br /&gt;
The machine needs to be booted in single user mode so you don't get a login prompt. After that here are some option:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start network, use "nc" to get and replace that file.&lt;/li&gt;
&lt;li&gt;Mount a CD that has the package to fix the broken file.&lt;/li&gt;
&lt;li&gt;Manually repair it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;"You have installed apache, php and mysql and a webapplication such as Drupal. The webapplication tries to send emails to an external mailserver but fails. What could be the cause when these items have been verified:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The web application is correctly configured to use the external mailserver.&lt;/li&gt;
&lt;li&gt;It's possible to connect to the mailserver on the specified port from the command line.&lt;/li&gt;
&lt;li&gt;The logs of the mailserver don't record anything when the web application tries to send email."&lt;/li&gt;
&lt;li&gt;IPtables allows connections out to port 25.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;SELinux could be blocking apache from using port 25 on an external system. The logfile /var/log/messages might inform you about it. To fix it issue "setsebool -P httpd_can_network_connect=1".&lt;/p&gt;
&lt;p&gt;"What determines the load (w, uptime) of a system?"&lt;br /&gt;
The number of processes that are waiting for execution. These processes are in the run queue. Processes could be waiting for io, network or memory allocation.&lt;/p&gt;
</description>
 <comments>http://meinit.nl/linux-interview-questions#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Fri, 10 Jun 2011 07:35:31 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">436 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/linux-interview-questions</feedburner:origLink></item>
<item>
 <title>Drupal on Amazon's Elastic Compute Cloud (EC2)</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/0Pdz3efkOos/drupal-amazons-elastic-compute-cloud-ec2</link>
 <description>&lt;p&gt;Hosting &lt;a href="http://drupal.org/"&gt;Drupal&lt;/a&gt; site in the &lt;a href="http://aws.amazon.com/ec2/"&gt;Amazon EC2&lt;/a&gt; cloud is not difficult. Here is a recipe I have used, first attempt was a &lt;a href="http://fedoraproject.org/wiki/Cloud_SIG/EC2_Images"&gt;Fedora 14 EC2 ami&lt;/a&gt;, but Fedora 14 comes with php 5.3, which can't be combined with Drupal 5.x. If you only have Drupal 6 (or Drupal 7) sites to host, you can use Fedora 14. If you want to use a "small" instance, please read this &lt;a href="https://bugzilla.redhat.com/show_bug.cgi?id=651861"&gt;bug about readdir64_r&lt;/a&gt;. The fix for that bug is easy:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;echo &amp;quot;hwcap 1 nosegneg&amp;quot; &amp;gt; /etc/ld.so.conf.d/libc6-xen.conf&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Let's continue with Drupal on CentOS. &lt;a href="http://support.rightscale.com/18-Release_Notes/02-AMI/RightImages_Release_Notes"&gt;Rightscale provides perfect CentOS amis&lt;/a&gt; that can be used on Amazons EC2 platform. If you install one, these are the steps I took to make it Drupal 5, Drupal 6 and Drupal 7 ready:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# Update the software.&lt;br /&gt;yum -y update&lt;br /&gt;&lt;br /&gt;# Set the timezone for this machine.&lt;br /&gt;cp /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime&lt;br /&gt;&lt;br /&gt;# This images came with 10Gb of ESB storage, I added another 64 Gb volume, here it&amp;#039;s called &amp;quot;/dev/sdc&amp;quot;.&lt;br /&gt;# Use LVM to be ready to grow in the future.&lt;br /&gt;pvcreate /dev/sdc&lt;br /&gt;vgcreate vg0 /dev/sdc&lt;br /&gt;lvcreate vg0 -L 32G -n var-www&lt;br /&gt;lvcreate vg0 -L 1G -n var-lib-mysql&lt;br /&gt;lvcreate vg0 -L 2G -n root&lt;br /&gt;&lt;br /&gt;# Put filesystems on the logical volumes.&lt;br /&gt;mke2fs -j /dev/vg0/var-www&lt;br /&gt;mke2fs -j /dev/vg0/var-lib-mysql&lt;br /&gt;mke2fs -j /dev/vg0/root&lt;br /&gt;&lt;br /&gt;# Add the mountpoints to fstab.&lt;br /&gt;echo &amp;quot;/dev/vg0/var-www /var/www/virtualhosts ext3 defaults 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&lt;br /&gt;echo &amp;quot;/dev/vg0/var-lib-mysql /var/lib/mysql ext3 defaults 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&lt;br /&gt;echo &amp;quot;/dev/vg0/root /root ext3 defaults 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&lt;br /&gt;&lt;br /&gt;# Create the mountpoints.&lt;br /&gt;mkdir /var/www /var/lib/mysql /root&lt;br /&gt;&lt;br /&gt;# Mount all mounpoints in /etc/fstab.&lt;br /&gt;mount -a&lt;br /&gt;&lt;br /&gt;# Install the webserver.&lt;br /&gt;yum -y install httpd&lt;br /&gt;service httpd start&lt;br /&gt;chkconfig httpd on&lt;br /&gt;&lt;br /&gt;# Install the database server.&lt;br /&gt;yum -y install mysql-server&lt;br /&gt;service mysqld start&lt;br /&gt;chkconfig mysqld on&lt;br /&gt;/usr/bin/mysqladmin -u root password &amp;#039;YourPassWord&amp;#039;&lt;br /&gt;&lt;br /&gt;# Install PHP and all required Drupal php modules.&lt;br /&gt;yum -y install php php-mysql php-mcrypt php-xml php-mbstring php-gd&lt;br /&gt;&lt;br /&gt;# Add a single new file in the ESB root filesystem, that includes configurations from /var/www/conf.d&lt;br /&gt;# Using this trick allows you to easily remount the volume on another host in case of troubles.&lt;br /&gt;echo &amp;#039;Include /var/www/conf.d/*.conf&amp;#039; &amp;gt;&amp;gt; /etc/httpd/conf.d/virtualhosts.conf&lt;br /&gt;mkdir /var/www/conf.d&lt;br /&gt;&lt;br /&gt;# Rightscale CentOS images comes with postfix and sendmail. Postfix is enabled, but sendmail is fine for me.&lt;br /&gt;# First erase postfix.&lt;br /&gt;yum -y erase postfix&lt;br /&gt;&lt;br /&gt;# Now reinstall sendmail to fix a few permissions.&lt;br /&gt;yum -y reinstall sendmail&lt;br /&gt;service sendmail start&lt;br /&gt;chkconfig on sendmail&lt;br /&gt;&lt;br /&gt;# Reboot the box to make sure it&amp;#039;s working properly.&lt;br /&gt;reboot&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/drupal-amazons-elastic-compute-cloud-ec2#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 25 Jan 2011 08:32:46 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">435 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/drupal-amazons-elastic-compute-cloud-ec2</feedburner:origLink></item>
<item>
 <title>Fedora 14 to be released</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/5gqRY9sxUys/fedora-14-be-released</link>
 <description>&lt;script id="fedora-banner" type="text/javascript" src="http://fedoraproject.org/static/js/release-counter-ext.js?lang=en"&gt;&lt;/script&gt;&lt;p&gt;So it's not so long before Fedora 14 is released. Lets take a look at some &lt;a href="http://fedoraproject.org/wiki/Releases/14/FeatureList"&gt;features Fedora 14&lt;/a&gt; will bring that look interesting to me.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An &lt;a href="http://fedoraproject.org/wiki/Features/EC2"&gt;Amazon EC2 Image (AIM) for Fedora&lt;/a&gt; will be released! Finally move on from that old Fedora 8 image that was available on Amazon EC2.&lt;/li&gt;
&lt;li&gt;For Desktop Virtualization, &lt;a href="http://fedoraproject.org/wiki/Features/Spice"&gt;Spice&lt;/a&gt; is released. This is a KVM feature that enable super fast access to virtualized desktop systesm, Windows, Linux or any other.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://fedoraproject.org/wiki/Features/perl5.12"&gt;Perl&lt;/a&gt;, &lt;a href="http://fedoraproject.org/wiki/Features/Python_2.7"&gt;Python&lt;/a&gt; and &lt;a href="http://fedoraproject.org/wiki/Features/Ruby_1.8.7"&gt;Ruby&lt;/a&gt; will be updated, nice but not very important to me.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://fedoraproject.org/wiki/Features/OpenSCAP"&gt;OpenSCAP&lt;/a&gt; can ensure security compliance. Should be helpful to many customers.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All in all, a pretty good release although it's kind of hard to improve an already good distribution.&lt;/p&gt;
&lt;p&gt;Many of the changes done in Fedora, will end up in RHEL. Current &lt;a href="http://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux"&gt;estimate&lt;/a&gt; is that RHEL 7 will be based on Fedora 16 (earliest) up to Fedora 19. (latest)&lt;/p&gt;
</description>
 <comments>http://meinit.nl/fedora-14-be-released#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Wed, 27 Oct 2010 05:52:11 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">429 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/fedora-14-be-released</feedburner:origLink></item>
<item>
 <title>Moving a single Drupal instalation into a multisite environment.</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/_reGQTEhg1U/moving-single-drupal-instalation-multisite-environment</link>
 <description>&lt;p&gt;If you'd like to move a single installation of Drupal into a multisite environment, use these steps, and replace example.com for your websites name. In this example, Drupal is installed in /var/www/drupal/ .&lt;/p&gt;
&lt;h2&gt;1. Change the webserver configuration.&lt;/h2&gt;
&lt;p&gt;This one is obvious, the website was first pointing to an individual installation of Drupal, it needs to be directed to the multi-site installation of Drupal.&lt;/p&gt;
&lt;h2&gt;2. Copy templates, settings.php and files into the multisite environment.&lt;/h2&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;mkdir -p /var/www/drupal/sites/example.com/&lt;br /&gt;cd /var/www/example.com&lt;br /&gt;cp -Rip html/sites/all/themes html/sites/default/settings.php html/sites/default/files/ /var/www/drupal/sites/example.com/&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;3. Update the MySQL database with the new paths.&lt;/h2&gt;
&lt;p&gt;If you have used files (including images) on your website, the path needs to be updated. Earlier files were located on "sites/default/files/", but this will become "sites/example.com/files"&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;mysql -u root -pPaSsWoRd&lt;br /&gt;USE examplecom;&lt;br /&gt;UPDATE files SET filepath=REPLACE (filepath, &amp;#039;default&amp;#039;, &amp;#039;example.com&amp;#039;);&lt;br /&gt;UPDATE files SET filepath=REPLACE (&amp;#039;filepath&amp;#039;, &amp;#039;images&amp;#039;, &amp;#039;sites/example.com/images&amp;#039;) WHERE filepath REGEXP &amp;#039;^images.*&amp;#039;;&lt;br /&gt;QUIT;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;4. Change the location of the icons for the selected theme.&lt;/h2&gt;
&lt;p&gt;Go to Administer - Site building - Themes - Your Theme "configure" and change the path to reflect the right one. Mostly this means changing the word "files/" to "sites/example.com/files/".&lt;/p&gt;
&lt;h2&gt;5. Restart the web server and clean up the old environment.&lt;/h2&gt;
&lt;p&gt;For Apache, that would be:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;apachectl configtest&lt;br /&gt;apachectl restart&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Check the website, everything should work, maybe you have to reselect your template to make it look better. If all works well, remove the old code.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;rm -R /var/www/example.com&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/moving-single-drupal-instalation-multisite-environment#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Mon, 18 Oct 2010 08:12:07 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">410 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/moving-single-drupal-instalation-multisite-environment</feedburner:origLink></item>
<item>
 <title>Shrinking a filesystem with LVM</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/yJKRSsLQjKw/shrinking-filesystem-lvm</link>
 <description>&lt;p&gt;After an installation you might find some file systems are too large, they are almost empty. When you want to use that space for another file system, here are the steps you can take:&lt;br /&gt;
Imagine /opt is now 10 Gb, but 1 Gb would be sufficient.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check if the file system is in use. Using &lt;code&gt;lsof /opt&lt;/code&gt; you will get a list of processes that currently use /opt. Stop these processes.&lt;/li&gt;
&lt;li&gt;Find out what device is used for /opt with &lt;code&gt;df -h /opt&lt;/code&gt; or &lt;code&gt;mount&lt;/code&gt;. In my example, I found /dev/mapper/VolGroup/opt hold files on /opt.&lt;/li&gt;
&lt;li&gt;Unmount the filesystem, using &lt;code&gt;umount /opt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Resize the filesystem using &lt;code&gt;resize2fs /dev/mapper/VolGroup/opt 1G&lt;/code&gt;. This frees the "right" part of the disk that LVM will un-allocate in a moment. All data from the file system is on the "left hand side".&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;lvreduce -L 1G /dev/mapper/VolGroup-opt&lt;/code&gt; to shrink the logical volume. (It might warn you that you need to run &lt;code&gt;e2fsck -f /dev/mapper/VolGroup-opt&lt;/code&gt; before you can continue.&lt;/li&gt;
&lt;li&gt;Remount the filesystem with a command as &lt;code&gt;mount /opt&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For /opt or any other filesystem that can easily be freed from open file handles, the above procedure works fine, but for "busy" filesystems, like /, /var, /usr, and so on, you'd have boot the machine without mounting filesystems. One way to do this is using the installation CD and starting up the "rescue" environment.&lt;/p&gt;
</description>
 <comments>http://meinit.nl/shrinking-filesystem-lvm#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Mon, 02 Aug 2010 13:31:25 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">409 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/shrinking-filesystem-lvm</feedburner:origLink></item>
<item>
 <title>Forwarding one port to another</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/kRDLDkRa_p8/forwarding-one-port-another</link>
 <description>&lt;p&gt;Here is a very simple stick to forward a TCP port from your local workstation to another host. Can be easy to use for debugging purposes:&lt;/p&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;mkfifo pipe ; cat pipe | nc -l 8080 | nc google.com 80 &amp;gt; pipe ; rm pipe&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;What this one does:&lt;br /&gt;
1) Create a fifo (First in First out) file. This is a very simple type of file, you can put stuff in there with an output redirect (&gt;) and get stuff out there with cat for example. It acts as a temporary buffer.&lt;br /&gt;
2) Open that newly created pipe. Anything that gets in, will be printed. (and forwarded in this example to "nc")&lt;br /&gt;
3) Open a listening port on your local workstation, listening on port 8080.&lt;br /&gt;
4) Open a connection to google.com, on port 80.&lt;br /&gt;
5) Send al the output to the earlier created pipe.&lt;br /&gt;
6) Remove the pipe when done.&lt;/p&gt;
&lt;p&gt;Have a look &lt;a href="http://netcat.sourceforge.net/"&gt;the netcat homepage&lt;/a&gt;, it's a great tool!&lt;/p&gt;
</description>
 <comments>http://meinit.nl/forwarding-one-port-another#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 13 Jul 2010 07:28:53 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">407 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/forwarding-one-port-another</feedburner:origLink></item>
<item>
 <title>Creating an RPM of some binary</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/yBBEIIgflhA/creating-rpm-some-binary</link>
 <description>&lt;p&gt;We've covered this topic before in &lt;a href="/making-rpm-shell-script"&gt;this story about creating an RPM from a shell script&lt;/a&gt;, but this information might help you better understand how to create an RPM.&lt;/p&gt;
&lt;p&gt;So; you've found a piece of software that has no RPM? (Or; your manager tells you to install a piece of software that the development department created.)&lt;/p&gt;
&lt;p&gt;Normally you'd use &lt;code&gt;./configure ; make ; make install&lt;/code&gt;, here is how to put that all in an RPM.&lt;/p&gt;
&lt;p&gt;Prepare your rpm building environment: (DO THIS AS A USER!)&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ sudo yum install rpm-build&lt;br /&gt;$ mkdir -p RPMBUILD/{BUILD,RPMS,SOURCES,SPECS,SRPMS}&lt;br /&gt;$ echo &amp;quot;%_topdir /home/username/RPMBUILD&amp;quot; &amp;gt;&amp;gt; .rpmmacros&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now copy the software into that newly create structure.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ cp software.tar.gz RPMBUILD/SOURCES/&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And now create a "spec file" for the software. This basically explains rpmbuild how to make the software and what to put in the RPM. This is the most "tweakable" step and might require quite some time to get right. Put this into /home/username/RPMBUILD/SPECS/software.spec:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;Name: software&lt;br /&gt;Version: 0.23&lt;br /&gt;Release: 1&lt;br /&gt;Summary: Custom software to run enterprise servers.&lt;br /&gt;&lt;br /&gt;Group: Applications/Internet&lt;br /&gt;License: GPLv2&lt;br /&gt;URL: http://meinit.nl/&lt;br /&gt;Source0: %{name}-%{version}.tar.gz&lt;br /&gt;BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root&lt;br /&gt;&lt;br /&gt;%description&lt;br /&gt;This software runs all enterprise software as a daemon. It&amp;#039;s been developed by Me in IT consultancy.&lt;br /&gt;&lt;br /&gt;%prep&lt;br /&gt;%setup -q&lt;br /&gt;&lt;br /&gt;%build&lt;br /&gt;make&lt;br /&gt;&lt;br /&gt;%install&lt;br /&gt;mkdir -p $RPM_BUILD_ROOT/usr/local/bin&lt;br /&gt;install software $RPM_BUILD_ROOT/usr/local/bin/software&lt;br /&gt;&lt;br /&gt;%files&lt;br /&gt;%defattr(-,root,root)&lt;br /&gt;%doc README&lt;br /&gt;/usr/local/bin/software&lt;br /&gt;&lt;br /&gt;%clean&lt;br /&gt;rm -rf $RPM_BUILD_ROOT&lt;br /&gt;&lt;br /&gt;%changelog&lt;br /&gt;* Tue Jun 15 2010 Robert de Bock &amp;lt;robert@meinit.nl&amp;gt; - 0.23-1&lt;br /&gt;- Initial build&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Good to know; the %install  refers to the temporary environment that rpm will create when building this RPM. The %files section refers to what will end up in the RPM. They should correspond; you can't %install a whole bunch of files and only include a few in the $files part. (rpmbuild will display the missing files.&lt;/p&gt;
&lt;p&gt;The group can be any line out of /usr/share/doc/rpm-*/GROUPS&lt;/p&gt;
&lt;p&gt;So; you are prepared, run this command to so if you got everything correct:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ rpmbuild -ba software.spec&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;When it finally builds, you'll find the rpm in /home/username/RPMBUILD/RPMS/$arch/software-0.23-1.$arch.rpm &lt;/p&gt;
</description>
 <comments>http://meinit.nl/creating-rpm-some-binary#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 15 Jun 2010 16:53:50 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">406 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/creating-rpm-some-binary</feedburner:origLink></item>
<item>
 <title>Setting up iSCSI (target/server and initiator/client) on RHEL</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/nkwEE5cX0SI/setting-iscsi-targetserver-and-initiatorclient-rhel</link>
 <description>&lt;p&gt;It's quite easy to setup an iSCSI environment on Red Hat Enterprise Linux. Try this easy setup to get a better understanding of iSCSI.&lt;/p&gt;
&lt;p&gt;Ingredients:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Two (virtual) machines, a server 172.16.0.1 and a client 172.16.0.2.&lt;/li&gt;
&lt;li&gt;Access to the "RHEL Cluster-Storage" channel on Red Hat Network.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;N.B. SELinux must be disabled when using this recipe, iptables tcp port 3260 must be opened on the server.&lt;/p&gt;
&lt;p&gt;On the server execute these commands to setup a 100 Mb iSCSI target. This target can later be mounted on the client(s).&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# yum install scsi-target-utils&lt;br /&gt;# cat /etc/tgt/targets.conf&lt;br /&gt;&amp;lt;target iqn.2010-04.nl.meinit:node1.target1&amp;gt;&lt;br /&gt;	backing-store /iscsi1.img&lt;br /&gt;	initiator-address 172.16.0.2&lt;br /&gt;&amp;lt;/target&amp;gt;&lt;br /&gt;# dd if=/dev/zero of=/iscsi1.img bs=1024 count=102400&lt;br /&gt;# chkconfig tgtd on&lt;br /&gt;# service tgtd start&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now on (all) client(s) follow these steps. (Please pay attention that only one client was give access in the configuration example above; 172.16.0.2.)&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# yum install iscsi-initiator-utils&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Start iscsi daemon.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# service iscsi start&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;To see what IQNs are available, run:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# iscsiadm -m discovery -t sendtargets -p 172.16.0.1&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
The result is a list of IQN(s) available. This discovery is a mandatory step of connecting to the iSCSI target.&lt;/p&gt;
&lt;p&gt;Login to the iSCSI target:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# iscsiadm -m node -T iqn.2010-04.nl.meinit:node1.target1 -p 172.16.0.1 -l&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;If that all works, you have new SCSI devices available, check dmesg and start iscsi at boot time:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# chkconfig iscsi on&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In this example the iSCSI target does not have a filesystem. Create it on the client and mount it at boot time:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# fdisk /dev/sda&lt;br /&gt;# mkfs.ext3 /dev/sda1&lt;br /&gt;# echo &amp;quot;/dev/sda1 /mnt ext3 defaults,_netdev 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;You are done, but these commands are quite useful when connecting to an unknown iSCSI device.&lt;/p&gt;
&lt;p&gt;To see more about the IQN:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# iscsiadm -m node -T iqn.2010-04.nl.meinit:node1.target1 -p 172.16.0.1&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/setting-iscsi-targetserver-and-initiatorclient-rhel#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Mon, 19 Apr 2010 18:53:27 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">405 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/setting-iscsi-targetserver-and-initiatorclient-rhel</feedburner:origLink></item>
<item>
 <title>Using "recording" in VI instead of being annoyed</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/7-Iy-RXiPak/using-recording-vi-instead-being-annoyed</link>
 <description>&lt;p&gt;Here is a trick you can use in VI if you need to repeat an action multiple times. Imagine you have this file:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;hello&lt;br /&gt;Workd&lt;br /&gt;hello&lt;br /&gt;Workd&lt;br /&gt;hello&lt;br /&gt;Workd&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;You want to change it to read "Hello world!" Here is what you can do in VI:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to the first occurrence of what you would like to have changed.&lt;/li&gt;
&lt;li&gt;Enter "q" to initiate a recording.&lt;/li&gt;
&lt;li&gt;Enter a letter or digit to save the recording under, like "a" or "1".&lt;/li&gt;
&lt;li&gt;Do the actions you would like to repeat.&lt;/li&gt;
&lt;li&gt;Enter "q" again to stop and save the recording.&lt;/li&gt;
&lt;li&gt;Go to the line where you would like to start running the saved recording/macro.&lt;/li&gt;
&lt;li&gt;Enter "@" followed by the letter of digit you have saved the recording under, like "a" or "1".&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So, now you have learned what this (annoying) "recording" option can be used for!&lt;/p&gt;
</description>
 <comments>http://meinit.nl/using-recording-vi-instead-being-annoyed#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-fred-clausen">Fred Clausen</category>
 <pubDate>Tue, 02 Feb 2010 09:25:43 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">404 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/using-recording-vi-instead-being-annoyed</feedburner:origLink></item>
<item>
 <title>Debugging an SSL connection</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/XdGvlo92KeU/debugging-ssl-connection</link>
 <description>&lt;p&gt;Imagine you would like to debug an SSL connection to a box, for example HTTPS. Using telnet or netcat, you are not able to do so, but openssl makes this possible, here is how:&lt;/p&gt;
&lt;p&gt;First; connect to a machine:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ openssl s_client -connect mail.google.com:443&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;You will be given the certificate details:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;CONNECTED(00000003)&lt;br /&gt;depth=2 /C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority&lt;br /&gt;verify return:1&lt;br /&gt;depth=1 /C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA&lt;br /&gt;verify return:1&lt;br /&gt;depth=0 /C=US/ST=California/L=Mountain View/O=Google Inc/CN=mail.google.com&lt;br /&gt;verify return:1&lt;br /&gt;---&lt;br /&gt;Certificate chain&lt;br /&gt; 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=mail.google.com&lt;br /&gt;&amp;nbsp; i:/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA&lt;br /&gt; 1 s:/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA&lt;br /&gt;&amp;nbsp; i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority&lt;br /&gt;---&lt;br /&gt;Server certificate&lt;br /&gt;-----BEGIN CERTIFICATE-----&lt;br /&gt;MIIDIjCCAougAwIBAgIQHxn23jXdY6FCkYrVLMCrEjANBgkqhkiG9w0BAQUFADBM&lt;br /&gt;MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg&lt;br /&gt;THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0wOTEyMTgwMDAwMDBaFw0x&lt;br /&gt;MTEyMTgyMzU5NTlaMGkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh&lt;br /&gt;MRYwFAYDVQQHFA1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKFApHb29nbGUgSW5jMRgw&lt;br /&gt;FgYDVQQDFA9tYWlsLmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ&lt;br /&gt;AoGBANknyBHye+RFyUa2Y3WDsXd+F0GJgDjxRSegPNnoqABL2QfQut7t9CymrNwn&lt;br /&gt;E+wMwaaZF0LmjSfSgRSwS4L6ssXQuyBZYiijlrVh9nbBbUbS/brGDz3RyXeaWDP2&lt;br /&gt;BnYyrVFfKV9u+BKLrebFCDmzQ0OpW5Ed1+PPUd91WY6NgKtTAgMBAAGjgecwgeQw&lt;br /&gt;DAYDVR0TAQH/BAIwADA2BgNVHR8ELzAtMCugKaAnhiVodHRwOi8vY3JsLnRoYXd0&lt;br /&gt;ZS5jb20vVGhhd3RlU0dDQ0EuY3JsMCgGA1UdJQQhMB8GCCsGAQUFBwMBBggrBgEF&lt;br /&gt;BQcDAgYJYIZIAYb4QgQBMHIGCCsGAQUFBwEBBGYwZDAiBggrBgEFBQcwAYYWaHR0&lt;br /&gt;cDovL29jc3AudGhhd3RlLmNvbTA+BggrBgEFBQcwAoYyaHR0cDovL3d3dy50aGF3&lt;br /&gt;dGUuY29tL3JlcG9zaXRvcnkvVGhhd3RlX1NHQ19DQS5jcnQwDQYJKoZIhvcNAQEF&lt;br /&gt;BQADgYEAicju7fexy+yRP2drx57Tcqo+BElR1CiHNZ1nhPmS9QSZaudDA8jy25IP&lt;br /&gt;VWvjEgaq13Hro0Hg32ZNVK53qcXwjWtnCAReojvNwj6/x1Ciq5B6D7E6eiYDSfXJ&lt;br /&gt;8/a2vR5IbgY89nq+wuHaA6vspH6vNR848xO3z1PQ7BrIjnYQ1A0=&lt;br /&gt;-----END CERTIFICATE-----&lt;br /&gt;subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=mail.google.com&lt;br /&gt;issuer=/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA&lt;br /&gt;---&lt;br /&gt;No client certificate CA names sent&lt;br /&gt;---&lt;br /&gt;SSL handshake has read 1778 bytes and written 343 bytes&lt;br /&gt;---&lt;br /&gt;New, TLSv1/SSLv3, Cipher is AES256-SHA&lt;br /&gt;Server public key is 1024 bit&lt;br /&gt;Compression: NONE&lt;br /&gt;Expansion: NONE&lt;br /&gt;SSL-Session:&lt;br /&gt;&amp;nbsp;&amp;nbsp; Protocol&amp;nbsp; : TLSv1&lt;br /&gt;&amp;nbsp;&amp;nbsp; Cipher&amp;nbsp;&amp;nbsp;&amp;nbsp; : AES256-SHA&lt;br /&gt;&amp;nbsp;&amp;nbsp; Session-ID: 53530BBF94619E255B7956A18D9B9F26241B2A1BF16F30C18C73C88A60200E5F&lt;br /&gt;&amp;nbsp;&amp;nbsp; Session-ID-ctx:&lt;br /&gt;&amp;nbsp;&amp;nbsp; Master-Key:&lt;br /&gt;B40F4E1D533F88AF9248E6576CA4E4CFC2C4BD092816DB7EF9D4FE650EA62B4CAC1F23C36892866B40E3502E67D52CF1&lt;br /&gt;&amp;nbsp;&amp;nbsp; Key-Arg&amp;nbsp;&amp;nbsp; : None&lt;br /&gt;&amp;nbsp;&amp;nbsp; Krb5 Principal: None&lt;br /&gt;&amp;nbsp;&amp;nbsp; Start Time: 1264674178&lt;br /&gt;&amp;nbsp;&amp;nbsp; Timeout&amp;nbsp;&amp;nbsp; : 300 (sec)&lt;br /&gt;&amp;nbsp;&amp;nbsp; Verify return code: 0 (ok)&lt;br /&gt;---&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now you can enter commands in plain text, just as you would using telnet or netcat:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;HEAD / HTTP/1.0&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Here is what you get:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;HTTP/1.0 302 Found&lt;br /&gt;Cache-Control: private&lt;br /&gt;Location: http://www.google.com&lt;br /&gt;Content-Type: text/html; charset=UTF-8&lt;br /&gt;Content-Length: 218&lt;br /&gt;Date: Thu, 28 Jan 2010 10:23:05 GMT&lt;br /&gt;Server: GFE/2.0&lt;br /&gt;X-XSS-Protection: 0&lt;br /&gt;&lt;br /&gt;read:errno=0&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;An easy trick that can also be used to connect to SSL-ed STMP connections, IMAPS, POP3S, etc.&lt;/p&gt;
</description>
 <comments>http://meinit.nl/debugging-ssl-connection#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-fred-clausen">Fred Clausen</category>
 <pubDate>Thu, 28 Jan 2010 10:42:43 +0000</pubDate>
 <dc:creator>Fred Clausen</dc:creator>
 <guid isPermaLink="false">403 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/debugging-ssl-connection</feedburner:origLink></item>
<item>
 <title>Making an RPM for a shell script.</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/XsEZs88KAa4/making-rpm-shell-script</link>
 <description>&lt;p&gt;So, you have written an enterprise quality shell script and would like to deploy it on serveral Red Hat based machines? Creating an RPM will make this easy to do. Here are the steps required.&lt;/p&gt;
&lt;p&gt;1. Install rpmbuild so you may start to build your own RPMs.&lt;br /&gt;
2. Package your shell script into a tar.gz file and move that to /usr/src/redhat/SOURCES/&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# tar -cvzf shell-script-0.1.tar.gz shell-script-0.1&lt;br /&gt;# mv shell-script-0.1.tar.gz /usr/src/redhat/SOURCES/&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
3. Create a .spec file that describes where everything is.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# cat /usr/src/redhat/SPECS/shell-script.spec&lt;br /&gt;Summary: The do it all script. (Enterprise quality)&lt;br /&gt;Name: shell-script&lt;br /&gt;Version: 0.1&lt;br /&gt;Release: 1&lt;br /&gt;URL:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://meinit.nl&lt;br /&gt;License: GPL&lt;br /&gt;Group: Applications/Internet&lt;br /&gt;BuildRoot: %{_tmppath}/%{name}-root&lt;br /&gt;Requires: bash&lt;br /&gt;Source0: shell-script-%{version}.tar.gz&lt;br /&gt;BuildArch: noarch&lt;br /&gt;&lt;br /&gt;%description&lt;br /&gt;A shell script.&lt;br /&gt;&lt;br /&gt;%prep&lt;br /&gt;%setup&lt;br /&gt;&lt;br /&gt;%build&lt;br /&gt;&lt;br /&gt;%install&lt;br /&gt;rm -rf ${RPM_BUILD_ROOT}&lt;br /&gt;mkdir -p ${RPM_BUILD_ROOT}/usr/bin&lt;br /&gt;install -m 755 shell-script.sh ${RPM_BUILD_ROOT}%{_bindir}&lt;br /&gt;&lt;br /&gt;%clean&lt;br /&gt;rm -rf ${RPM_BUILD_ROOT}&lt;br /&gt;&lt;br /&gt;%files&lt;br /&gt;%defattr(-,root,root)&lt;br /&gt;%attr(755,root,root) %{_bindir}/shell-script.sh&lt;br /&gt;&lt;br /&gt;%changelog&lt;br /&gt;* Tue Jan 12 2010 Robert de Bock &amp;lt;robert@meinit.nl&amp;gt;&lt;br /&gt;- Uberscript!&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
3. Build it!&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# rpmbuild --bb /usr/src/redhat/SPECS/shell-script.spec&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
4. Install it!&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# rpm -Uvh /usr/src/redhat/RPMS/noarch/shell-script-0.1.1.noarch.rpm&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/making-rpm-shell-script#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 12 Jan 2010 10:21:28 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">402 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/making-rpm-shell-script</feedburner:origLink></item>
<item>
 <title>Ranges in shell scripts</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/82dCLf9wSHM/ranges-shell-scripts</link>
 <description>&lt;p&gt;I have been admiring the people who know how to use ranges in shell scripts. These people are faster and more fluent on the Linux command line than anybody without knowledge of ranges could be.&lt;/p&gt;
&lt;p&gt;Here are some ranges or patters that you could use.&lt;/p&gt;
&lt;p&gt;A sequence of characters, in this case 1 to 10, printed on one line.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ echo &amp;quot;file{1..9}&amp;quot;&lt;br /&gt;file1 file2 file3 file4 file5 file6 file7 file8 file9&lt;br /&gt;$ echo file{s..z}&lt;br /&gt;files filet fileu filev filew filex filey filez&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The order of the range can be found in the man-page for "ascii".&lt;/p&gt;
&lt;p&gt;A pattern that describes either a range, or a separated pattern.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ echo file{1,2,4}&lt;br /&gt;file1 file2 file4&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Additional information can be found in the man page of bash, under "Brace Expansion".&lt;/p&gt;
</description>
 <comments>http://meinit.nl/ranges-shell-scripts#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 15 Dec 2009 07:23:33 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">401 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/ranges-shell-scripts</feedburner:origLink></item>
<item>
 <title>Restore hidden files with Apple Mac OS X Time Machine</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/pMQbEx7FHbc/restore-hidden-files-apple-mac-os-x-time-machine</link>
 <description>&lt;p&gt;Apple's &lt;a href="http://www.apple.com/macosx/what-is-macosx/time-machine.html"&gt;Time Machine&lt;/a&gt; works great, but restoring hidden files (files that start with a dot, like .ssh, .bashrc or .Trash) is difficult, but possible!&lt;/p&gt;
&lt;p&gt;Time machine uses the settings as used by the Finder. So first step is to change Finders behaviour, to show hidden files. Execute this command (as a regular user) from within the Terminal.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ defaults write com.apple.finder AppleShowAllFiles TRUE&lt;br /&gt;$ killall Finder&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now you should be able to see extra files in the finder, like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="/image/view/398/_original"&gt;&lt;img src="/image/view/398" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now start Time Machine and scroll back to the date you were sure a file existed.&lt;/p&gt;
&lt;p&gt;&lt;a href="/image/view/399/_original"&gt;&lt;img src="/image/view/399" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Restore it and to hide all these (annoying) hidden files, revert to original Finder settings:&lt;/p&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;$ defaults write com.apple.finder AppleShowAllFiles FALSE&lt;br /&gt;$ killall Finder&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/restore-hidden-files-apple-mac-os-x-time-machine#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Thu, 03 Dec 2009 09:40:34 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">400 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/restore-hidden-files-apple-mac-os-x-time-machine</feedburner:origLink></item>
<item>
 <title>Nagios time check using SNMP</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/rqI3z1s_bbk/nagios-time-check-using-snmp</link>
 <description>&lt;p&gt;When you would like to retrieve the remotely configured time using SNMP and compare it to see how accurate the time is, here is a script to help you out.&lt;/p&gt;
&lt;p&gt;This setup does not specifically require NTP to be running on the hosts that are checked, it just requires that the time is correct. Virtual machines for example are advised to have the appropriate "tools" installed to synchronize time. NTP is not desirable for virtual machines.&lt;/p&gt;
&lt;p&gt;(Parts of the script are borrowed from http://spielwiese.la-evento.com/xelasblog/archives/27-SNMP-hrSystemDate.0-Datumsformat-anpassen.html)&lt;/p&gt;
&lt;p&gt;This is the graph that is created:&lt;br /&gt;
&lt;a href="/image/view/396/_original"&gt;&lt;img src="/image/view/396" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The script:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;# Nagios plugin to report time difference as received via SNMP compared to the local time.&lt;br /&gt;# Make sure the machine this script runs on (poller/nagios host) is using NTP.&lt;br /&gt;&lt;br /&gt;usage() {&lt;br /&gt; # This function is called when a user enters impossible values.&lt;br /&gt; echo &amp;quot;Usage: $0 -H HOSTADDRESS [-C COMMUNITY] [-w WARNING] [-c CRITICAL] [-v VERSION]&amp;quot;&lt;br /&gt; echo&lt;br /&gt; echo &amp;quot; -H HOSTADDRESS&amp;quot;&lt;br /&gt; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The host to check, either IP address or a resolvable hostname.&amp;quot;&lt;br /&gt; echo &amp;quot; -C COMMUNITY&amp;quot;&lt;br /&gt; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The SNMP community to use, defaults to public.&amp;quot;&lt;br /&gt; echo &amp;quot; -v VERSION&amp;quot;&lt;br /&gt; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The SNMTP version to use, defaults to 2c.&amp;quot;&lt;br /&gt; echo &amp;quot; -w WARNING&amp;quot;&lt;br /&gt; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The amount of seconds from where warnings start. Defaults to 60.&amp;quot;&lt;br /&gt; echo &amp;quot; -c CRITICAL&amp;quot;&lt;br /&gt; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The amount of seconds from where criticals start. Defaults to 120.&amp;quot;&lt;br /&gt; exit 3&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;readargs() {&lt;br /&gt; # This function reads what options and arguments were given on the&lt;br /&gt; # command line.&lt;br /&gt; while [ &amp;quot;$#&amp;quot; -gt 0 ] ; do&lt;br /&gt;&amp;nbsp; case &amp;quot;$1&amp;quot; in&lt;br /&gt;&amp;nbsp;&amp;nbsp; -H)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$2&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host=&amp;quot;$2&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift ; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Missing a value for $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; -C)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$2&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; community=&amp;quot;$2&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift ; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Missing a value for $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; -w)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$2&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; warning=&amp;quot;$2&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift ; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Missing a value for $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; -c)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$2&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; critical=&amp;quot;$2&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift ; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Missing a value for $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; -v)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$2&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; version=&amp;quot;$2&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift ; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Missing a value for $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; *)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Unknown option $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; esac&lt;br /&gt;done&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;checkvariables() {&lt;br /&gt; # This function checks if all collected input is correct.&lt;br /&gt; if [ ! &amp;quot;$host&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; echo &amp;quot;Please specify a hostname or IP address.&amp;quot;&lt;br /&gt;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp; usage&lt;br /&gt; fi&lt;br /&gt; if [ ! &amp;quot;$community&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; # The public community is used when a user did not enter a community.&lt;br /&gt;&amp;nbsp; community=&amp;quot;public&amp;quot;&lt;br /&gt; fi&lt;br /&gt; if [ ! &amp;quot;$version&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; # Version 2c is used when a user did not enter a version.&lt;br /&gt;&amp;nbsp; version=&amp;quot;2c&amp;quot;&lt;br /&gt; fi&lt;br /&gt; if [ ! &amp;quot;$critical&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; critical=&amp;quot;120&amp;quot;&lt;br /&gt; fi&lt;br /&gt; if [ ! &amp;quot;$warning&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; warning=&amp;quot;60&amp;quot;&lt;br /&gt; fi&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;getandprintresults() {&lt;br /&gt; # This converts the date retreived from snmp to a unix time stamp.&lt;br /&gt; rdatestring=$( snmpget -v $version -c $community $host HOST-RESOURCES-MIB::hrSystemDate.0 | gawk &amp;#039;{print $NF}&amp;#039; )&lt;br /&gt;&lt;br /&gt; if [ ! &amp;quot;$rdatestring&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; echo &amp;quot;Time difference could not be calculated; no time received.&amp;quot;&lt;br /&gt;&amp;nbsp; exit 3&lt;br /&gt; fi&lt;br /&gt;&lt;br /&gt; rdate=$( echo $rdatestring | gawk -F&amp;#039;,&amp;#039; &amp;#039;{print $1}&amp;#039; )&lt;br /&gt; rtime=$( echo $rdatestring | gawk -F&amp;#039;,&amp;#039; &amp;#039;{print $2}&amp;#039; | gawk -F&amp;#039;.&amp;#039; &amp;#039;{print $1}&amp;#039; )&lt;br /&gt; cldate=$( echo $rdate | gawk -F&amp;#039;-&amp;#039; &amp;#039;{printf(&amp;quot;%4i&amp;quot;,$1)}; {printf(&amp;quot;%02i&amp;quot;,$2)}; {printf(&amp;quot;%02i&amp;quot;,$3)};&amp;#039; )&lt;br /&gt; cltime=$( echo $rtime | gawk -F&amp;#039;:&amp;#039; &amp;#039;{printf(&amp;quot;%02i&amp;quot;,$1)}; {printf(&amp;quot;%02i&amp;quot;,$2)}; {printf(&amp;quot; %02i&amp;quot;,$3)};&amp;#039; )&lt;br /&gt; rdate_s=$( date -d &amp;quot;$cldate $cltime sec&amp;quot; +%s )&lt;br /&gt; ldate_s=$(date +&amp;#039;%s&amp;#039;)&lt;br /&gt; &lt;br /&gt; # If the calculated difference is negative, make it positive again for comparison.&lt;br /&gt; difference=$(($rdate_s - $ldate_s))&lt;br /&gt; if [ &amp;quot;$difference&amp;quot; -lt 0 ] ; then&lt;br /&gt;&amp;nbsp; positivedifference=$(($difference*-1))&lt;br /&gt; else&lt;br /&gt;&amp;nbsp; positivedifference=$difference&lt;br /&gt; fi&lt;br /&gt; &lt;br /&gt; if [ &amp;quot;$positivedifference&amp;quot; -gt &amp;quot;$critical&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; echo &amp;quot;Time difference is more than $critical seconds: $difference|diff=$difference&amp;quot;&lt;br /&gt;&amp;nbsp; exit 2&lt;br /&gt; fi&lt;br /&gt; &lt;br /&gt; if [ &amp;quot;$positivedifference&amp;quot; -gt &amp;quot;$warning&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; echo &amp;quot;Time difference is more than $warning seconds: $difference|diff=$difference&amp;quot;&lt;br /&gt;&amp;nbsp; exit 1&lt;br /&gt; fi&lt;br /&gt; &lt;br /&gt; echo &amp;quot;Time difference is less than $warning seconds: $difference|diff=$difference&amp;quot;&lt;br /&gt; exit 0&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;# The calls to the different functions.&lt;br /&gt;readargs &amp;quot;$@&amp;quot;&lt;br /&gt;checkvariables&lt;br /&gt;getandprintresults&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;To implement it in Nagios, add these sniplets to nagios.cfg. (or any other applicable nagios file.)&lt;/p&gt;
&lt;p&gt;The service for a group.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;define service{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hostgroup_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Servertype_Linux&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; service_description&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; time&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _SERVICE_ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1856&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; use&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SNMP-time&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The service template.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;define service{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SNMP-time&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; service_description&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; time&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; use&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; generic-service&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; check_command&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; check_snmp_time!$_HOSTSNMPCOMMUNITY$!120!60&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max_check_attempts&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; normal_check_interval&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retry_check_interval&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; notification_interval&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; register&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The command.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;define command{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; command_name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; check_snmp_time&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; command_line&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $USER1$/check_snmp_time -H $HOSTADDRESS$ -C $ARG1$ -c $ARG2$ -w $ARG3$&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/nagios-time-check-using-snmp#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Wed, 25 Nov 2009 08:26:21 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">395 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/nagios-time-check-using-snmp</feedburner:origLink></item>
<item>
 <title>Optimize only fragmented tables in MySQL</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/_MHygiVpRxs/optimize-only-fragmented-tables-mysql</link>
 <description>&lt;p&gt;When you are using MySQL, you will (likely) have tables that can be fragmented. In MySQL terms this is called "OPTIMIZE".&lt;/p&gt;
&lt;p&gt;You could simply OPTIMIZE every table in every database, but during an OPTIMIZE, the tables are locked, so writing is not possible.&lt;/p&gt;
&lt;p&gt;To minimize the time that MySQL will be locked (and results cannot be written), here is a script that checks fragmentation of every table of every database. Only if a table is fragmented, the table is OPTIMIZED.&lt;/p&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;echo -n &amp;quot;MySQL username: &amp;quot; ; read username&lt;br /&gt;echo -n &amp;quot;MySQL password: &amp;quot; ; stty -echo ; read password ; stty echo ; echo&lt;br /&gt;&lt;br /&gt;mysql -u $username -p&amp;quot;$password&amp;quot; -NBe &amp;quot;SHOW DATABASES;&amp;quot; | grep -v &amp;#039;lost+found&amp;#039; | while read database ; do&lt;br /&gt; mysql -u $username -p&amp;quot;$password&amp;quot; -NBe &amp;quot;SHOW TABLE STATUS;&amp;quot; $database | while read name engine version rowformat rows avgrowlength datalength maxdatalength indexlength datafree autoincrement createtime updatetime checktime collation checksum createoptions comment ; do&lt;br /&gt;&amp;nbsp; if [ &amp;quot;$datafree&amp;quot; -gt 0 ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp; fragmentation=$(($datafree * 100 / $datalength))&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;$database.$name is $fragmentation% fragmented.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp; mysql -u &amp;quot;$username&amp;quot; -p&amp;quot;$password&amp;quot; -NBe &amp;quot;OPTIMIZE TABLE $name;&amp;quot; &amp;quot;$database&amp;quot;&lt;br /&gt;&amp;nbsp; fi&lt;br /&gt; done&lt;br /&gt;done&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Result will look something like this:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;MySQL username: root&lt;br /&gt;MySQL password:&lt;br /&gt;...&lt;br /&gt;database.cache_filter is 19% fragmented.&lt;br /&gt;meinit.cache_filter	optimize	status	OK&lt;br /&gt;database.cache_page is 35% fragmented.&lt;br /&gt;meinit.cache_page	optimize	status	OK&lt;br /&gt;...&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;You may comment out that line with OPTIMIZE TABLE in it, if you are just interested in seeing the fragmentation.&lt;/p&gt;
</description>
 <comments>http://meinit.nl/optimize-only-fragmented-tables-mysql#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 17 Nov 2009 15:38:36 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">394 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/optimize-only-fragmented-tables-mysql</feedburner:origLink></item>
<item>
 <title>Failover on OpenBSD is so easy to setup using carp!</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/Rb6YT1RWzS0/failover-openbsd-so-easy-setup-using-carp</link>
 <description>&lt;p&gt;I am not the first (and last) to write about carp, the failover/vip/floating-IP solution OpenBSD is using. &lt;a href="http://www.countersiege.com/doc/pfsync-carp/"&gt;Many&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Common_Address_Redundancy_Protocol"&gt;articles&lt;/a&gt; &lt;a href="http://www.kernel-panic.it/openbsd/carp/"&gt;describe&lt;/a&gt; this topic including a &lt;a href="http://www.openbsd.org/faq/pf/carp.html"&gt;very complete answer  to a frequently asked question about carp&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are not familiar with IP failover situations; in case of carp/pulse/HSRP/VIP, an IP "floats" between different machines. One machine actually answers request to received packets, so this is an solution that knows of a MASTER of ACTIVE node .&lt;/p&gt;
&lt;p&gt;A CARP interface (which is not physical) is bound to a physical interface. The physical interface advertises statuses so other CARP interfaces know about each other.&lt;/p&gt;
&lt;p&gt;You can bind almost any service to a CARP interface, some examples are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DNS&lt;/li&gt;
&lt;li&gt;HTTP&lt;/li&gt;
&lt;li&gt;NTP&lt;/li&gt;
&lt;li&gt;Proxy/Squid&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Services that store data/stadia locally are not very suitable for a CARP solution. Examples are: DHCP (because leases are stored localy), MySQL/PostgreSQL (because data is stored on a physical local storage) and SSH (because you can never be sure what machine you are connecting to.&lt;/p&gt;
&lt;p&gt;Here is how to set it up. On both boxes add a file /etc/hostname.carp0 with this content:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;inet 192.168.1.123 255.255.0 192.168.1.255 vhid 1 pass SeCrEt carpdev em0&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Remember to activate the interface like this: (All your network cards will be (re-) configured!)&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# sh /etc/netstart&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In this case, 192.168.1.123 is the floating IP address and em0 is the physical device that carp0 is running on. Be aware that the other server's carpdev should be connected to the same LAN.&lt;/p&gt;
&lt;p&gt;Now that this is done, you may access services on the newly created CARP device's IP address. You may also specifically bind applications to only the CARP device.&lt;/p&gt;
&lt;p&gt;You may check the status using ifconfig: (Please not the "carp: MASTER" part, it tells you this machine is the master, all others are "BACKUP".)&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# ifconfig carp0&lt;br /&gt;carp0: flags=8843&amp;lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&amp;gt; mtu 1500&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lladdr 00:00:5e:00:01:02&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; priority: 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; carp: MASTER carpdev em0 vhid 1 advbase 1 advskew 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; groups: carp&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inet6 fe80::200:5eff:fe00:102%carp0 prefixlen 64 scopeid 0x5&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inet 192.168.1.123 netmask 0xffffff00 broadcast 192.168.1.255&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;One limitation I found; you can not run dhclient on a carp interface, you will need to assign an IP address to the carp device. Please be aware that this would be a very odd setup; DHCP in a failover interface...&lt;/p&gt;
</description>
 <comments>http://meinit.nl/failover-openbsd-so-easy-setup-using-carp#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Wed, 11 Nov 2009 13:16:42 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">393 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/failover-openbsd-so-easy-setup-using-carp</feedburner:origLink></item>
<item>
 <title>Your Soekris OpenBSD as a OpenVPN appliance</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/zg8ir4TFimE/your-soekris-openbsd-openvpn-appliance</link>
 <description>&lt;p&gt;I have an existing network at home, but would like to be able to connect to it using a VPN every now and then. This enables me to access the fileserver, printer and so on.&lt;/p&gt;
&lt;p&gt;My network contains an &lt;a href="http://www.apple.com/timecapsule/"&gt;Apple Time Capsule&lt;/a&gt; as a nat router, an ethernet modem provided by my cable company &lt;a href="http://www.ziggo.nl/"&gt;Ziggo&lt;/a&gt; and devices such as laptops, that use the network. &lt;/p&gt;
&lt;p&gt;A &lt;a href="http://www.soekris.com/"&gt;Soekris box&lt;/a&gt; I had lying around meets all requirements perfectly for a VPN-server. Here is how to set it up.&lt;/p&gt;
&lt;h2&gt;1. Forward UDP port 1194 from your router to your soekris box.&lt;/h2&gt;
&lt;p&gt;This one is easy enough, on &lt;a href="http://www.apple.com/macosx/"&gt;Apple Mac OS X&lt;/a&gt; and a &lt;a href="http://www.apple.com/timecapsule/"&gt;Time Capsule&lt;/a&gt; (or &lt;a href="http://www.apple.com/airportexpress/"&gt;Airport Express&lt;/a&gt;) open AirPort Utility on your Mac, select the Time Capsule, click Manual Setup.&lt;br /&gt;
Go to Internet - NAT&lt;br /&gt;
Select the box "Enable NAT Port Mapping Protocol" and click on "Configure Port Mappings..."&lt;br /&gt;
&lt;a href="/image/view/389/_original"&gt;&lt;img src="/image/view/389" /&gt;&lt;/a&gt;&lt;br /&gt;
Click on the "+" to add a portmapping. OpenVPN uses UDP port 1194, so map it from the "Public UDP Port(s)" to the "Private UDP Port(s)" on the "Private IP Address" of your soekris box. Fill in "OpenVPN" in the next "Description" field.&lt;br /&gt;
&lt;a href="/image/view/388/_original"&gt;&lt;img src="/image/view/388" /&gt;&lt;br /&gt;
Finish your router configuration by pressing "Update". N.B. The network connection will be gone for a minute or two.&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;2. Install &lt;a href="http://www.openvpn.net/"&gt;OpenVPN&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I assume &lt;a href="http://www.openbsd.org/"&gt;OpenBSD&lt;/a&gt; is already running on your Soekris box, otherwise check out &lt;a href="http://meinit.nl/install-your-soekris-or-any-other-machine-openbsd-using-openbsd"&gt;how to install your soekris box with OpenBSD&lt;/a&gt;.&lt;br /&gt;
Add the package "openvpn". A dependency "lzo" will be added automatically.&lt;/p&gt;
&lt;h2&gt;3. Configure &lt;a href="http://www.openvpn.net/"&gt;OpenVPN&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Create a directory /etc/openvpn/keys:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;soekris # mkdir -p /etc/openvpn/keys&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
And create the file /etc/openvpn.conf with this content:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;port 1194&lt;br /&gt;proto udp&lt;br /&gt;dev tun0&lt;br /&gt;ca /etc/openvpn/keys/ca.crt&lt;br /&gt;cert /etc/openvpn/keys/server.crt&lt;br /&gt;key /etc/openvpn/keys/server.key&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;dh /etc/openvpn/keys/dh1024.pem&lt;br /&gt;# This is the network that lives on the tun0 device.&lt;br /&gt;# My regular network uses 10.0.1.0/24, so using&lt;br /&gt;# 10.0.2.0/24 seems pretty logical.&lt;br /&gt;server 10.0.2.0 255.255.255.0&lt;br /&gt;ifconfig-pool-persist ipp.txt&lt;br /&gt;# When clients connect, tell them that 10.0.1.0/24 can&lt;br /&gt;# be reached through this tunnel. (You may also set this on the,&lt;br /&gt;# client instead of &amp;quot;broadcasting&amp;quot; this...&lt;br /&gt;push &amp;quot;route 10.0.1.0 255.255.255.0&amp;quot;&lt;br /&gt;client-to-client&lt;br /&gt;keepalive 10 120&lt;br /&gt;comp-lzo&lt;br /&gt;user _openvpn&lt;br /&gt;group _openvpn&lt;br /&gt;persist-key&lt;br /&gt;persist-tun&lt;br /&gt;status openvpn-status.log&lt;br /&gt;verb 3&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;4. Create OpenSSL certificates&lt;/h2&gt;
&lt;p&gt;This is quite an abstract step. It boils down to this: on the server you will create a certificate authority (ca) key and certificate, also you will create a key and certificate for each client connecting and sign them using your newly create certificate authority. The certificate from the certificate authority (ca.crt) and client (client1.crt) and the key for the client (client1.key) will be distributed to all clients. That's a mouth full, but here is how to do it in steps:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;soekris # cp -Rip /usr/local/share/example/openvpn/easy-rsa /etc/openvpn&lt;br /&gt;soekris # cd /etc/openvpn/easy-rsa/2.0&lt;br /&gt;soekris # cat vars&lt;br /&gt;export EASY_RSA=&amp;quot;`pwd`&amp;quot;&lt;br /&gt;export OPENSSL=&amp;quot;openssl&amp;quot;&lt;br /&gt;export PKCS11TOOL=&amp;quot;pkcs11-tool&amp;quot;&lt;br /&gt;export GREP=&amp;quot;grep&amp;quot;&lt;br /&gt;export KEY_CONFIG=&amp;quot;/etc/openvpn/easy-rsa/2.0/openssl.cnf&amp;quot;&lt;br /&gt;export KEY_DIR=&amp;quot;/etc/openvpn/keys&amp;quot;&lt;br /&gt;echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR&lt;br /&gt;export PKCS11_MODULE_PATH=&amp;quot;dummy&amp;quot;&lt;br /&gt;export PKCS11_PIN=&amp;quot;dummy&amp;quot;&lt;br /&gt;export KEY_SIZE=1024&lt;br /&gt;export CA_EXPIRE=3650&lt;br /&gt;export KEY_EXPIRE=3650&lt;br /&gt;export KEY_COUNTRY=&amp;quot;NL&amp;quot;&lt;br /&gt;export KEY_PROVINCE=&amp;quot;UT&amp;quot;&lt;br /&gt;export KEY_CITY=&amp;quot;Utrecht&amp;quot;&lt;br /&gt;export KEY_ORG=&amp;quot;Me in It Consultancy&amp;quot;&lt;br /&gt;export KEY_EMAIL=&amp;quot;robert@meinit.nl&amp;quot;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
N.b. Please change the KEY_ values to match your personal settings.&lt;/p&gt;
&lt;p&gt;Now execute these steps, as stolen from &lt;a href="http://www.openvpn.net/index.php/open-source/documentation/howto.html#pki"&gt;The OpenVPN homepage&lt;/a&gt;.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;soekris # . vars&lt;br /&gt;soekris # ./clean-all&lt;br /&gt;soekris # ./build-ca&lt;br /&gt;soekris # ./build-key-server server&lt;br /&gt;soekris # ./build-key client1&lt;br /&gt;soekris # ./build-key client2&lt;br /&gt;soekris # ./build-key client3&lt;br /&gt;soekris # ./build-dh&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Once again; send the newly created file /etc/openvpn/keys/ca.crt, /etc/openvpn/keys/client1.crt and /etc/openvpn/keys/client1.key to the machine using the vpn connection.&lt;/p&gt;
&lt;h2&gt;5. Configure the OpenBSD Packet Filter&lt;/h2&gt;
&lt;p&gt;This step enables client to reach your local network using network address translation. At the bare minimum, add this rule to your pf configuration in /etc/pf.conf&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;nat pass on sis0 from !(sis0) to any -&amp;gt; (sis0)&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
sis0 is a physical interface that connects the Soekris box to my local area network.&lt;/p&gt;
&lt;p&gt;Also, make sure the packet filter is enabled and is using your pf.cofn&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;soekris # pfctl -e&lt;br /&gt;soekris # pfclt -f /etc/pf.conf&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And finally make sure it works after a reboot:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;soekris # echo &amp;quot;ps=yes&amp;quot; &amp;gt;&amp;gt; /etc/rc.conf.local&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;6. Start &lt;a href="http://www.openvpn.net/"&gt;OpenVPN&lt;/a&gt; on the server&lt;/h2&gt;
&lt;p&gt;Wow, almost there, let's start the software:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;soekris # /usr/local/sbin/openvpn --config /etc/openvpn/server.conf --key /etc/openvpn/keys/server.key&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Some debugging information will scroll down your screen. &lt;/p&gt;
&lt;h2&gt;7. Make sure &lt;a href="http://www.openvpn.net/"&gt;OpenVPN&lt;/a&gt; starts at boot time&lt;/h2&gt;
&lt;p&gt;Add these lines to your /etc/rc.local.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# Add your local startup actions here.&lt;br /&gt;&lt;br /&gt;echo &amp;quot; openvpn&amp;quot;&lt;br /&gt;/usr/local/sbin/openvpn --config /etc/openvpn/server.conf --key /etc/openvpn/keys/server.key &amp;gt;&amp;gt; /var/log/openvpn.output &amp;amp;&lt;br /&gt;&lt;br /&gt;echo &amp;#039;.&amp;#039;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;8. Configure the client(s)&lt;/h2&gt;
&lt;p&gt;I use &lt;a href="http://www.apple.com/macosx/"&gt;Mac OS X&lt;/a&gt; to connect to &lt;a href="http://www.openvpn.net/"&gt;OpenVPN&lt;/a&gt;. You will have to install some extra software, your choices are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://code.google.com/p/tunnelblick/"&gt;Tunnelblick&lt;/a&gt; - (Free) Tunnelblick is a ready-to-use graphical OpenVPN client for Mac OS X &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.viscosityvpn.com/"&gt;Viscosity&lt;/a&gt; - is an OpenVPN client for Mac, providing a rich Cocoa graphical user interface for creating, editing, and controlling VPN connections. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For now I am using the trail version of &lt;a href="http://www.viscosityvpn.com/"&gt;Viscosity&lt;/a&gt; because it looks great. Check out the screenshots below.&lt;br /&gt;
&lt;a href="/image/view/390/_original"&gt;&lt;img src="/image/view/390/thumbnail" /&gt;&lt;br /&gt;
&lt;a href="/image/view/391/_original"&gt;&lt;img src="/image/view/391/thumbnail" /&gt;&lt;br /&gt;
&lt;a href="/image/view/392/_original"&gt;&lt;img src="/image/view/392/thumbnail" /&gt;&lt;/a&gt;&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/your-soekris-openbsd-openvpn-appliance#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Wed, 21 Oct 2009 12:50:28 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">387 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/your-soekris-openbsd-openvpn-appliance</feedburner:origLink></item>
<item>
 <title>Managing a Linux Virtual Server</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/sniV9F47FE0/managing-linux-virtual-server</link>
 <description>&lt;p&gt;When you have &lt;a href="http://meinit.nl/making-loadbalancer-centos-using-linux-virtual-server"&gt;setup an LVS&lt;/a&gt; you will need to administer it. Here are the tools you can use.&lt;/p&gt;
&lt;h2&gt;Discover what machine is the master.&lt;/h2&gt;
&lt;p&gt;Log in to both boxes and issue the command:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# ipvsadm&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
A list of active services and it's IP-addresses will be printed on the active master.&lt;/p&gt;
&lt;p&gt;Or, check /var/log/messages for a line like this:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;pulse[$pid]: STARTING PULSE AS BACKUP&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
This clearly shows you the machine is a backup.&lt;/p&gt;
&lt;h2&gt;Failover from one machine to another.&lt;/h2&gt;
&lt;p&gt;You could simple reboot the active machine. Otherwise, stop the service pulse for a moment on the active server. The backup will discover this and configure the floating IP.&lt;br /&gt;
On the active machine, issue:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# /etc/init.d/pulse stop&lt;br /&gt;# sleep 60&lt;br /&gt;# /etc/init.d/pulse start&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Add/delete a Virtual Service or Real Server.&lt;/h2&gt;
&lt;p&gt;Use the piranha web interface, located on port 3636 of either one of the load balancers. Remember to copy /etc/sysconfig/ha/lvs.cf to the backup machine as well.&lt;br /&gt;
After you have altered the configuration, restart pulse on the active machine. (Be aware; this makes services unavailable for a couple of seconds.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# ipvsadm&lt;br /&gt;[services are printed]&lt;br /&gt;# /etc/init.d/pulse restart&lt;br /&gt;# ipvsadm&lt;br /&gt;[services should be printed in a couple of seconds.]&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/managing-linux-virtual-server#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Mon, 31 Aug 2009 12:03:09 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">386 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/managing-linux-virtual-server</feedburner:origLink></item>
<item>
 <title>Making a loadbalancer with CentOS using Linux Virtual Server</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/9OGZlZ0IpfM/making-loadbalancer-centos-using-linux-virtual-server</link>
 <description>&lt;p&gt;When you are new to all terminology Red Hat is using, it can be challenging to understand what actions to take to create a simple load-balancer with Linux. Here is some information to get you started.&lt;/p&gt;
&lt;p&gt;Read more on &lt;a href="http://www.centos.org/docs/5/html/Virtual_Server_Administration"&gt;the CentOS Virtual Server Administration&lt;/a&gt; pages.&lt;/p&gt;
&lt;p&gt;Terminology:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;piranha&lt;/b&gt; This is a package that provides a configuration interface for setting up LVS.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;ipvs&lt;/b&gt; The name of the module that allows a load-balancing on Linux.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;ipvsadm&lt;/b&gt; A package (and a command) that makes administrating ipvs possible. Be aware, you either user piranha-gui or /etc/sysconfig/ipvsadm to configure ipvs.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;LVS&lt;/b&gt; Linux Virtual Server - the project name of all tools used in this document.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;pulse&lt;/b&gt; A service (/etc/init.d/pulse) that runs on both active and backup machine and opens a port to make checking possible. piranha-gui configures everything, pulse actually activates all configurations.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;nanny&lt;/b&gt; A process started by pulse to monitor the realservers.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;nat&lt;/b&gt; Network Address Translation. A common combination with LVS. In case NAT is uses, the loadbalancer/director/LVS accepts traffic on one the VIP and sends traffic to the realservers. Be aware, the current implementation of ipvsadm does not properly use Source NAT, it currently does not rewrite the source address.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;direct routing&lt;/b&gt; A method of routing available in LVS. Traffic is received on the VIP, sent through to the realservers. The realservers receive the traffic as if it was sent to the VIP, so the VIP must be configured on the realservers. To avoid arp-caches to register the wrong MAC-address-IP-address combination, a few "tricks" must be done.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;wlc&lt;/b&gt; Weighted Least Connections, an algorithm to balance load to realservers.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;VIP&lt;/b&gt; Virtual IP. The IP-address the service is configured on.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;RIP&lt;/b&gt; Real server IP. The IP-address of a real-server.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;realserver&lt;/b&gt; The server providing the actual service. This can be Linux, Windows, whatever.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is an overview of a possible setup:&lt;br /&gt;
&lt;img src="/image/view/383/_original" /&gt;&lt;/p&gt;
&lt;p&gt;Steps to finish before eternal succes:&lt;/p&gt;
&lt;h2&gt;Install piranha-gui&lt;/h2&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;# yum install piranha-gui&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
(modify 172.16.0.0/24 to whatever network you are using on the realserver network.)&lt;/p&gt;
&lt;h2&gt;Configure services&lt;/h2&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;# chkconfig httpd on&lt;br /&gt;# chkconfig piranha-gui on&lt;br /&gt;# chkconfig pulse on&lt;br /&gt;# sed -i &amp;#039;s/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/&amp;#039; /etc/sysctl.conf&lt;br /&gt;# echo &amp;quot;*nat&lt;br /&gt;:PREROUTING ACCEPT [46:3346]&lt;br /&gt;:POSTROUTING ACCEPT [431:32444]&lt;br /&gt;:OUTPUT ACCEPT [431:32534]&lt;br /&gt;-A POSTROUTING -o eth0 -j MASQUERADE&lt;br /&gt;COMMIT&lt;br /&gt;*filter&lt;br /&gt;:INPUT ACCEPT [4186:1094786]&lt;br /&gt;:FORWARD ACCEPT [729:111992]&lt;br /&gt;:OUTPUT ACCEPT [4266:388099]&lt;br /&gt;-A FORWARD -i eth1 -j ACCEPT&lt;br /&gt;COMMIT&amp;quot; &amp;gt; /etc/sysconfig/iptables&lt;br /&gt;# chkconfig iptables on&lt;br /&gt;# sed -i &amp;#039;s/SELINUX=enabled/SELINUX=disabled/&amp;#039; /etc/sysconfig/selinux&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Configure via webinterface&lt;/h2&gt;
&lt;p&gt;Execute these steps to be able to use the piranha-gui web interface:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# service httpd start&lt;br /&gt;# piranha-passwd&lt;br /&gt;# service piranha-gui start &lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
Open a browser and open your servers IP-address, port 3636. URL looks something like this: http://192.168.202.50:3636&lt;/p&gt;
&lt;h2&gt;Synchronize /etc/sysconfig/ha/lvs.cf&lt;/h2&gt;
&lt;p&gt;You will need to have the piranha configuration the same on both machines. Here are some hints. Do this on both machines, just switch the IP-address.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# ssh-keygen&lt;br /&gt;# scp .ssh/id_rsa* 192.168.202.110:./.ssh/&lt;br /&gt;# cp .ssh/id_rsa.pub .ssh/authorized_keys&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
Now you should be able to connect to both machines without using a password.&lt;/p&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;# cat update-lvs.cf &lt;br /&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;copiedserialno=$(grep serial_no /tmp/lvs.cf | awk &amp;#039;{ print $NF }&amp;#039;)&lt;br /&gt;runningserialno=$(grep serial_no /etc/sysconfig/ha/lvs.cf | awk &amp;#039;{ print $NF }&amp;#039;)&lt;br /&gt;&lt;br /&gt;if [ &amp;quot;$copiedserialno&amp;quot; -gt &amp;quot;$runningserialno&amp;quot; ] ; then&lt;br /&gt; mv /tmp/lvs.cf /etc/sysconfig/ha/lvs.cf&lt;br /&gt;fi&lt;br /&gt;# crontab -l&lt;br /&gt;* * * * * /usr/bin/scp /etc/sysconfig/ha/lvs.cf 192.168.1.46:/tmp &amp;gt; /dev/null&lt;br /&gt;* * * * * /root/update-lvs.cf&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Reboot the server.&lt;/h2&gt;
&lt;p&gt;To activate all changes, simply reboot the load-balancer.&lt;/p&gt;
</description>
 <comments>http://meinit.nl/making-loadbalancer-centos-using-linux-virtual-server#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Mon, 24 Aug 2009 10:06:54 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">382 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/making-loadbalancer-centos-using-linux-virtual-server</feedburner:origLink></item>
<item>
 <title>Really minimal HOWTO for loadbalancing on CentOS 5.3 using ipvsadm</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/iRJjnBFai6c/really-minimal-howto-loadbalancing-centos-53-using-ipvsadm</link>
 <description>&lt;p&gt;There are quite a few howto's for LVS, but all of them are quite extensive. To be honest; you'll need to read them at some point, but for now let's try to make a very minimal howto for setting up LVS.&lt;/p&gt;
&lt;h2&gt;Step 1: Install and configure a few settings.&lt;/h2&gt;
&lt;p&gt;Configure the director/loadbalancer to have two NIC's. One side on a routable network, the other side connected to the machine running the services, called realservers.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# chkconfig ipvsadm on&lt;br /&gt;# sed -i &amp;#039;s/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/&amp;#039; /etc/sysctl.conf&lt;br /&gt;# sysctl -p&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;If you want your realservers to be able to use the internet, execute these lines on the director. Replace YOURREALSERVERLAN for the network address of the network where the real servers are located, for example. 192.168.1.0&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# iptables -A POSTROURING -s YOURREALSERVERSLAN/24 -j MASQUERADE&lt;br /&gt;# service iptables save&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Step 2: Tell IPVS how to configure itself for HTTP.&lt;/h2&gt;
&lt;p&gt;Fill in the blanks for PUBLICIP and REALSERVERIP. If you would like to add more servers to this virtual server, just repeast the last line a few times, changing the REALSERVERIP every time.&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# echo &amp;quot;-A -t PUBLICIP:80&amp;quot; &amp;gt; /etc/sysconfig/ipvsadm&lt;br /&gt;# echo &amp;quot;-a -t PUBLICIP:80 -r REALSERVERIP -m&amp;quot; &amp;gt;&amp;gt; /etc/sysconfig/ipvsadm&lt;br /&gt;# service ipvsadm start&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Step 3: Test it.&lt;/h2&gt;
&lt;p&gt;From a machine other then the redirector and/or the realserver, visit the ipaddress of your virtual ip.&lt;/p&gt;
&lt;p&gt;N.B. I have spent quite some time trying to access the loadbalancer from the loadbalancer; this does not work.&lt;/p&gt;
</description>
 <comments>http://meinit.nl/really-minimal-howto-loadbalancing-centos-53-using-ipvsadm#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Thu, 20 Aug 2009 11:04:50 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">381 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/really-minimal-howto-loadbalancing-centos-53-using-ipvsadm</feedburner:origLink></item>
<item>
 <title>Zabbix on OpenBSD</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/6LfXsZm8EnM/zabbix-openbsd</link>
 <description>&lt;p&gt;Installing and using the monitoring tool &lt;a href="http://www.zabbix.com/"&gt;Zabbix&lt;/a&gt; on OpenBSD is quite simple. Take just these steps to get started.&lt;/p&gt;
&lt;h3&gt;Step 1: Install a few packages.&lt;/h3&gt;
&lt;p&gt;Use pkg_add to add these packages: (Versions could change over time.)&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;curl-7.19.3&lt;br /&gt;gettext-0.17p0&lt;br /&gt;jpeg-6bp3&lt;br /&gt;libiconv-1.12&lt;br /&gt;libidn-1.11&lt;br /&gt;libxml-2.6.32p2&lt;br /&gt;net-snmp-5.4.2.1p1&lt;br /&gt;php5-core-5.2.8p0&lt;br /&gt;php5-gd-5.2.8-no_x11&lt;br /&gt;php5-pgsql-5.2.8&lt;br /&gt;png-1.2.33&lt;br /&gt;postgresql-client-8.3.6&lt;br /&gt;postgresql-server-8.3.6&lt;br /&gt;t1lib-5.1.0p1&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
Follow all hints the package manager tells you.&lt;/p&gt;
&lt;h3&gt;Step 2: Configure some items.&lt;/h3&gt;
&lt;p&gt;Make sure the apache daemons is started at boot time. (/etc/rc.conf.local)&lt;/p&gt;
&lt;p&gt;Modify PHP to allow longer execution times and set the timezone:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ grep max_execution_time /var/www/conf/php.ini&lt;br /&gt;max_execution_time = 300&lt;br /&gt;$ grep date.timezone /var/www/conf/php.ini&lt;br /&gt;date.timezone = Europe/Amsterdam&lt;br /&gt;$ sudo pkill httpd&lt;br /&gt;$ sudo /usr/sbin/httpd&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h3&gt;Step 3: Compile and install Zabbix.&lt;/h3&gt;
&lt;p&gt;Get the latest release of Zabbix, untar it and use these options to configure it:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;./configure --enable-server --with-pgsql --with-net-snmp --with-libcurl --enable-agent&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
Use "make install" to install all items. The binaries will be placed in /usr/local.&lt;/p&gt;
&lt;p&gt;Import database schemes as described in the &lt;a href="http://www.zabbix.com/documentation.php"&gt;Zabbix documentation&lt;/a&gt;, chapter 2.4.3: "Zabbix Server"&lt;/p&gt;
&lt;p&gt;Create /etc/zabbix/zabbix_agentd.conf and /etc/zabbix/zabbix_server.conf by copying them from the untarred zabbix release:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# mkdir /etc/zabbix&lt;br /&gt;# cp zabbix-1.6.5/misc/conf/zabbix_agentd.conf /etc/zabbix&lt;br /&gt;# cp zabbix-1.6.5/misc/conf/zabbix_server.conf /etc/zabbix&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Set DBName DBUser and DBPassword in /etc/zabbix/zabbix_server.conf.&lt;/p&gt;
&lt;h3&gt;Step 4: Automatically start Zabbix items.&lt;/h3&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;$ cat /etc/rc.local&lt;br /&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $OpenBSD: rc.local,v 1.39 2006/07/28 20:19:46 sturm Exp $&lt;br /&gt;&lt;br /&gt;# Site-specific startup actions, daemons, and other things which&lt;br /&gt;# can be done AFTER your system goes into securemode.&amp;nbsp; For actions&lt;br /&gt;# which should be done BEFORE your system has gone into securemode&lt;br /&gt;# please see /etc/rc.securelevel.&lt;br /&gt;&lt;br /&gt;echo -n &amp;#039;starting local daemons:&amp;#039;&lt;br /&gt;&lt;br /&gt;# Add your local startup actions here.&lt;br /&gt;&lt;br /&gt;if [ -x /usr/local/sbin/zabbix_agentd ] ; then&lt;br /&gt; echo -n &amp;#039; zabbix_agentd&amp;#039;&lt;br /&gt; /usr/local/sbin/zabbix_agentd&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ -x /usr/local/sbin/zabbix_server ] ; then&lt;br /&gt; echo -n &amp;#039; zabbix_server&amp;#039;&lt;br /&gt; /usr/local/sbin/zabbix_server&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo &amp;#039;.&amp;#039;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h3&gt;Step 5: Install the webfrontend.&lt;/h3&gt;
&lt;p&gt;You are practically done, now copy the php files and visit your zabbix installation:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# cp -Rip zabbix-1.6.5/frontends/php/* /var/www/htdocs/zabbix/ &lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;That's it, not extremely difficult!&lt;/p&gt;
</description>
 <comments>http://meinit.nl/zabbix-openbsd#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Fri, 14 Aug 2009 05:55:36 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">380 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/zabbix-openbsd</feedburner:origLink></item>
<item>
 <title>Bash completion for Mac OS X</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/hWdGlbVCwIw/bash-completion-mac-os-x</link>
 <description>&lt;p&gt;If your are using the Terminal application of your Apple computer running Mac OS X, try &lt;a href="http://freshmeat.net/projects/bashcompletion/"&gt;bash programmable completion&lt;/a&gt;. It allow you to use the TAB key more often, for example in scp: (If you are &lt;a href="/using-ssh-keys"&gt;using ssh-keys&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;&lt;div class="codeblock"&gt;&lt;code&gt;$ scp shell01:/etc/pa&lt;br /&gt;/etc/pam.d/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /etc/pam_smb.conf&amp;nbsp;&amp;nbsp; /etc/passwd &lt;br /&gt;/etc/pam_pkcs11/&amp;nbsp;&amp;nbsp;&amp;nbsp; /etc/pango/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /etc/passwd- &lt;br /&gt;$ scp shell01:/etc/pa&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The steps to start using this great utility are these:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="http://freshmeat.net/projects/bashcompletion/"&gt;Download the bash programmable completion .tar.gz file&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In a Terminal on your Apple, untar it. (tar -xvf bash-completion-20060301.tar&lt;/li&gt;
&lt;li&gt;Copy the bash_completion shell-script to /etc (sudo cp bash_completion/bash_completion /etc)&lt;/li&gt;
&lt;li&gt;Add the bash complation to your login script. (echo ". /etc/bash_completion" &gt;&gt; ~/.profile)&lt;/li&gt;
&lt;li&gt;Start a new terminal and see the result!&lt;/li&gt;
&lt;/ol&gt;
</description>
 <comments>http://meinit.nl/bash-completion-mac-os-x#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Fri, 10 Jul 2009 07:20:20 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">379 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/bash-completion-mac-os-x</feedburner:origLink></item>
<item>
 <title>Using DynDNS for iPhone OS 3.0 without crontab but with launchd</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/G5rbUeFwU_c/using-dyndns-iphone-os-30-without-crontab-launchd</link>
 <description>&lt;p&gt;Apple iPhone OS 3.0 does not have crontab anymore. You are supposed to use launchd's facilities to execute something at a scheduled interval. Here is an example of a simple script to update the IP-address at DynDNS.org.&lt;/p&gt;
&lt;p&gt;The script /var/mobile/update-dyndns.org contains:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;host=&amp;quot;your-host-name.dyndns.org&amp;quot;&lt;br /&gt;user=&amp;quot;your-username&amp;quot;&lt;br /&gt;pass=&amp;quot;your-password&amp;quot;&lt;br /&gt;&lt;br /&gt;oldip=$(cat /tmp/ip)&lt;br /&gt;wget -o /dev/null -O - http://ip.serverchief.com/ &amp;gt; /tmp/ip&lt;br /&gt;ip=$(cat /tmp/ip)&lt;br /&gt;&lt;br /&gt;if [ &amp;quot;$oldip&amp;quot; != &amp;quot;$ip&amp;quot; ] ; then&lt;br /&gt; echo -n &amp;quot;$(date) &amp;quot;&lt;br /&gt; echo $(/usr/local/bin/wget -O - &amp;quot;http://$user:$pass@members.dyndns.org/nic/update?hostname=$host&amp;amp;wildcard=NOCHG&amp;amp;bacakmx=NOCHG&amp;quot;&amp;nbsp; 2&amp;gt; /dev/null)&lt;br /&gt;fi&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The file /var/LaunchDaemons/org.dyndns.update.plist contains:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE plist PUBLIC &amp;quot;-//Apple Computer//DTD PLIST 1.0//EN&amp;quot; &amp;quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;plist version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;dict&amp;gt;&amp;nbsp; &lt;br /&gt;	&amp;lt;key&amp;gt;Label&amp;lt;/key&amp;gt;&lt;br /&gt;	&amp;lt;string&amp;gt;org.dyndns.update&amp;lt;/string&amp;gt;&lt;br /&gt;	&amp;lt;key&amp;gt;ProgramArguments&amp;lt;/key&amp;gt;&lt;br /&gt;	&amp;lt;array&amp;gt; &lt;br /&gt;		&amp;lt;string&amp;gt;~/mobile/dyndns-update.sh&amp;lt;/string&amp;gt;&lt;br /&gt;	&amp;lt;/array&amp;gt;&lt;br /&gt;	&amp;lt;key&amp;gt;StartCalendarInterval&amp;lt;/key&amp;gt;&lt;br /&gt;	&amp;lt;dict&amp;gt;&amp;nbsp; &lt;br /&gt;		&amp;lt;key&amp;gt;Minute&amp;lt;/key&amp;gt;&lt;br /&gt;		&amp;lt;integer&amp;gt;3&amp;lt;/integer&amp;gt;&lt;br /&gt;	&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;lt;/dict&amp;gt;&lt;br /&gt;&amp;lt;/plist&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And execute:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;# launchctl load org.dyndns.update.plist&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now your IP will be update every 3-rd minute. Have fun!&lt;/p&gt;
</description>
 <comments>http://meinit.nl/using-dyndns-iphone-os-30-without-crontab-launchd#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Fri, 03 Jul 2009 11:10:08 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">377 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/using-dyndns-iphone-os-30-without-crontab-launchd</feedburner:origLink></item>
<item>
 <title>A shell script to measure network throughput on Linux machines.</title>
 <link>http://feedproxy.google.com/~r/MeInIt/~3/FnH-kLu-x0o/shell-script-measure-network-throughput-linux-machines</link>
 <description>&lt;p&gt;Here is a shell script to see how many (kilo-, mega-, giga-, terra-) bytes pass a network interface. The output looks like this:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;$ ./network-traffic.sh --help&lt;br /&gt;Usage: ./network-traffic.sh [-i INTERFACE] [-s INTERVAL] [-c COUNT]&lt;br /&gt;&lt;br /&gt;-i INTERFACE&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; The interface to monitor, default is eth0.&lt;br /&gt;-s INTERVAL&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; The time to wait in seconds between measurements, default is 3 seconds.&lt;br /&gt;-c COUNT&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; The number of times to measure, default is 10 times.&lt;br /&gt;$ ./network-traffic.sh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;Monitoring eth0 every 3 seconds. (RXbyte total = 706 Mb TXbytes total = 1 Gb)&lt;br /&gt;RXbytes = 104 b	TXbytes = 194 b&lt;br /&gt;RXbytes = 80 b	TXbytes = 188 b&lt;br /&gt;RXbytes = 52 b	TXbytes = 146 b&lt;br /&gt;RXbytes = 689 b	TXbytes = 8 Kb&lt;br /&gt;RXbytes = 52 b	TXbytes = 146 b&lt;br /&gt;RXbytes = 52 b	TXbytes = 146 b&lt;br /&gt;RXbytes = 52 b	TXbytes = 146 b&lt;br /&gt;RXbytes = 52 b	TXbytes = 146 b&lt;br /&gt;RXbytes = 4 Kb	TXbytes = 4 Kb&lt;br /&gt;RXbytes = 716 b	TXbytes = 5 Kb&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Here is the script:&lt;br /&gt;
&lt;div class="codeblock"&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;usage(){&lt;br /&gt; echo &amp;quot;Usage: $0 [-i INTERFACE] [-s INTERVAL] [-c COUNT]&amp;quot;&lt;br /&gt; echo&lt;br /&gt; echo &amp;quot;-i INTERFACE&amp;quot;&lt;br /&gt; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp; The interface to monitor, default is eth0.&amp;quot;&lt;br /&gt; echo &amp;quot;-s INTERVAL&amp;quot;&lt;br /&gt; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp; The time to wait in seconds between measurements, default is 3 seconds.&amp;quot;&lt;br /&gt; echo &amp;quot;-c COUNT&amp;quot;&lt;br /&gt; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp; The number of times to measure, default is 10 times.&amp;quot;&lt;br /&gt; exit 3&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;readargs(){&lt;br /&gt; while [ &amp;quot;$#&amp;quot; -gt 0 ] ; do&lt;br /&gt;&amp;nbsp; case &amp;quot;$1&amp;quot; in&lt;br /&gt;&amp;nbsp;&amp;nbsp; -i)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$2&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interface=&amp;quot;$2&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift ; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Missing a value for $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; -s)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$2&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sleep=&amp;quot;$2&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift ; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Missing a value for $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; -c)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$2&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter=&amp;quot;$2&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift ; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Missing a value for $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; *)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;Unknown option $1.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shift&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; esac&lt;br /&gt; done&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;checkargs(){&lt;br /&gt; if [ ! &amp;quot;$interface&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; interface=&amp;quot;eth0&amp;quot;&lt;br /&gt; fi&lt;br /&gt; if [ ! &amp;quot;$sleep&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; sleep=&amp;quot;3&amp;quot;&lt;br /&gt; fi&lt;br /&gt; if [ ! &amp;quot;$counter&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp; counter=&amp;quot;10&amp;quot;&lt;br /&gt; fi&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;printrxbytes(){&lt;br /&gt; /sbin/ifconfig &amp;quot;$interface&amp;quot; | grep &amp;quot;RX bytes&amp;quot; | cut -d: -f2 | awk &amp;#039;{ print $1 }&amp;#039;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;printtxbytes(){&lt;br /&gt; /sbin/ifconfig &amp;quot;$interface&amp;quot; | grep &amp;quot;TX bytes&amp;quot; | cut -d: -f3 | awk &amp;#039;{ print $1 }&amp;#039;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;bytestohumanreadable(){&lt;br /&gt; multiplier=&amp;quot;0&amp;quot;&lt;br /&gt; number=&amp;quot;$1&amp;quot;&lt;br /&gt; while [ &amp;quot;$number&amp;quot; -ge 1024 ] ; do&lt;br /&gt;&amp;nbsp; multiplier=$(($multiplier+1))&lt;br /&gt;&amp;nbsp; number=$(($number/1024))&lt;br /&gt; done&lt;br /&gt; case &amp;quot;$multiplier&amp;quot; in&lt;br /&gt;&amp;nbsp; 1)&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;$number Kb&amp;quot;&lt;br /&gt;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; 2)&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;$number Mb&amp;quot;&lt;br /&gt;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; 3)&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;$number Gb&amp;quot;&lt;br /&gt;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; 4)&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;$number Tb&amp;quot;&lt;br /&gt;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp; *)&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;$1 b&amp;quot;&lt;br /&gt;&amp;nbsp; ;;&lt;br /&gt; esac&lt;br /&gt;}&lt;br /&gt;&amp;nbsp; &lt;br /&gt;printresults(){&lt;br /&gt; while [ &amp;quot;$counter&amp;quot; -ge 0 ] ; do&lt;br /&gt;&amp;nbsp; counter=$(($counter - 1))&lt;br /&gt;&amp;nbsp; if [ &amp;quot;$rxbytes&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp; oldrxbytes=&amp;quot;$rxbytes&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp; oldtxbytes=&amp;quot;$txbytes&amp;quot;&lt;br /&gt;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp; rxbytes=$(printrxbytes)&lt;br /&gt;&amp;nbsp; txbytes=$(printtxbytes)&lt;br /&gt;&amp;nbsp; if [ &amp;quot;$oldrxbytes&amp;quot; -a &amp;quot;$rxbytes&amp;quot; -a &amp;quot;$oldtxbytes&amp;quot; -a &amp;quot;$txbytes&amp;quot; ] ; then&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;RXbytes = $(bytestohumanreadable $(($rxbytes - $oldrxbytes)))	TXbytes = $(bytestohumanreadable $(($txbytes - $oldtxbytes)))&amp;quot;&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;Monitoring $interface every $sleep seconds. (RXbyte total = $(bytestohumanreadable $rxbytes) TXbytes total = $(bytestohumanreadable $txbytes))&amp;quot;&lt;br /&gt;&amp;nbsp; fi &lt;br /&gt;&amp;nbsp; sleep &amp;quot;$sleep&amp;quot;&lt;br /&gt; done&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;readargs &amp;quot;$@&amp;quot;&lt;br /&gt;checkargs&lt;br /&gt;printresults&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://meinit.nl/shell-script-measure-network-throughput-linux-machines#comments</comments>
 <category domain="http://meinit.nl/content/articles">Articles</category>
 <category domain="http://meinit.nl/writer-robert-de-bock">Robert de Bock</category>
 <pubDate>Tue, 30 Jun 2009 11:58:53 +0000</pubDate>
 <dc:creator>Robert de Bock</dc:creator>
 <guid isPermaLink="false">376 at http://meinit.nl</guid>
<feedburner:origLink>http://meinit.nl/shell-script-measure-network-throughput-linux-machines</feedburner:origLink></item>
</channel>
</rss>

