<?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"
	>

<channel>
	<title>amrit</title>
	<atom:link href="http://blogs.splunk.com/amrit/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.splunk.com/amrit</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sat, 29 Aug 2009 19:31:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>API 4TW</title>
		<link>http://blogs.splunk.com/amrit/2009/08/27/api-4tw/</link>
		<comments>http://blogs.splunk.com/amrit/2009/08/27/api-4tw/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 19:03:41 +0000</pubDate>
		<dc:creator>amrit</dc:creator>
		
		<category><![CDATA[CLI]]></category>

		<category><![CDATA[Homepage]]></category>

		<category><![CDATA[api]]></category>

		<category><![CDATA[dev]]></category>

		<category><![CDATA[platform]]></category>

		<category><![CDATA[tech]]></category>

		<category><![CDATA[40 days of 4.0]]></category>

		<guid isPermaLink="false">http://blogs.splunk.com/amrit/?p=150</guid>
		<description><![CDATA[Ok, here&#8217;s a real blog post to make up for that last one.  You may have heard that one of the major features of Splunk 4.0 is a brand new REST API.  This is the interface that both the CLI and the web UI use to manage Splunk inputs, retrieve splunkd status, perform [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, here&#8217;s a real blog post to make up for that last one.  You may have heard that one of the major features of Splunk 4.0 is a brand new <a href="http://www.infoq.com/articles/rest-introduction">REST</a> API.  This is the interface that both the CLI and the web UI use to manage Splunk inputs, retrieve splunkd status, perform searches, etc.  You, too, can use this API for doing all sorts of good or evil - read on.</p>
<h3>Explore a bit&#8230;</h3>
<p>Exploring it is easy - point Firefox at your your local Splunk instance&#8217;s management port.  For example, <a href="http://en.wikipedia.org/wiki/Atom_(standard)">https://localhost:8089/services</a> is the default.  Adjust <em>https</em> vs <em>http</em> as necessary, as well as the port.  Note that this is the management port, not the web interface port (which is 8000 by default).</p>
<p>In a decent browser (my favorite, Konqueror, doesn&#8217;t seem to cut it <img src='http://blogs.splunk.com/amrit/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> ), you&#8217;ll see a list of links, with smaller links beneath each.  This is just a user-friendly rendering of our <a href="http://en.wikipedia.org/wiki/Atom_(standard)">Atom</a> XML feed.  View the raw XML by right clicking and choosing <em>View Source</em>, if you wish.</p>
<p>You can use this set of links to inspect the state of your running splunkd.  Drilling down into <em>data/inputs/monitor</em>, for example, displays all Monitor inputs that Splunk knows about.  If one of these is a directory, clicking the <em>members</em> link below it will display all the files being monitored within that dir.  Note that not all of the links will work by simply clicking on them.  The <em>remove</em> action, for example, requires an HTTP DELETE action, whereas <em>edit</em> requires an HTTP POST containing the parameters you&#8217;d like to change.</p>
<h3>But APIs are serious business&#8230;</h3>
<p>Agreed, you&#8217;re not going to use the browser with the API for anything more than playing around (although the Poster extension for Firefox is quite useful&#8230;).</p>
<p>If you&#8217;re familiar with HTTP/REST, choose your favorite library and run with it.  Start by making a POST to <em>/services/auth/login</em> with the parameters <em>username=&lt;username&gt;</em> and <em>password=&lt;password&gt;</em>.  You&#8217;ll get a response like the following:</p>
<pre>  &lt;response&gt;
  &lt;sessionKey&gt;a48fe44eb76ecf08674954e47c403f24&lt;/sessionKey&gt;
  &lt;/response&gt;</pre>
<p>Then, simply include this session key in the HTTP headers for any requests you make to the API:</p>
<pre>  Authorization: Splunk a48fe44eb76ecf08674954e47c403f24</pre>
<h3>And if I&#8217;m lazy?</h3>
<p>Don&#8217;t worry, I&#8217;m lazy too.  Splunk includes a handy little tool that lets you easily make calls to the Splunk API.  For example:</p>
<pre>  splunk _internal call /data/inputs/monitor -auth admin:changeme</pre>
<p>Will perform an HTTP GET on <a href="https://localhost:8089/services/data/inputs/monitor">https://localhost:8089/services/data/inputs/monitor</a>.  Since this is a Splunk utility, it will read your config files and automatically enable/disable SSL on the request, as well as change the destination port as necessary.  You can also use -uri to <a href="http://blogs.splunk.com/amrit/2007/07/03/administering-remote-splunk-servers-via-the-cli/">point the request to other servers</a>. <img src='http://blogs.splunk.com/amrit/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The tool allows for POSTs and other HTTP actions, but more on that in my next post&#8230;</p>
<h3>Enough shenanigans, I want a real example.</h3>
<p>Sure.. how about this thing?</p>
<p><a href='http://blogs.splunk.com/amrit/wp-content/uploads/2009/08/splunk_status_2-small.png'><img src="http://blogs.splunk.com/amrit/wp-content/uploads/2009/08/splunk_status_2-small.png" alt="A KDE 4 desktop widget monitoring a handful of boxes around the office.  1 outta 5 ain\&#039;t so bad, is it?" title="A KDE 4 desktop widget monitoring a handful of boxes around the office.  1 outta 5 ain\&#039;t so bad, is it?" width="300" height="219" class="aligncenter size-medium wp-image-151" /></a></p>
<p>This is a <a href="http://techbase.kde.org/Projects/Plasma/Plasmoids">Plasmoid</a> for the <a href="http://www.kde.org/screenshots/">KDE 4</a> desktop environment.  It&#8217;s written in C++ using the cross-platform <a href="http://doc.trolltech.com/4.5">Qt toolkit</a> and KDE&#8217;s <a href="http://techbase.kde.org/Development/Tutorials/Plasma">Plasma library</a>.</p>
<p>The entire code will be linked further down this post, but the most important parts are the HTTP request, and the XML parsing.</p>
<p>We first make a request (using our handy CLI tool, because it&#8217;s easy) to our REST endpoint for messages, where highly important notices end up:</p>
<pre>
  // build args.
  QStringList args;
  args << "_internal"
       << "call"
       << "/admin/messages"
       << "-auth" << userPass; // this is OK even in the free version.
  if (!uri.isEmpty())
    args << "-uri" << (QString("http") + (info.useSSL ? "s" : "") + "://" + uri);
</pre>
<p>(Note that the password is sent as a command line argument - not the most secure thing to do on a multi-user system.  Luckily, this is just a tech demo.)</p>
<p>When the process completes, we check the return code, and then use an XPath query to parse any messages out of the XML returned on stdout:</p>
<pre>
  // build xpath query with splunk's namespace info.
  QXmlQuery query;
  query.bindVariable("data", &#038;xmlData);
  query.setQuery("declare namespace a='http://www.w3.org/2005/Atom';"
                 "declare namespace s='http://dev.splunk.com/ns/rest';"
                 // choose only the s:key nodes that match their entry node's title.
                 "doc($data)/a:feed/a:entry/a:content/s:dict/string(s:key[(../../../a:title = @name)])&#8221;);

  if (!query.evaluateTo(&#038;messages))
    messages << "Parsing of status failed.";
</pre>
<p>&#8230;and throw it up on the screen.  But you&#8217;ll have read the code to find that part. <img src='http://blogs.splunk.com/amrit/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<h3>I wanna try it!</h3>
<p>The source code is <a href="http://transamrit.net/splunk/splunk_status_plasmoid-0.01.tar.bz2">here</a>, give it a shot.</p>
<p>Installation instructions:</p>
<ul>
<li>tar -jxvf splunk_status*.tar.bz2</li>
<li>cd splunk_status-<em>version</em></li>
<li>cmake .  (don&#8217;t miss that dot!)</li>
<li>make</li>
<li>At this point you can try &#8216;make install&#8217;, but on my system I had to manually copy things to the right locations: <em>cp lib/splunk_status.so /usr/lib/kde4/splunk_status.so</em> and <em>cp splunk_status.desktop /usr/share/kde4/services/</em></li>
<li>Rebuild KDE&#8217;s cache: kbuildsycoca4</li>
<li>Restart the Plasma workspace: kquitapp plasma &#038;&#038; sleep 1 &#038;&#038; plasma
<p>Before you enable it in KDE4, you need to create a small config file by hand.  It will look something like the following.</p>
<p>~/.kde/share/config/splunkstatusrc:</p>
<pre>
  [settings]
  cmdPath = /opt/splunk/bin/splunk

  [servers]
  localhost:8089 = admin,changeme,ssl
  amritdesktop:8089 = admin,changeme,nossl
  tiny:1236 = admin,changeme
  spacecake:57089 = admin,changeme,ssl
  10.1.1.50:9089 = admin,changeme,ssl
</pre>
<p>The <em>settings/cmdPath</em> variable is required, as is at least one entry under <em>servers</em>.  The latter is formatted as <em>host:port = username,password,(ssl|nossl)</em>.  Remember that the port here is your management port, not your web interface port.  The SSL specification is optional, and defaults to <em>ssl</em>.  Be sure you get that one right as well (SSL is enabled on default Splunk installs).</p>
<h3>Now&#8230;</h3>
<p>Is anyone actually gonna try this thing? <img src='http://blogs.splunk.com/amrit/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.splunk.com/amrit/2009/08/27/api-4tw/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reload 4 Auth</title>
		<link>http://blogs.splunk.com/amrit/2009/08/20/reload-4-auth/</link>
		<comments>http://blogs.splunk.com/amrit/2009/08/20/reload-4-auth/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 19:54:40 +0000</pubDate>
		<dc:creator>amrit</dc:creator>
		
		<category><![CDATA[CLI]]></category>

		<category><![CDATA[api]]></category>

		<category><![CDATA[dev]]></category>

		<category><![CDATA[hacks]]></category>

		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blogs.splunk.com/amrit/?p=149</guid>
		<description><![CDATA[This will be a very brief post, to fulfill my obligations.  I&#8217;ll share something a little more informative, perhaps even more interesting, in an upcoming post (soon&#8230; I promise (kinda) this time).
As of Splunk 4.0, our old somewhat-of-an-API has been replaced with an entirely new REST API, invalidating my old post on reloading authentication [...]]]></description>
			<content:encoded><![CDATA[<p>This will be a very brief post, to <a href="http://blogs.splunk.com/amrit/2008/11/26/reloading-the-auth-system-via-cli/#comment-538">fulfill my obligations</a>.  I&#8217;ll share something a little more informative, perhaps even more interesting, in an upcoming post (soon&#8230; I promise (kinda) this time).</p>
<p>As of Splunk 4.0, our old somewhat-of-an-API has been replaced with an entirely new REST API, invalidating my old post on reloading authentication from the command line.</p>
<p>Sooo&#8230;.. in 4.x, you can restart the authentication system with the following command:</p>
<p><code>  $ splunk _internal call /authentication/providers/services/_reload -auth admin:changeme</code></p>
<p>Any errors should be obvious in the resulting XML.  As of 4.0.3, you&#8217;ll also get a non-zero return code upon receiving errors from the API.  And I&#8217;ve filed a bug (just now) to expose this as a real CLI command, so soon this post will no longer be very important. <img src='http://blogs.splunk.com/amrit/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p/>
<br/></p>
<p/>
<p>Happy now, Simeon?</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.splunk.com/amrit/2009/08/20/reload-4-auth/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reloading the auth system via CLI</title>
		<link>http://blogs.splunk.com/amrit/2008/11/26/reloading-the-auth-system-via-cli/</link>
		<comments>http://blogs.splunk.com/amrit/2008/11/26/reloading-the-auth-system-via-cli/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 19:26:20 +0000</pubDate>
		<dc:creator>amrit</dc:creator>
		
		<category><![CDATA[CLI]]></category>

		<category><![CDATA[dev]]></category>

		<category><![CDATA[hacks]]></category>

		<category><![CDATA[pcl]]></category>

		<category><![CDATA[remote]]></category>

		<category><![CDATA[tech]]></category>

		<category><![CDATA[admin]]></category>

		<category><![CDATA[auth]]></category>

		<category><![CDATA[splunk]]></category>

		<guid isPermaLink="false">http://blogs.splunk.com/amrit/?p=148</guid>
		<description><![CDATA[Note: Tina pointed out that this does not apply to the authorize.conf file.  This will be fixed in an upcoming version of splunk.
This comes up every once in a while on the support channel (EFnet/#splunk), so I guess that means I should do a blog post on it.
If you&#8217;re making changes to the authentication.conf [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note:</strong> Tina pointed out that this does not apply to the authorize.conf file.  This will be fixed in an upcoming version of splunk.</p>
<p>This comes up every once in a while on the support channel (EFnet/#splunk), so I guess that means I should do a blog post on it.</p>
<p>If you&#8217;re making changes to the authentication.conf file and want to reload Splunk&#8217;s auth system without going through the web UI, you can use one of our internal functions to do it at the command line:</p>
<p>  $ splunk _internal rpc-auth &#8216;&lt;call name=&#8221;syncAuth&#8221;&gt;&lt;params/&gt;&lt;/call&gt;&#8217;</p>
<p>This fires off the same call that the UI would use to reload the auth system, so it functions identically.  Note that this is an authenticated call, so you&#8217;ll need to use one of the standard authentication methods (-auth, splunk login, or the SPLUNK_USERNAME/SPLUNK_PASSWORD env vars&#8230;).</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.splunk.com/amrit/2008/11/26/reloading-the-auth-system-via-cli/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Saving the environment, one beer pong game at a time.</title>
		<link>http://blogs.splunk.com/amrit/2007/11/05/saving-the-environment-one-beer-pong-game-at-a-time/</link>
		<comments>http://blogs.splunk.com/amrit/2007/11/05/saving-the-environment-one-beer-pong-game-at-a-time/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 21:42:07 +0000</pubDate>
		<dc:creator>amrit</dc:creator>
		
		<category><![CDATA[dev]]></category>

		<category><![CDATA[life]]></category>

		<guid isPermaLink="false">http://blogs.splunk.com/amrit/2007/11/05/saving-the-environment-one-beer-pong-game-at-a-time/</guid>
		<description><![CDATA[Recycling is universally considered to be a good thing, right?
Good.  Then that means that we at Splunk are obligated to play play beer pong every Friday!  I figure that with all the bottles and cans that subsequently go into the recycling bin, we&#8217;re probably  offsetting a small percentage of the many computers [...]]]></description>
			<content:encoded><![CDATA[<p>Recycling is universally considered to be a good thing, right?</p>
<p>Good.  Then that means that we at Splunk are <em>obligated</em> to play play beer pong every Friday!  I figure that with all the bottles and cans that subsequently go into the recycling bin, we&#8217;re probably  offsetting a small percentage of the many computers we use here&#8230; amirite?</p>
<p><img src="http://blogs.splunk.com/devuploads/2007/11/beerPongAtSplunk.jpg" alt="Al Gore would be proud" /></p>
<p>If you disagree, you can voice your opinions in person.  See you here Friday at 5PM.  <img src='http://blogs.splunk.com/amrit/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.splunk.com/amrit/2007/11/05/saving-the-environment-one-beer-pong-game-at-a-time/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Things you don&#8217;t want to hear at work</title>
		<link>http://blogs.splunk.com/amrit/2007/10/09/things-you-dont-want-to-hear-at-work/</link>
		<comments>http://blogs.splunk.com/amrit/2007/10/09/things-you-dont-want-to-hear-at-work/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 01:21:08 +0000</pubDate>
		<dc:creator>amrit</dc:creator>
		
		<category><![CDATA[dev]]></category>

		<category><![CDATA[life]]></category>

		<guid isPermaLink="false">http://blogs.splunk.com/amrit/2007/10/09/things-you-dont-want-to-hear-at-work/</guid>
		<description><![CDATA[Lots of things are said here that are&#8230; hmm, what&#8217;s the word&#8230; inappropriate?  disgusting?  TMI?  omgwtfbbq?
My boss just told me, &#8220;Amrit, I have a camera on my computer.  And when I&#8217;m at home, anytime you want, I can turn on the camera and you can watch.&#8221;
There was more, but I think [...]]]></description>
			<content:encoded><![CDATA[<p>Lots of things are said here that are&#8230; hmm, what&#8217;s the word&#8230; inappropriate?  disgusting?  TMI?  omgwtfbbq?</p>
<p>My boss just told me, &#8220;Amrit, I have a camera on my computer.  And when I&#8217;m at home, anytime you want, I can turn on the camera and you can watch.&#8221;</p>
<p>There was more, but I think my ears reflexively closed in on themselves.</p>
<p><img src="http://blogs.splunk.com/devuploads/2007/10/Gorilla_donotwant.jpg" alt="do not want" /></p>
<p>:/</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.splunk.com/amrit/2007/10/09/things-you-dont-want-to-hear-at-work/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Administering remote Splunk servers via the CLI</title>
		<link>http://blogs.splunk.com/amrit/2007/07/03/administering-remote-splunk-servers-via-the-cli/</link>
		<comments>http://blogs.splunk.com/amrit/2007/07/03/administering-remote-splunk-servers-via-the-cli/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 15:02:46 +0000</pubDate>
		<dc:creator>amrit</dc:creator>
		
		<category><![CDATA[CLI]]></category>

		<category><![CDATA[Homepage]]></category>

		<category><![CDATA[pcl]]></category>

		<category><![CDATA[remote]]></category>

		<guid isPermaLink="false">http://blogs.splunk.com/amrit/2007/07/03/administering-remote-splunk-servers-via-the-cli/</guid>
		<description><![CDATA[It&#8217;s a little known (mainly because it&#8217;s undocumented) fact that it is possible to use the Splunk CLI to manage remote Splunk servers.  This capability has been built into the product since version 2.1, and allows one to do things such as remotely manage data inputs, run searches, manage users, etc.  For fairly [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a little known (mainly because it&#8217;s undocumented) fact that it is possible to use the Splunk CLI to manage remote Splunk servers.  This capability has been built into the product since version 2.1, and allows one to do things such as remotely manage data inputs, run searches, manage users, etc.  For fairly obvious reasons, this cannot be done with commands that require Splunkd to be stopped.</p>
<p>The syntax is simple:</p>
<p><strong>/opt/splunk/bin/splunk &lt;command&gt;  [&lt;subcommand&gt;] &lt;params&gt; -uri https://my2ndSplunkBox:8089</strong></p>
<p>The key here is the <strong>-uri</strong> parameter, which instructs the PCL to send all SOAP requests to the specified server.  There are 3 pieces to the parameter: protocol, host, and port.</p>
<p>The protocol must be one of <strong>http</strong> or <strong>https</strong>, depending on whether or not SSL is enabled on the Splunkd port.  Most users will want the latter, as recent versions of Splunk enable SSL on this port by default.</p>
<p>The second part is the hostname or IP address of the host that the remote Splunk server is running on.  This should need no real explanation - in this case, the remote server has the hostname <strong>my2ndSplunkBox</strong>.</p>
<p>The last part of the argument is the Splunkd port (aka the management port).  Note that this is <em>not</em> the port that&#8217;s used to reach the web interface, but the port that Splunkd listens on for incoming SOAP requests.  If you&#8217;re unsure of what this port is, try the default, which is <strong>8089</strong>.  Alternatively, <strong>splunk show splunkd-port</strong> will display the Splunkd port that the current server is listening on.</p>
<p>As a practical example, one can add a tailed data input on the <strong>/var/log</strong> directory of host <strong>my2ndSplunkBox</strong> with the following command:</p>
<p><strong>splunk add tail /var/log -uri https://my2ndSplunkBox:8089</strong></p>
<p>The only caveat to this feature is that if you&#8217;re logged into your Splunk server via <strong>splunk login</strong>, you will have to re-authenticate when sending commands to the remote server (and once again when you resume targetting your local server by leaving off <strong>-uri</strong>). Workarounds include using the <strong>-auth</strong> parameter or the <strong>SPLUNK_USERNAME</strong> and <strong>SPLUNK_PASSWORD</strong> environment variables, but these are better left to a later post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.splunk.com/amrit/2007/07/03/administering-remote-splunk-servers-via-the-cli/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HI@WEB2.0</title>
		<link>http://blogs.splunk.com/amrit/2007/07/03/hiweb20/</link>
		<comments>http://blogs.splunk.com/amrit/2007/07/03/hiweb20/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 14:24:36 +0000</pubDate>
		<dc:creator>amrit</dc:creator>
		
		<category><![CDATA[CLI]]></category>

		<category><![CDATA[Homepage]]></category>

		<category><![CDATA[pcl]]></category>

		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://blogs.splunk.com/amrit/2007/07/03/hiweb20/</guid>
		<description><![CDATA[Well, I guess I had to start &#8220;blogging&#8221; eventually&#8230;
Hi, I&#8217;m Amrit, the main CLI (Command Line Interface) and PCL (Python Control Layer) guy here at Splunk.  This means that I maintain our more common bash scripts (bin/splunk &#38; friends), and our Python support scripts (site-packages/splunk/clilib/), which do the heavy lifting for a number of [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I guess I had to start &#8220;blogging&#8221; eventually&#8230;</p>
<p>Hi, I&#8217;m Amrit, the main CLI (Command Line Interface) and PCL (Python Control Layer) guy here at Splunk.  This means that I maintain our more common bash scripts (bin/splunk &#38; friends), and our Python support scripts (site-packages/splunk/clilib/), which do the heavy lifting for a number of CLI &#38; Web UI features.</p>
<p>These aren&#8217;t the only things I work on, but they are the parts of the Splunk codebase that have consumed most of my time since starting here in December 2005.  I should also mention that Ivan Tam (no blog.. yet..?), who now works on the SplunkWeb UI, helped write the first implementation of the PCL during mid-2006.</p>
<p>Every now and then I&#8217;ll post some tips &#38; tricks related to the things I&#8217;m working on, which you&#8217;ll hopefully find useful.</p>
<p>KTHXBAI</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.splunk.com/amrit/2007/07/03/hiweb20/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
