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

<channel>
	<title>Admon Home</title>
	<atom:link href="http://www.admon.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.admon.org</link>
	<description>Linux System Administration</description>
	<lastBuildDate>Thu, 29 Dec 2011 15:20:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>In Memoriam: 17 Tech Pioneers Who Died in 2011</title>
		<link>http://www.admon.org/in-memoriam-17-tech-pioneers-who-died-in-2011/</link>
		<comments>http://www.admon.org/in-memoriam-17-tech-pioneers-who-died-in-2011/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 13:38:49 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[2011]]></category>
		<category><![CDATA[pioneers]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=1053</guid>
		<description><![CDATA[Along with Steve Jobs and Dennis Ritchie, 2011 marked the passing of many computer visionaries and technology pioneers. The computing industry came of age in the 1950s, and many of the individuals who laid the groundwork for modern computing, smart electronics and the Internet are now in their 80s. Many of the leaders who passed [...]]]></description>
			<content:encoded><![CDATA[<p>Along with Steve Jobs and <a title="Dennis Ritchie" href="http://en.wikipedia.org/wiki/Dennis_Ritchie" target="_blank">Dennis Ritchie</a>, 2011 marked the passing of many computer visionaries and technology pioneers.</p>
<p>The computing industry came of age in the 1950s, and many of the individuals who laid the groundwork for modern computing, smart electronics and the Internet are now in their 80s. <span id="more-1053"></span>Many of the leaders who passed away in 2011 were founders and chief executives who transformed their companies to take advantage of emerging technology. Several worked on the theoretical foundations in the fields of optics, mathematics and cryptography. Many knew each other as fellow members of the hobbyists group the <a title="Homebrew Computer Club" href="http://en.wikipedia.org/wiki/Homebrew_Computer_Club" target="_blank">Homebrew Computer Club</a>.</p>
<p>In memory of these innovators, <a title="eWEEK.com" href="http://www.eweek.com/" target="_blank">eWEEK</a> honors some of the individuals who made all the things modern society takes for granted possible, such as digital computers, cellular phones and interconnected networks. While some of the pioneers are better known than others, every one of the names on this list made their mark and has inspired thousands of people with their contributions.</p>
<p>Read more: <a href="http://www.eweek.com/c/a/IT-Infrastructure/In-Memoriam-17-Tech-Pioneers-Who-Died-in-2011-293735/" target="_blank">IT &amp; Network Infrastructure : In Memoriam: 17 Tech Pioneers Who Died in 2011</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/in-memoriam-17-tech-pioneers-who-died-in-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resize root partition for a running EBS EC2 Instance</title>
		<link>http://www.admon.org/resize-root-partition-for-a-running-ebs-ec2-instance/</link>
		<comments>http://www.admon.org/resize-root-partition-for-a-running-ebs-ec2-instance/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 02:59:39 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[System Tuning]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[ext3]]></category>
		<category><![CDATA[xfs]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=1043</guid>
		<description><![CDATA[As long as you are all right with a little downtime of the EC2 instance (in a few minutes), it is possible to extend the root partition on a running EBS boot EC2 instance, without needing to start a new instance. Before starting playing the trick, you need to have Amzon EC2 API tools installed. [...]]]></description>
			<content:encoded><![CDATA[<p>As long as you are all right with a little downtime of the EC2 instance (in a few minutes), it is possible to extend the root partition on a running EBS boot EC2 instance, without needing to start a new instance. <span id="more-1043"></span></p>
<p>Before starting playing the trick, you need to have <a title="Amazon EC2 API tools" href="http://www.admon.org/setup-amazon-ec2-api-tools-on-macbook/" target="_blank">Amzon EC2 API tools</a> installed.</p>
<p>Then the steps are:</p>
<ol>
<li>Shutdown the instance and detach the volume.</li>
<li>Build a snapshot for the detached volume and create a volume with a larger size based on the snapshot.</li>
<li>Attach the new volume to the instance and start it.</li>
<li>Login the instance and resize the root file system to fill the new EBS volume.</li>
</ol>
<p>Commands for the last step are listed as below:</p>
<pre># ext3 root file system (more common):
sudo resize2fs /dev/sda1

# XFS root file system (less common):
sudo xfs_growfs /</pre>
<p>xfs_growfs is supplied by <a title="XFS" href="http://oss.sgi.com/projects/xfs/" target="_blank">xfsprogs</a>, which can be installed via yum (or apt-get).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/resize-root-partition-for-a-running-ebs-ec2-instance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>vmtouch: File system cache diagnostics and control</title>
		<link>http://www.admon.org/vmtouch-file-system-cache-diagnostics-and-control/</link>
		<comments>http://www.admon.org/vmtouch-file-system-cache-diagnostics-and-control/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 15:45:20 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[System Tuning]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[fincore]]></category>
		<category><![CDATA[os]]></category>
		<category><![CDATA[vmtouch]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=1034</guid>
		<description><![CDATA[From the topic above, you may have remembered one of our former post &#8220;what data is cached by operation system&#8220;. This is a similar tool as Fincore, but it&#8217;s more powerful. It&#8217;s written in C and supports UNIX and unix-like systems. The installation is quite simple, you just need to download the source code, and run [...]]]></description>
			<content:encoded><![CDATA[<p>From the topic above, you may have remembered one of our former post &#8220;<a title="what data cached by OS" href="http://www.admon.org/what-data-is-cached-by-operation-system/" target="_blank">what data is cached by operation system</a>&#8220;. This is a similar tool as Fincore, but it&#8217;s more powerful. It&#8217;s written in C and supports UNIX and unix-like systems.<span id="more-1034"></span></p>
<p>The installation is quite simple, you just need to download the <a href="http://hoytech.com/vmtouch/vmtouch.c" target="_blank">source code</a>, and run below command to compile it:</p>
<pre>$ gcc -Wall -O3 -o vmtouch vmtouch.c</pre>
<p>The usage examples can be seen at <a href="http://hoytech.com/vmtouch/" target="_blank">its homepage</a>.</p>
<p>Its key features are:</p>
<ul>
<li>How much data of a file (or a directory) is currently in cache.</li>
<li>Bring a file (or part of a file) into system memory.</li>
<li>Ask the system to <strong>evict</strong> a specified file from memory, making room for other files.</li>
<li><strong>Daemonise</strong> and <strong>lock</strong> specified files into physical memory (Make sense?)</li>
</ul>
<p>Want to have a try? Please click this link: <a href="http://hoytech.com/vmtouch/" target="_blank">http://hoytech.com/vmtouch/</a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/vmtouch-file-system-cache-diagnostics-and-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lucene and Solr 3.5 Released</title>
		<link>http://www.admon.org/lucene-3-5-and-solr-3-5-released/</link>
		<comments>http://www.admon.org/lucene-3-5-and-solr-3-5-released/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 15:33:01 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[solr]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=1019</guid>
		<description><![CDATA[The Lucene project management committee has announced the availability of Apache Lucene 3.5.0 and Apache Solr 3.5.0. Lucene is a high-performance, full-featured text search library. Solr is a standalone search server that uses Lucene at its core for indexing and search. The major changes for the Lucene 3.5.0 release are: Lower Memory Consumption. There is [...]]]></description>
			<content:encoded><![CDATA[<p>The Lucene project management committee has <a href="http://lucene.apache.org/#27+November+2011+-+Lucene+Core+3.5.0+and+Solr+3.5.0+Available">announced</a> the availability of Apache Lucene 3.5.0 and Apache Solr 3.5.0. Lucene is a high-performance, full-featured text search library. Solr is a standalone search server that uses Lucene at its core for indexing and search.<span id="more-1019"></span></p>
<p>The major changes for the Lucene 3.5.0 release are:</p>
<ul>
<li><strong>Lower Memory Consumption</strong>. There is a substantial reduction (3-5X) of memory needed to hold the terms index. This has been achieved by creating a more memory efficient data structure for holding terms.</li>
<li><strong>Deep Paging Support</strong>. Added <a href="http://lucene.apache.org/java/3_5_0/api/core/org/apache/lucene/search/IndexSearcher.html#searchAfter%28org.apache.lucene.search.ScoreDoc,%20org.apache.lucene.search.Query,%20int%29">IndexSearcher.searchAfter</a> which returns results after a specified ScoreDoc. You can pass the last document on the previous page to the searchAfter method to get to the next page of results.</li>
<li><strong>SearcherManager</strong>. The <a href="http://lucene.apache.org/java/3_5_0/api/core/org/apache/lucene/search/SearcherManager.html">org.apache.lucene.search.SearcherManager</a> class has been added to simplify the sharing and reopening of IndexSearcher across multiple search threads. Underlying IndexReader instances are safely closed if not referenced anymore, using the IndexReader&#8217;s reference counts. The acquire method is used to retrieve an IndexSearcher and the release method is used to close the retrieved IndexSearcher.</li>
<li><strong>SearcherLifetimeManager</strong>. The <a href="http://lucene.apache.org/java/3_5_0/api/core/org/apache/lucene/search/SearcherLifetimeManager.html">org.apache.lucene.search.SearcherLifetimeManager</a> class has been added to provide a consistent view of the index across multiple requests. It simplifies the usage of the same IndexSearcher instance between requests, which provides a better user experience when paging or drilling down/up on search results.</li>
<li><strong>IndexWriter.optimize() Deprecated</strong>. <a href="http://lucene.apache.org/java/3_5_0/api/all/org/apache/lucene/index/IndexWriter.html#optimize%28%29">IndexWriter.optimize</a> has been deprecated and renamed to forceMerge. This is to discourage the use of this method since it is a very costly operation and only justified if the index is static.</li>
<li><strong>IndexReader.reopen() Renamed</strong>. <a href="http://lucene.apache.org/java/3_5_0/api/all/org/apache/lucene/index/IndexReader.html#reopen%28%29">IndexWriter.reopen</a> has been replaced by openIfChanged. IndexReader.openIfChanged returns null if there are no changes in the index. This method is typically less costly than opening a new IndexReader.</li>
<li><strong>NGramPhraseQuery</strong>. <a href="http://lucene.apache.org/java/3_5_0/api/core/org/apache/lucene/search/NGramPhraseQuery.html">org.apache.lucene.search.NGramPhraseQuery</a> is a PhraseQuery which is optimized for n-gram phrase queries. This can speed up queries 30-50% when n-gram analysis is used.</li>
</ul>
<p>To see the full list of changes in Lucene 3.5, please visit the <a href="http://wiki.apache.org/lucene-java/ReleaseNote35">Lucene 3.5 Release Notes</a>.</p>
<p>The major changes for the Solr 3.5.0 release are:</p>
<ul>
<li><strong>Lucene 3.5.0</strong>. Fixes and enhancements from Lucene 3.5.0, most notably the substantial reduction of memory needed for holding the term index.</li>
<li><strong>Distributed Result Grouping</strong>. Support for distributed search result grouping, also called field collapsing. This feature limits the number of documents shown for each &#8220;group&#8221;, defined as the unique values in a field, and now works with distributed search.</li>
<li><strong>Language Detection</strong>. The new contrib module &#8220;langid&#8221; adds the ability to detect the language of a document before indexing, so appropriate decisions can be made. It is implemented as an UpdateRequestProcessor using Apache Tika&#8217;s LanguageIdentifier or Cybozu&#8217;s language-detection library.</li>
<li><strong>Numeric sortMissingFirst and sortMissingLast Support</strong>. Numeric types including Trie field types and dates now support sortMissingFirst and sortMissingLast.</li>
<li><strong>HunspellStemFilterFactory</strong>. Added support for Lucene&#8217;s HunspellStemmerFilter which supports stemming for 99 languages. Hunspell is originally an advanced spell checker most famously used in the OpenOffice suite and is used in Solr for stemming.</li>
<li><strong>hl.q parameter</strong>. The optional hl.q parameter has been added, and if specified, overrides the q parameter in the Highlighter (HighlightComponent).</li>
</ul>
<p>The see the full list of changes in Solr 3.5, please visit the <a href="http://wiki.apache.org/solr/ReleaseNote35">Solr 3.5 Release Notes</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/lucene-3-5-and-solr-3-5-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GSLB: How DNS-based one works</title>
		<link>http://www.admon.org/gslb-how-dns-based-one-works/</link>
		<comments>http://www.admon.org/gslb-how-dns-based-one-works/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 02:59:11 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[citrix]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[gslb]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=1012</guid>
		<description><![CDATA[GSLB is short for Global Server Load Balancing, and is a tried and tested way of improving the availability and speed of Internet-based services. GSLB enables distribution of traffic across multiple sites, manages disaster recovery, and ensures that applications are consistently accessible. The Citrix NetScaler implementation of GSLB is DNS-based. DNS can be thought of [...]]]></description>
			<content:encoded><![CDATA[<p>GSLB is short for <strong>Global Server Load Balancing</strong>, and is a tried and tested way of improving the availability and speed of Internet-based services. GSLB enables distribution of traffic across multiple sites, manages disaster recovery, and ensures that applications are consistently accessible.<span id="more-1012"></span></p>
<p>The <a title="Citrix NetScaler" href="http://www.citrix.com/NetScaler" target="_blank">Citrix NetScaler</a> implementation of GSLB is DNS-based. DNS can be thought of as the Internet’s ‘Phone Book’, telling computers where different services are located. DNS-based Global Server Load Balancers are by far the most common type of GSLB device.</p>
<p>GSLB directs DNS requests to the best-performing GSLB site in a distributed Internet environment. When a client sends a DNS request, the system determines the best-performing site and returns its IP to the client. In the process of ascertaining the best- performing site, the system performs these intelligent decisions:</p>
<ul>
<li>Directs client requests to the geographically closest GSLB site (geographic and network proximity-based traffic redirection)</li>
<li>Directs client requests to surviving data centers when an outage occurs</li>
<li>Directs client requests to alternate data centers, when a pre-defined traffic load limit is reached</li>
<li>Directs client requests to be distributed among multiple data centers (assigns each user to the GSLB site with lowest latency)</li>
</ul>
<p>The system performs these intelligent decisions using the <a title="MEP" href="http://support.citrix.com/article/CTX121675" target="_blank">Metric Exchange Protocol</a> (MEP), GSLB policies, and GSLB methods supported by the system.</p>
<p><strong>GSLB policies</strong> direct the traffic to a pre-defined target site. <strong>GSLB methods</strong> are algorithms that control how the system load-balances client requests across distributed data centers. The system provides support for creating policies for distributing or redirecting client request.</p>
<p>Multiple sites exchange metrics with each other using the MEP. The system uses this protocol to exchange load, network, and persistence information between GSLB sites. The system also uses this information to perform load balancing between GSLB sites.</p>
<p><strong>GSLB Entity Model</strong></p>
<p><strong></strong>A typical GSLB deployment contains the entities described in the following figure.  <img src="http://community.citrix.com/download/attachments/37847052/GSLB_Architecture.PNG" alt="GSLB Architecture" align="absmiddle" border="0" /></p>
<p>To configure GSLB, you must configure a <strong>GSLB site</strong>. As shown in the figure, a GSLB site is the logical collection of <strong>GSLB vserver</strong>, <strong>GSLB service</strong>, <strong>LB vserver</strong>, <strong>service</strong>, <strong>domain</strong>, and <strong>ADNS service</strong>. It is the central entity in a GSLB deployment, and is represented by a name and an IP address.</p>
<p>To create a <strong>GSLB site</strong>, you must configure load balancing on the system. You must create<strong> GSLB vservers</strong> and GSLB services for each site. You must bind GSLB services to GSLB vservers. You must then create an ADNS service that provides the IP address of the best performing site to the client&#8217;s request.</p>
<p>A <strong>GSLB vserver</strong> is an entity that performs load balancing for the domains bound to it by returning the IP address of the best GSLB service. A GSLB service is a representation of the load balancing/content switching vserver. An LB vserver load balances incoming traffic by identifying the best server, then directs traffic to the corresponding service. It can also load-balance external DNS name servers. Services are entities that represent the servers. The domain is the domain name for which the system is the authoritative DNS server. By creating an ADNS service, the system can be configured as an <a href="http://en.wikipedia.org/wiki/Domain_Name_System" target="_blank">authoritative DNS server</a>.</p>
<p><em>Note: This is a modified version from the article <a title="How GSLB Works" href="http://community.citrix.com/display/ns/How+GSLB+Works" target="_blank">How+GSLB+Works</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/gslb-how-dns-based-one-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check Virtualization type for a running Linux</title>
		<link>http://www.admon.org/check-virtualization-type-for-running-linux/</link>
		<comments>http://www.admon.org/check-virtualization-type-for-running-linux/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 14:53:55 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[openvz]]></category>
		<category><![CDATA[uml]]></category>
		<category><![CDATA[vserver]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=1007</guid>
		<description><![CDATA[Are you running VPS as a hosting solution? And do you want to know what kind of virtualization is it running on? Is it OpenVZ, V-server, Xen or UML, and how can I confirm this? Since the hosting providers normally do not tell you these kind of detailed info, here we created a simple script: [...]]]></description>
			<content:encoded><![CDATA[<p>Are you running VPS as a hosting solution? And do you want to know what kind of virtualization is it running on? Is it <a href="http://wiki.openvz.org/Main_Page" title="OpenVZ" target="_blank">OpenVZ</a>, <a href="http://linux-vserver.org/" title="V-server" target="_blank">V-server</a>, <a href="http://xen.org/" title="Xen" target="_blank">Xen</a> or <a href="http://user-mode-linux.sourceforge.net/" title="UML" target="_blank">UML</a>, and how can I confirm this?<span id="more-1007"></span><br />
Since the hosting providers normally do not tell you these kind of detailed info, here we created a simple script:</p>
<pre>
#!/usr/bin/python
#
# Check what kind of virtual machine for a running Linux. It supports (openvz/vserver/xen/uml).
# Please copy &#038; save this script and run it as root.
#
# By Joseph Chen <http://www.admon.org/> 2011-12-10

import sys, os
import re

def main():
    if os.getuid() != 0:
        print "It must be run as root"
        sys.exit(0)

    # Check OpenVZ/Virtuozzo
    if os.path.exists("/proc/vz"):
        if not os.path.exists("/proc/bc"):
            print "openvz container"
        else:
            print "openvz node"

    # Check V-server
    if os.path.exists("/proc/self/status"):
	s = open("/proc/self/status", "r")
	txt = s.read()
	s.close()

        reobj = re.compile(r"^(s_context|VxID):[[:blank:]]*[0-9]/")
        if reobj.match (txt):
            if os.path.exists("/proc/virtual"):
                print "vserver_host"
            else:
                print "vserver"

    # Check Xen
    if os.path.exists("/proc/xen/capabilities"):

	f = open("/proc/xen/capabilities", "r")
	text = f.read()
	f.close()

        if (len(text) > 0):
            print "xen dom0"
        else:
            print "xen domU"

    # Check User Mode Linux (UML)
    f = open("/proc/cpuinfo", "r"); t = f.read(); f.close()
    if (t.find("UML") > 0):
        print "uml"

if __name__=="__main__":
    main()
</pre>
<p>Here is a running example on a Xen dom0 node:</p>
<pre>
root@pekdev230:~ # python check-vm.py
xen dom0
</pre>
<p>Note that, the check for vserver may not work since I didn&#8217;t get an environment for testing. Sorry about that, but if you any updates, please kindly let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/check-virtualization-type-for-running-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios: Disable notifications from command line</title>
		<link>http://www.admon.org/nagios-disable-notifications-from-command-line/</link>
		<comments>http://www.admon.org/nagios-disable-notifications-from-command-line/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 15:15:03 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=995</guid>
		<description><![CDATA[With the commands below, Nagios can be controlled in command line mode. It&#8217;s helpful for your automation work. To disable notifications curl -d "cmd_typ=23&#038;cmd_mod=2&#038;host=[THE-HOST]&#038;service=[THE-SERVICE]&#038;btnSubmit=Commit" "http://[NAGIOS-SERVER]/nagios/cgi-bin/cmd.cgi" To enable notifications curl -d "cmd_typ=22&#038;cmd_mod=2&#038;host=[THE-HOST]&#038;service=[THE-SERVICE]&#038;btnSubmit=Commit" "http://[NAGIOS-SERVER]/nagios/cgi-bin/cmd.cgi" Depending on your setup, you may also need to use the &#8211;insecure or &#8211;user options of curl. The parameter of posted data can [...]]]></description>
			<content:encoded><![CDATA[<p>With the commands below, Nagios can be controlled in command line mode. It&#8217;s helpful for your automation work.</p>
<p>To disable notifications<span id="more-995"></span></p>
<p><code>curl -d "cmd_typ=23&#038;cmd_mod=2&#038;host=[THE-HOST]&#038;service=[THE-SERVICE]&#038;btnSubmit=Commit" "http://[NAGIOS-SERVER]/nagios/cgi-bin/cmd.cgi"</code></p>
<p>To enable notifications</p>
<p><code>curl -d "cmd_typ=22&#038;cmd_mod=2&#038;host=[THE-HOST]&#038;service=[THE-SERVICE]&#038;btnSubmit=Commit" "http://[NAGIOS-SERVER]/nagios/cgi-bin/cmd.cgi"</code></p>
<p>Depending on your setup, you may also need to use the &#8211;insecure or &#8211;user options of curl.</p>
<p>The parameter of posted data can be assembled &#8212; look at what links are being used in your web browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/nagios-disable-notifications-from-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check HTTP header on multiple servers</title>
		<link>http://www.admon.org/check-http-header-on-multiple-servers/</link>
		<comments>http://www.admon.org/check-http-header-on-multiple-servers/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 06:07:10 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cdn]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[HTTP]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=990</guid>
		<description><![CDATA[How can we dump the HTTP header for a specified URL? It&#8217;s not difficult since linux has such tools to do that, below is an example: $ curl -s --head http://www.admon.org/robots.txt HTTP/1.1 200 OK Date: Fri, 25 Nov 2011 05:52:11 GMT Server: Apache/2.2.11 (Unix) PHP/5.3.8 DAV/2 SVN/1.6.4 X-Powered-By: PHP/5.3.8 X-Pingback: http://www.admon.org/xmlrpc.php Cache-Control: max-age=303445772 Expires: Wed, [...]]]></description>
			<content:encoded><![CDATA[<p>How can we dump the HTTP header for a specified URL?<br />
It&#8217;s not difficult since linux has such tools to do that, below is an example:<br />
<span id="more-990"></span></p>
<pre>
$ curl -s --head http://www.admon.org/robots.txt
HTTP/1.1 200 OK
Date: Fri, 25 Nov 2011 05:52:11 GMT
Server: Apache/2.2.11 (Unix) PHP/5.3.8 DAV/2 SVN/1.6.4
X-Powered-By: PHP/5.3.8
X-Pingback: http://www.admon.org/xmlrpc.php
Cache-Control: max-age=303445772
Expires: Wed, 07 Jul 2021 08:21:44 GMT
Content-Type: text/plain; charset=utf-8</pre>
<p>If the domain name is resolved to multiple IP addresses (e.g. in a CDN environment), how can we check the header on all servers one by one?<br />
It&#8217;s not a problem, here&#8217;s a script for this task. It resolves the domain names on a list of DNS servers, and collects the resolved IP addresses, then check HTTP header on each of the server:</p>
<pre>
#!/bin/bash
#
# Check HTTP header on a list of servers.
# The servers are resolved by specified DNS servers.
#            by Joseph Chen <joseph#admon.org>
# GPL v2 licensed.

# Define your DNS servers here!
DNS_LIST=(61.139.2.69 192.168.0.3)

die_msg() {
	echo $@
	exit -1
}

[ $# != 1 ] &#038;&#038; die_msg Only accept one URL as parameter.
which  dig >/dev/null || die_msg We need the command dig to do DNS resolving.
which curl >/dev/null || die_msg We need the command curl to send request.

URL=$1
DNAME=$(echo $URL |awk -F// '{print $2}' |awk -F/ '{print $1}')
DFILE=$(echo $URL |awk -F${DNAME} '{print $2}' |awk -F? '{print $1}')

echo Start to check the requested file is $DFILE on domain $DNAME

for ((i=0; i<${#DNS_LIST[@]}; i++))
do
	echo Resolving $DNAME on DNS server ${DNS_LIST[$i]}
	dig +time=1 $DNAME @${DNS_LIST[$i]} |awk '!/^;/ &#038;&#038; /IN\tA/{print $NF}' >/tmp/.cdn.resolved.${i}
done

echo
echo Starting to check HTTP header for $URL on these IP:
echo $(cat /tmp/.cdn.resolved.* | sort | uniq)
echo

echo Checking Last-Modified for http://${DNAME}${DFILE}
for RESOLVED_IP in $(cat /tmp/.cdn.resolved.* |sort |uniq)
do
	/bin/echo -n "Resolved IP: $RESOLVED_IP >>>> "
	curl -s --head --connect-timeout 2 --header "Host: $DNAME" http://${RESOLVED_IP}${DFILE} | grep ^Last-Modified || /bin/echo
done

rm -f /tmp/.cdn.resolved.* 2>/dev/null
</pre>
<p>A running example can be seen as below:</p>
<pre>
$ sh dump-CDN-header.sh http://adm.fwmrm.net/p/fox_live/AdManager.swf
Start to check the requested file is /p/fox_live/AdManager.swf on domain adm.fwmrm.net
Resolving adm.fwmrm.net on DNS server 61.139.2.69
Resolving adm.fwmrm.net on DNS server 192.168.0.3

Starting to check HTTP header for http://adm.fwmrm.net/p/fox_live/AdManager.swf on these IP:
124.40.41.30 124.40.41.40 125.141.136.100 125.141.136.101 125.141.136.102 125.141.136.98 193.108.88.192 205.168.236.217 205.168.236.227

Checking Last-Modified for http://adm.fwmrm.net/p/fox_live/AdManager.swf
Resolved IP: 124.40.41.30 >>>> Last-Modified: Tue, 22 Nov 2011 08:21:11 GMT
Resolved IP: 124.40.41.40 >>>> Last-Modified: Tue, 22 Nov 2011 08:21:11 GMT
Resolved IP: 125.141.136.100 >>>>
Resolved IP: 125.141.136.101 >>>>
Resolved IP: 125.141.136.102 >>>>
Resolved IP: 125.141.136.98 >>>>
Resolved IP: 193.108.88.192 >>>>
Resolved IP: 205.168.236.217 >>>> Last-Modified: Tue, 22 Nov 2011 08:21:11 GMT
Resolved IP: 205.168.236.227 >>>> Last-Modified: Tue, 22 Nov 2011 08:21:11 GMT
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/check-http-header-on-multiple-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Limit the size of Subversion commitment</title>
		<link>http://www.admon.org/limit-the-size-of-subversion-commitment/</link>
		<comments>http://www.admon.org/limit-the-size-of-subversion-commitment/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 16:09:40 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=985</guid>
		<description><![CDATA[Has your subversion repository ever been abused by massive commitments? If not, I should say that you are lucky. Never mind that someday you might be abused as it&#8217;s hard to predict what the non-Ops are working on and trying to do. It would suck just because some people were committing large files without any [...]]]></description>
			<content:encoded><![CDATA[<p>Has your <a title="subversion" href="http://subversion.tigris.org" target="_blank">subversion</a> repository ever been abused by massive commitments?<br />
If not, I should say that you are lucky. Never mind that someday you might be abused as it&#8217;s hard to predict what the non-Ops are working on and trying to do.<span id="more-985"></span><br />
It would suck just because some people were committing large files without any legitimate reasons. There are other annoying consequences. Your daily backup would take longer time to finish eating more disk space, and your commitment analysis tool would get hiccups like ours.</p>
<p>So, <strong>How can we limit the size of a Subversion commitment?</strong><br />
The solution is quite easy, use the <a href="http://svnbook.red-bean.com/en/1.6/svn-book.html#svn.ref.reposhooks.pre-commit" target="_blank">pre-commit hook</a>. You can find some examples after searching around. Here&#8217;s the script that I use. It reads the tmp files in <em>db/transactions/</em>, caculate the total size and compare it with your settings (<em>db/tranactions</em> only saves changesets, not original files).</p>
<p>If the size exceeds your limit, the commitment fails and user will be warned with details.</p>
<pre>#!/usr/bin/env python
#
# Limit the size of SVN commits. It reads db/transactions to caculate commit size.
# Put the follwoing 3 lines in hook/pre-commit hook like this:
#
# REPOS="$1"
# TXN="$2"
# check_commit_size.py "$REPOS" "$TXN" || exit 1
#

import sys,os,popen2

# The size is not an exact value.
MAX_BYTES = 10000000

def printUsage():
    sys.stderr.write('Usage: %s "$REPOS" "$TXN" ' % sys.argv[0])

def getTransactionSize(repos, txn):
    txnRevPath = repos+'/db/transactions'+'/'+txn+'.txn'+'/rev'
    return os.stat(txnRevPath)[6]

def checkTransactionSize(repos, txn):
    size = getTransactionSize(repos, txn)
    if (size &gt; MAX_BYTES):
        sys.stderr.write("Sorry, you are trying to commit %d bytes, which is larger than the limit of %d.\n" % (size, MAX_BYTES))
        sys.stderr.write("If you think you have a good reason to, email to Ops and ask for permission.")
        sys.exit(1)

if __name__ == "__main__":
    #Check that we got a repos and transaction with this script
    if len(sys.argv) != 3:
        printUsage()
        sys.exit(2)
    else:
        repos = sys.argv[1]
        txn = sys.argv[2]

    checkTransactionSize(repos, txn)</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/limit-the-size-of-subversion-commitment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular expressions in Bash 3</title>
		<link>http://www.admon.org/regular-expressions-in-bash-3/</link>
		<comments>http://www.admon.org/regular-expressions-in-bash-3/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 12:26:03 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[regexp]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=978</guid>
		<description><![CDATA[Since version 3 which released in 2004, Bash acquired a regular expression operator &#8220;=~&#8221;, but I never noticed it, probably because grep sed or other commands works alternatively well. The regular expression is the same as egrep,  you can find more details from man egrep. In addition to doing simple matching, bash regular expressions support [...]]]></description>
			<content:encoded><![CDATA[<p>Since version 3 which released in 2004, <a title="bash" href="http://www.gnu.org/s/bash/" target="_blank">Bash</a> acquired a regular expression operator &#8220;=~&#8221;, but I never noticed it, probably because grep sed or other commands works alternatively well. The regular expression is the same as <a title="grep" href="http://www.gnu.org/software/grep/" target="_blank">egrep</a>,  you can find more details from <em>man egrep</em>.<span id="more-978"></span></p>
<p>In addition to doing simple matching, bash regular expressions support sub-patterns for capturing parts of the match. The matches are assigned to an array variable <strong>BASH_REMATCH</strong>. The entire match is assigned to BASH_REMATCH[0], the first sub-pattern is assigned to BASH_REMATCH[1], and going forward.</p>
<p>Below is an example:</p>
<pre>#!/bin/bash
# is this a number?

number=$1
if [ $# -eq 0 ] ; then
   echo Parameter is needed.
   exit
fi

[[ "$number" =~ '\&lt;[0-9]+\&gt;' ]] &amp;&amp; echo 'It is a number' || echo Sorry: ${BASH_REMATCH:?"no value"}

echo "Match: $BASH_REMATCH"</pre>
<p>The running results are:</p>
<pre>
!1064 $ sh test.sh 3123
It is a number
Match: 3123

!1065 $ sh test.sh 123sdf
test.sh: line 8: BASH_REMATCH: no value
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/regular-expressions-in-bash-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

