<?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>R.I.Pienaar &#187; mcollective</title>
	<atom:link href="http://www.devco.net/archives/tag/mcollective/feed" rel="self" type="application/rss+xml" />
	<link>http://www.devco.net</link>
	<description>www.devco.net</description>
	<lastBuildDate>Thu, 29 Jul 2010 09:08:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Making machine metadata visible</title>
		<link>http://www.devco.net/archives/2010/07/29/making_machine_meta_data_visible.php</link>
		<comments>http://www.devco.net/archives/2010/07/29/making_machine_meta_data_visible.php#comments</comments>
		<pubDate>Thu, 29 Jul 2010 09:04:07 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1658</guid>
		<description><![CDATA[I&#8217;m quite the fan of data, metadata and querying these to interact with my infrastructure rather than interacting by hostnames and wanted to show how far I am down this route. This is more an iterative ongoing process than a fully baked idea at this point since the concept of hostnames is so heavily embedded [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m quite the fan of data, metadata and querying these to interact with my infrastructure rather than interacting by hostnames and wanted to show how far I am down this route.   </p>
<p>This is more an iterative ongoing process than a fully baked idea at this point since the concept of hostnames is so heavily embedded in our Sysadmin culture.  Today I can&#8217;t yet fully break away from it due to tools like nagios etc still relying heavily on the hostname as the index but these are things that will improve in time.</p>
<p>The background is that in the old days we attempted to capture a lot of metadata in hostnames, domain names and so forth.  This was kind of OK since we had static networks with relatively small amounts of hosts.  Today we do ever more complex work on our servers and we have more and more servers.  The advent of cloud computing has also brought with it a whole new pain of unpredictable hostnames, rapidly changing infrastructures a much bigger emphasis on role based computing.</p>
<p>My metadata about my machines comes from 3 main sources:</p>
<ul>
<li>My Puppet manifests &#8211; classes and modules that gets put on a machine</li>
<li>Facter facts with the ability to add many per machine easily</li>
<li>MCollective stores the meta data in a MongoDB and let me query the network in real time</li>
</ul>
<h2>Puppet manifests based on query</h2>
<p>When setting up machines I keep some data like database master hostnames in extlookup but in many cases I am now moving to a search based approach to finding resources.  Here&#8217;s a sample manifest that will find the master database for a customers development machines:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="puppet" style="font-family:monospace;"><span style="color:#ff6633; font-weight:bold;">$masterdb</span> <span style="color:#006600; font-weight:bold;">=</span> search_nodes<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;{'facts.customer': '${customer}', 'facts.environment':${environment}, classes: 'mysql::master'}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p></code></p>
<p>This is MongoDB query against my infrastructure database, it will find for a given node the name of a node that has the class <em>mysql::master</em> on it, by convention there should be only one per customer in my case.  When using it in a template I can get back full objects with all the meta data for a node.  Hopefully with Puppet 2.6 I can get full hashes into puppet too!</p>
<h2>Making Metadata Visible</h2>
<p>With machines doing a lot of work, filling a lot of roles etc and with more and more machines you need to be able to tell immediately what machine you are on.</p>
<p>I do this in several places, first my MOTD can look something like this:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">   Welcome to Synchronize Your Dogmas 
            hosted at Hetzner, Germany
&nbsp;
        Puppet Modules:
                - apache
                - iptables
                - mcollective member
                - xen dom0 skeleton
                - mw1.xxx.net virtual machine</pre></div></div>

<p></code></p>
<p>I build this up using snippet from my <a href="http://github.com/ripienaar/puppet-concat">concat</a> module, each important module like apache can just put something like this in:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="puppet" style="font-family:monospace;">motd<span style="color:#0066ff; font-weight:bold;">::</span>register<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;Apache Web Server&quot;</span><span style="color:#006600; font-weight:bold;">:</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p></code></p>
<p>Being managed by my snippet library, if you just remove the <em>include</em> line from the manifests the MOTD will automatically update.</p>
<p>With a big block of welcome done, I now need to also be able to show in my prompts what a machine does, who its for a importantly what environment it is in.</p>
<p><center><img src="http://www.devco.net/images/context-prompt.png"></center></p>
<p>Above a shot of 2 prompts in different environments, you see customer name, environment and major modules.  Like with the motd I have a <em>prompt::register</em> define that module use to register into the prompt.</p>
<h2>SSH Based on Metadata</h2>
<p>With all this meta data in place, mcollective rolled out and everything integrated it&#8217;s very easy to now find and access machines based on this.</p>
<p>MCollective does real time resource discovery, so keeping with the mysql example above from puppet:</p>
<p><code></p>
<pre>
$ mc-ssh -W "environment=development customer=acme mysql::master"
Running: ssh db1.acme.net
Last login: Thu Jul 29 00:22:58 2010 from xxxx

$
</pre>
<p></code></p>
<p>Here i am ssh&#8217;ing to a server based on a query, if it found more than one machine matching the query a menu would be presented offering me a choice.</p>
<h2>Monitoring Based on Metatdata</h2>
<p>Finally setting up monitoring and keeping it in sync with reality can be a big challenge especially in dynamic cloud based environments, again I deal with this through discovery based on meta data:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ check-mc-nrpe -W &quot;environment=development customer=acme mysql::master&quot;  check_load
check_load: OK: 1 WARNING: 0 CRITICAL: 0 UNKNOWN: 0|total=1 ok=1 warn=0 crit=0 unknown=0 checktime=0.612054</pre></div></div>

<p></code></p>
<h2>Summary</h2>
<p>This is really the tip of the ice berg, there is a lot more that I already do &#8211; like scheduling puppet runs on groups of machines based on metadata &#8211;  but also a lot more to do this really is early days down this route.  I am very keen to get views from others who is struggling with shortcomings in hostname based approaches and how they deal with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/07/29/making_machine_meta_data_visible.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MCollective Components, Terminology and Flow</title>
		<link>http://www.devco.net/archives/2010/07/28/mcollective_components_terminology_and_flow.php</link>
		<comments>http://www.devco.net/archives/2010/07/28/mcollective_components_terminology_and_flow.php#comments</comments>
		<pubDate>Wed, 28 Jul 2010 08:16:06 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mcollective]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1651</guid>
		<description><![CDATA[I often see some confusion about terminology in use in MCollective, what the major components are, where software needs to be installed etc. I attempted to address this in a presentation and screen cast covering: What middleware is and how we use it. The major components and correct terminology. Anatomy of a request life cycle. [...]]]></description>
			<content:encoded><![CDATA[<p>I often see some confusion about terminology in use in MCollective, what the major components are, where software needs to be installed etc.</p>
<p>I attempted to address this in a presentation and screen cast covering:</p>
<ul>
<li>What middleware is and how we use it.</li>
<li>The major components and correct terminology.</li>
<li>Anatomy of a request life cycle.</li>
<li>And an actual look inside the messages we sent and receive.</li>
</ul>
<p>You can grab the presentation from <a href="http://www.slideshare.net/mcollective/mcollective-message-flow-terminology-and-components">Slideshare</a> or view a video of it on <a href="http://mcollective.blip.tv/file/3935110">blip.tv</a>.  Below find an embedded version of the slideshare deck including audio.  I suggest you view it full screen as there&#8217;s some code in it.</p>
<p><center>
<div style="width:425px" id="__ss_4853323"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/mcollective/mcollective-message-flow-terminology-and-components" title="Architecture, Flow and Terminology">Architecture, Flow and Terminology</a></strong><object id="__sse4853323" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=messageflow-100727191919-phpapp01&#038;stripped_title=mcollective-message-flow-terminology-and-components" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse4853323" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=messageflow-100727191919-phpapp01&#038;stripped_title=mcollective-message-flow-terminology-and-components" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">webinars</a> from <a href="http://www.slideshare.net/mcollective">Marionette Collective</a>.</div>
</div>
<p></center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/07/28/mcollective_components_terminology_and_flow.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bootstrapping Puppet on EC2 with MCollective</title>
		<link>http://www.devco.net/archives/2010/07/14/bootstrapping_puppet_on_ec2_with_mcollective.php</link>
		<comments>http://www.devco.net/archives/2010/07/14/bootstrapping_puppet_on_ec2_with_mcollective.php#comments</comments>
		<pubDate>Tue, 13 Jul 2010 23:10:08 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1592</guid>
		<description><![CDATA[The problem of getting EC2 images to do what you want is quite significant, mostly I find the whole thing a bit flakey and with too many moving parts. When and what AMI to start Once started how to do you configure it from base to functional. Especially in a way that doesn&#8217;t become a [...]]]></description>
			<content:encoded><![CDATA[<p>The problem of getting EC2 images to do what you want is quite significant, mostly I find the whole thing a bit flakey and with too many moving parts.  </p>
<ul>
<li>When and what AMI to start</li>
<li>Once started how to do you configure it from base to functional.  Especially in a way that doesn&#8217;t become a vendor lock.</li>
<li>How do you manage the massive sprawl of instances, inventory them and track your assets</li>
<li>Monitoring and general life cycle management</li>
<li>When and how do you shut them, and what cleanup is needed.  Being billed by the hour means this has to be a consideration</li>
</ul>
<p>These are significant problems and just a tip of the ice berg.  All of the traditional aspects of infrastructure management &#8211; like Asset Management, Monitoring, Procurement &#8211; are totally useless in the face of the cloud.</p>
<p>A lot of work is being done in this space by tools like Pool Party, Fog, Opscode and many other players like the countless companies launching control panels, clouds overlaying other clouds and so forth.  As a keen believer in Open Source many of these options are not appealing.</p>
<p>I want to focus on the 2nd step above here today and show how I pulled together a number of my Open Source projects to automate that.   I built a generic provisioner that hopefully is expandable and usable in your own environments.  The provisioner deals with all the interactions between Puppet on nodes, the Puppet Master, the Puppet CA and the administrators.</p>
<p>&lt;rant&gt; Sadly the activity in the Puppet space is a bit lacking in the area of making it really easy to get going on a cloud.  There are suggestions on the level of monitoring syslog files from a cronjob and signing certificates based on that.  Really.   It&#8217;s a pretty sad state of affairs when that&#8217;s the state of the art.</p>
<p>Compare the ease of using <a href="http://www.opscode.com/blog/2010/03/24/amazon-ec2-amis-for-ubuntu-9-10-and-chef-0-8-8/">Chef&#8217;s Knife</a> with a lot of the suggestions currently out there for using Puppet in EC2 like these: <a href="http://ubuntumathiaz.wordpress.com/2010/03/24/using-puppet-in-uecec2-puppet-support-in-ubuntu-images/">1</a>, <a href="https://wiki.ubuntu.com/PuppetUECEC2Integration">2</a>, <a href="http://agiletesting.blogspot.com/2009/09/bootstrapping-ec2-images-as-puppet.html">3</a> and <a href="http://ubuntumathiaz.wordpress.com/2010/03/25/using-puppet-in-uecec2-automating-the-signing-process/">4</a>.</p>
<p>Not trying to have a general Puppet Bashing session here but I think it&#8217;s quite defining of the 2 user bases that Cloud readiness is such an after thought so far in Puppet and its community.  &lt;/rant&gt;</p>
<p>My basic needs are that instances all start in the same state, I just want 1 base AMI that I massage into the desired final state.  Most of this work has to be done by Puppet so it&#8217;s repeatable.  Driving this process will be done by MCollective.</p>
<p>I bootstrap the EC2 instances using my <a href="http://www.devco.net/archives/2010/07/12/ec2_bootstrap_helper.php">EC2 Bootstrap Helper</a> and I use that to install MCollective with just a <em>provision</em> agent.  It configures it and hook it into my collective.</p>
<p>From there I have the following steps that need to be done:</p>
<ul>
<li>Pick a nearby Puppet Master, perhaps using EC2 Region or country as guides</li>
<li>Set up the host &#8211; perhaps using <em>/etc/hosts</em> &#8211; to talk to the right master</li>
<li>Revoke and clean any old certs for this hostname on all masters</li>
<li>Instruct the node to create a new CSR and send it to its master</li>
<li>Sign the certificate</li>
<li>Run my initial bootstrap Puppet environment, this sets up some hard to do things like facts my full build needs</li>
<li>Run the final Puppet run in my normal production environment.</li>
<li>Notify me using XMPP, Twitter, Google Calendar, Email, Boxcar and whatever else I want of the new node</li>
</ul>
<p>This is a lot of work to be done on every node.  And more importantly it&#8217;s a task that involves many other nodes like puppet masters, notifiers and so forth.  It has to adapt dynamically to your environment and not need reconfiguring when you get new Puppet Masters.  It has to deal with new data centers, regions and countries without needing any configuration or even a restart.  It has to happen automatically without any user interaction so that your auto scaling infrastructure can take care of booting new instances even while you sleep.</p>
<p>The provisioning system I wrote does just this.  It follows the above logic for any new node and is configurable for which facts to use to pick a master and how to notify you of new systems.  It adapts automatically to your ever changing environments thanks to discovery of resources.  The actions to perform on the node are easily pluggable by just creating an agent that complies to the <a href="http://github.com/ripienaar/mcollective-server-provisioner/blob/master/agent/provision.ddl">published DDL</a> like the <a href="http://github.com/ripienaar/mcollective-server-provisioner/blob/master/agent/provision.rb">sample agent</a>.</p>
<p>You can see it in action in the video below.  I am using Amazon&#8217;s console to start the instance, you&#8217;d absolutely want to automate that for your needs.   You can also see it direct on blip.tv <a href="http://mcollective.blip.tv/file/3876576/">here</a>.  For best effect &#8211; and to be able to read the text &#8211; please fullscreen.</p>
<p><center><embed src="http://blip.tv/play/hfMOge3ibQA" type="application/x-shockwave-flash" width="640" height="417" allowscriptaccess="always" allowfullscreen="true"></embed></center></p>
<p>In case the text is unreadable in the video a log file similar to the one in the video can be seen <a href="http://www.devco.net/code/mcollective-provisioner-log.txt">here</a> and an example config <a href="http://github.com/ripienaar/mcollective-server-provisioner/blob/master/etc/provisioner.yaml">here</a></p>
<p>Past this point my Puppet runs are managed by <a href="http://www.devco.net/archives/2010/03/17/scheduling_puppet_with_mcollective.php">my MCollective Puppet Scheduler</a>.</p>
<p>While this is all done using EC2 nothing prevents you from applying these same techniques to your own data center or non cloud environment.  </p>
<p>Hopefully this shows that you can wrap all the logic needed to do very complex interactions with systems that are perhaps not known for their good reusable API&#8217;s in simple to understand wrappers with MCollective, exposing those systems to the network at large with APIs that can be used to reach your goals.</p>
<p>The various bits of open source I used here are:</p>
<ul>
<li><a href="http://mcollective.googlecode.com/">MCollective</a></li>
<li><a href="http://www.devco.net/archives/2010/07/12/ec2_bootstrap_helper.php">EC2 Bootstrap</a> helper on CentOS 5.5</li>
<li>The <a href="http://github.com/ripienaar/mcollective-server-provisioner">MCollective Server Provisioner</a></li>
<li>The sample <a href="http://github.com/ripienaar/mcollective-server-provisioner/blob/master/agent/provision.rb">provisioner agent</a></li>
<li>My <a href="http://code.google.com/p/nagger/">Nagger notification framework</a> with it&#8217;s XMPP plugin</li>
<li>The <a href="http://github.com/ripienaar/mcollective-plugins/tree/master/agent/naggernotify/">Naggernotify</a> MCollective Agent</li>
<li>The <a href="http://github.com/ripienaar/mcollective-plugins/tree/master/agent/puppetca/">Puppet CA</a> Mcollective Agent</li>
<li><a href="http://www.puppetlabs.com/">Puppet and Facter</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/07/14/bootstrapping_puppet_on_ec2_with_mcollective.php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Puppet resources on demand with MCollective</title>
		<link>http://www.devco.net/archives/2010/07/07/puppet_resources_on_demand.php</link>
		<comments>http://www.devco.net/archives/2010/07/07/puppet_resources_on_demand.php#comments</comments>
		<pubDate>Wed, 07 Jul 2010 16:55:36 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1565</guid>
		<description><![CDATA[Some time ago I wrote how to reuse Puppet providers in your Ruby script, I&#8217;ll take that a bit further here and show you to create any kind of resource. Puppet works based on resources and catalogs. A catalog is a collection of resources and it will apply the catalog to a machine. So in [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I wrote how to <a href="http://www.devco.net/archives/2009/10/19/reusing_puppet_providers.php">reuse Puppet providers</a> in your Ruby script, I&#8217;ll take that a bit further here and show you to create any kind of resource.</p>
<p>Puppet works based on resources and catalogs.  A catalog is a collection of resources and it will apply the catalog to a machine.  So in order to do something you can do as before and call the type&#8217;s methods directly but if you wanted to build up a resource and say &#8216;just do it&#8217; then you need to go via a catalog.</p>
<p>Here&#8217;s some code, I don&#8217;t know if this is the best way to do it, I dug around the code for <em>ralsh</em> to figure this out:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">params = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;rip&quot;</span>,
           <span style="color:#ff3333; font-weight:bold;">:comment</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;R.I.Pienaar&quot;</span>,
           <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'......'</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
pup = <span style="color:#6666ff; font-weight:bold;">Puppet::Type</span>.<span style="color:#9900CC;">type</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
catalog = <span style="color:#6666ff; font-weight:bold;">Puppet::Resource::Catalog</span>.<span style="color:#9900CC;">new</span>
catalog.<span style="color:#9900CC;">add_resource</span> pup
catalog.<span style="color:#9900CC;">apply</span></pre></div></div>

<p></code></p>
<p>That&#8217;s really simple and doesn&#8217;t require you to know much about the inner workings of a type, you&#8217;re just mapping the normal Puppet manifest to code and applying it.  Nifty.</p>
<p>The natural progression &#8211; to me anyway &#8211; is to put this stuff into a <a href="http://github.com/ripienaar/mcollective-plugins/blob/master/agent/puppetral/puppetral.rb">MCollective agent</a> and build a distributed <em>ralsh</em>.</p>
<p>Here&#8217;s a sample use case, I wanted to change my users password everywhere:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ mc-rpc puppetral do type=user name=rip password='$1$xxx'</pre></div></div>

<p></code></p>
<p>And that will go out, find all my machines and use the Puppet RAL to change my password for me.  You can do anything puppet can, manage <em>/etc/hosts</em>, add users, remove users, packages, services and anything even your own custom types can be used.   Distributed and in parallel over any number of hosts.</p>
<p>Some other examples:</p>
<p>Add a user:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ mc-rpc puppetral do type=user name=foo comment=&quot;Foo User&quot; managehome=true</pre></div></div>

<p></code></p>
<p>Run a command using exec, with the magical <em>creates</em> option:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ mc-rpc puppetral do type=exec name=&quot;/bin/date &gt; /tmp/date&quot; user=root timeout=5 creates=&quot;/tmp/date&quot;</pre></div></div>

<p></code></p>
<p>Add an aliases entry:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ mc-rpc puppetral do type=mailalias name=foo recipient=&quot;rip@devco.net&quot; target=&quot;/etc/aliases&quot;</pre></div></div>

<p></code></p>
<p>Install a package:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ mc-rpc puppetral do type=package name=unix2dos ensure=present</pre></div></div>

<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/07/07/puppet_resources_on_demand.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aggregating Nagios Checks With MCollective</title>
		<link>http://www.devco.net/archives/2010/07/03/aggregating_nagios_checks_with_mcollective.php</link>
		<comments>http://www.devco.net/archives/2010/07/03/aggregating_nagios_checks_with_mcollective.php#comments</comments>
		<pubDate>Sat, 03 Jul 2010 15:12:00 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[monitoring]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1532</guid>
		<description><![CDATA[A very typical scenario I come across on many sites is the requirement to monitor something like Puppet across 100s or 1000s of machines. The typical approaches are to add perhaps a central check on your puppet master or to check using NRPE or NSCA on every node. For this example the option exist to [...]]]></description>
			<content:encoded><![CDATA[<p>A very typical scenario I come across on many sites is the requirement to monitor something like Puppet across 100s or 1000s of machines.</p>
<p>The typical approaches are to add perhaps a central check on your puppet master or to check using NRPE or NSCA on every node.  For this example the option exist to easily check on the master and get one check but that isn&#8217;t always easily achievable.  </p>
<p>Think for example about monitoring mail queues on all your machines to make sure things like root mail isn&#8217;t getting stuck.   In those cases you are forced to do per node checks which inevitably result in huge notification storms in the event that your mail server was down and not receiving the mail from the many nodes.</p>
<p><a href="http://mcollective.googlecode.com/">MCollective</a> has had <a href="http://code.google.com/p/mcollective-plugins/wiki/AgentNRPE">a plugin that can run NRPE commands</a> for a long time, I&#8217;ve now added a nagios plugin using this agent to combine results from many hosts.</p>
<p>Sticking with the Puppet example, here are my needs:</p>
<ul>
<li>I want to know if anywhere some puppet machine isn&#8217;t successfully doing runs.</li>
<li>I want to be able to do <em>puppetd &#8211;disable</em> and not get alerts for those machines.</li>
<li>I do not want to change any configs when I am adding new machines, it should just work.</li>
<li>I want the ability to do monitoring on subsets of machines on different probes</li>
</ul>
<p>This is a pretty painful set of requirements for nagios on its own to achieve.  Easy with the help of MCollective.</p>
<p>Ultimately, I just want this:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">OK: 42 WARNING: 0 CRITICAL: 0 UNKNOWN: 0</pre></div></div>

<p></code></p>
<p>Meaning 42 machines &#8211; only ones currently enabled &#8211; are all running happily.</p>
<h2>The NRPE Check</h2>
<p>We put the NRPE logic on every node.  A simple check command in <em>/etc/nagios/nrpe.d/check_puppet_run.cfg</em>:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">command[check_puppet_run]=/usr/lib/nagios/plugins/check_file_age -f /var/lib/puppet/state/state.yaml -w 5400 -c 7200</pre></div></div>

<p></code></p>
<p>In my case I just want to know there are successful runs happening, if I wanted to know the code is actually compiling correctly I&#8217;d monitor the local cache age and size.</p>
<h2>Determining if Puppet is enabled or not</h2>
<p>Currently this is a bit hacky, I&#8217;ve filed tickets with Puppet Labs to improve this.  The way to determine if puppet is disabled is to check if the lock file exist and if its 0 bytes.  If it&#8217;s not zero bytes it means a <em>puppetd</em> is currently doing a run &#8211; there will be a pid in it.  Or the <em>puppetd</em> crashed and there&#8217;s a stale pid preventing other runs.  </p>
<p>To automate this and integrate into MCollective I&#8217;ve made a fact <a href="http://github.com/ripienaar/facter-facts/tree/master/puppet-enabled/">puppet_enabled</a>.  We&#8217;ll use this in MCollective discovery to only monitor machines that are enabled.  Get this onto all your nodes perhaps using <a href="http://docs.reductivelabs.com/guides/plugins_in_modules.html">Plugins in Modules</a>.</p>
<h2>The MCollective Agent</h2>
<p>You want to deploy the <a href="http://code.google.com/p/mcollective-plugins/wiki/AgentNRPE">MCollective NRPE Agent</a> to all your nodes, once you&#8217;ve got it right you can test it easily using something like this:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">% mc-nrpe -W puppet_enabled=1 check_puppet_run
&nbsp;
 * [ ============================================================&gt; ] 47 / 47
&nbsp;
Finished processing 47 / 47 hosts in 395.51 ms
              OK: 47
         WARNING: 0
        CRITICAL: 0
         UNKNOWN: 0</pre></div></div>

<p></code></p>
<p>Note we&#8217;re restricting the run to only enabled hosts.</p>
<h2>Integrating into Nagios</h2>
<p>The last step is to add this to nagios.  I create SSL certs and a specific client configuration for Nagios and put these in it&#8217;s home directory.</p>
<p>The <em>check-mc-nrpe</em> plugin works best with Nagios 3 as it will return subsequent lines of output indicating which machines are in what state so you get the details hidden behind the aggregation in alerts.  It also outputs performance data for total node, each status and also how long it took to do the check.</p>
<p>The nagios command would be something like this:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">define command{
        command_name                    check_mc_nrpe
        command_line                    /usr/sbin/check-mc-nrpe  --config /var/log/nagios/.mcollective/client.cfg  -W $ARG1$ $ARG2$
}</pre></div></div>

<p></code></p>
<p>And finally we need to make a service:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">define service{
        host_name                       monitor1
        service_description             mc_puppet-run
        use                             generic-service
        check_command                   check_mc_nrpe!puppet_enabled=1!check_puppet_run
        notification_period             awakehours
        contact_groups                  sysadmin
}</pre></div></div>

<p></code></p>
<p>Here are a few other command examples I use:</p>
<p>All machines with my Puppet class &#8220;pki&#8221;, check the age of certs:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">check_command   check_mc_nrpe!pki!check_pki</pre></div></div>

<p></code></p>
<p>All machines with my Puppet class &#8220;bacula::node&#8221;, make sure the FD is running:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">check_command   check_mc_nrpe!bacula::node!check_fd</pre></div></div>

<p></code></p>
<p>&#8230;and that they were backed up:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">check_command   check_mc_nrpe!bacula::node!check_bacula_main</pre></div></div>

<p></code></p>
<p>Using this I removed 100s of checks from my monitoring platform, saving on resources and making sure I can do my critical monitor tasks better.</p>
<p>Depending on the quality of your monitoring system you might even get a graph showing the details hidden behind the aggregation:</p>
<p><center><img src="http://www.devco.net/images/mcbacula.png"></center></p>
<p>The above is a graph showing a series of servers where the backup ran later than usual, I had 2 alerts only, would have had more than 30 before aggregation.</p>
<p></p>
<h2>Restrictions for Probes</h2>
<p>The last remaining requirement I had was to be able to do checks on different probes and restrict them.  My Collective is one big one spread all over the world which means sometimes things are a bit slow discovery wise.  </p>
<p>So I have many nagios servers doing local checks.  Using MCollective discovery I can now easily restrict checks, for example If I only wanted to check machines in the USA and I had a fact <em>country</em> I only have to change my command line in the service declaration:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">check_command   check_mc_nrpe!puppet_enabled=1 country=us!check_puppet_run</pre></div></div>

<p></code></p>
<p>This will then via MCollective discovery just monitor machines in the US.</p>
<h2>What to monitor this way</h2>
<p>As this style of monitoring is done using Discovery you would need to think carefully about what you monitor this way.  It&#8217;s totally conceivable that if a node is under high CPU load that it wont respond to discovery commands in time, and so wont get monitored!</p>
<p>You would then for example not want to monitor things like load averages or really critical services this way, but we all have a lot of peripheral things like zombie process counts and a lot of other places where aggregation makes a lot of sense, in those cases by all means consider this approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/07/03/aggregating_nagios_checks_with_mcollective.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: Writing MCollective Agents</title>
		<link>http://www.devco.net/archives/2010/06/27/tutorial_writing_mcollective_agents.php</link>
		<comments>http://www.devco.net/archives/2010/06/27/tutorial_writing_mcollective_agents.php#comments</comments>
		<pubDate>Sun, 27 Jun 2010 15:41:28 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1495</guid>
		<description><![CDATA[I&#8217;ve recorded a screencast that walks you through the process of developing a SimpleRPC Agent, give it a DDL and also a simple client to communicate with it. The tutorial creates a small echo agent that takes input and return it unmodified. It validates that you are sending a string and has a sample of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recorded a screencast that walks you through the process of developing a SimpleRPC Agent, give it a DDL and also a simple client to communicate with it.</p>
<p><center><embed src="http://blip.tv/play/hfMOgenSZAA" type="application/x-shockwave-flash" width="560" height="360" allowscriptaccess="always" allowfullscreen="true"></embed></center></p>
<p>The tutorial creates a small echo agent that takes input and return it unmodified.  It validates that you are sending a string and has a sample of dealing with intermittent failure.</p>
<p>Once you&#8217;ve watched this, or even during, you can use the following links are reference material:  <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCAgents">Writing Agents</a>, <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCDDL">Data Definition Language</a> and <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCClients">Writing Clients</a>.</p>
<p>You can view it <a href="http://mcollective.blip.tv/file/3808928">directly on blip.tv</a> which will hopefully be better quality.</p>
<p>I used a few VIM Snippets during the demo to boilerplate the agent and DDL, you&#8217;ll find these in the tarball for the upcoming <em>0.4.7</em> release in the <em>ext/vim</em> directory, they are already on GitHub too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/06/27/tutorial_writing_mcollective_agents.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MCollective Data Definition Language</title>
		<link>http://www.devco.net/archives/2010/06/25/mcollective_data_definition_language.php</link>
		<comments>http://www.devco.net/archives/2010/06/25/mcollective_data_definition_language.php#comments</comments>
		<pubDate>Thu, 24 Jun 2010 23:08:03 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mcollective]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1488</guid>
		<description><![CDATA[I mentioned in my recent post about mcollective Road Map about the DDL. The DDL is used to describe agents in a way that is accessible by other programs, web applications, client libraries and so forth to help those various client tools to configure themselves correctly. An actual example of a DDL file can be [...]]]></description>
			<content:encoded><![CDATA[<p>I mentioned in my <a href="http://www.devco.net/archives/2010/06/14/recent_mcollective_releases_and_roadmap.php">recent post about mcollective Road Map</a> about the <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCDDL">DDL</a>.  </p>
<p>The DDL is used to describe agents in a way that is accessible by other programs, web applications, client libraries and so forth to help those various client tools to configure themselves correctly.</p>
<p>An actual example of a DDL file can be found <a href="http://github.com/ripienaar/mcollective-plugins/blob/master/agent/puppetca/puppetca.ddl">here</a> if you want to have a good look at it and full docs <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCDDL">here</a>.</p>
<p>I&#8217;ve created a short video showing the DDL and some of the features of the upcoming 0.4.7 release,  you probably want to view it full screen to really see what&#8217;s going on.</p>
<p><center><embed src="http://blip.tv/play/AYHpijQA" type="application/x-shockwave-flash" width="560" height="369" allowscriptaccess="always" allowfullscreen="true"></embed></center></p>
<p>And a quick note about the colors, I know people tend to feel strongly about this kind of thing, you can disable them in the config file of the client <img src='http://www.devco.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This is also my first attempt at using blip.tv, please let me know if you see any problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/06/25/mcollective_data_definition_language.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recent MCollective releases and roadmap.</title>
		<link>http://www.devco.net/archives/2010/06/14/recent_mcollective_releases_and_roadmap.php</link>
		<comments>http://www.devco.net/archives/2010/06/14/recent_mcollective_releases_and_roadmap.php#comments</comments>
		<pubDate>Mon, 14 Jun 2010 08:44:14 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1472</guid>
		<description><![CDATA[I&#8217;ve had two successive Marionette Collective releases recently, I was hoping to have one big one but I was waiting for the Stomp maintainers to do a release and it was taking a while. These two releases are both major feature releases covering major feature sets. See lower down for a breakdown of it all. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had two successive <a href="http://code.google.com/p/mcollective/">Marionette Collective</a> releases recently, I was hoping to have one big one but I was waiting for the Stomp maintainers to do a release and it was taking a while.</p>
<p>These two releases are both major feature releases covering major feature sets.  See lower down for a breakdown of it all.</p>
<p>We&#8217;re nearing feature completeness for the <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCIntroduction">SimpleRPC</a> layer as I am adding a number of features of interest to Enterprise and Large users especially around security and web UIs.  </p>
<p>Once we&#8217;re at the end of this cycle I&#8217;ll do a 1.0.0 release and then from there move onto the next major feature cycle.  The next cycle will focus on queuing long running tasks, background scheduling, future scheduling of tasks and a lot of related work.  I <a href="http://groups.google.com/group/mcollective-users/msg/35edb9a3fbca3de0">posted some detail</a> about these plans to the list recently.</p>
<p>Over the new few days or weeks I&#8217;ll do a number of Screencasts exploring some of these new features in depth, for now the list of what&#8217;s new:</p>
<h2>Security</h2>
<ul>
<li>New <a href="http://code.google.com/p/mcollective/wiki/SSLSecurityPlugin">SSL based security system</a></li>
<li>New <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCAuthorization">Authorization system</a> [<a href="http://www.devco.net/archives/2010/04/11/authorization_plugins_for_mcollective_simplerpc.php">blog post</a>] and sample plugins, allowing for fine grained control over every request</li>
</ul>
<h2>Connectivity</h2>
<p>We can use Ruby Gem Stomp 1.1.6 which brings a lot of enhancements:</p>
<ul>
<li><a href="http://code.google.com/p/mcollective/wiki/ConnectorStomp">Connection pools for failover</a> between multiple ActiveMQs</li>
<li>Lots of tunables about the connection pools such as retry frequencies etc</li>
<li>SSL TLS between node and ActiveMQ</li>
</ul>
<h2>Writing Web and Dynamic UIs</h2>
<ul>
<li>A <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCDDL">DDL that describes agents</a>, inputs and outputs:</li>
<ul>
<li>Creates auto generated documentation</li>
<li>Can be used to auto generate user interfaces</li>
<li>The client library will only make requests that validate against the DDL</li>
<li>In future input validations will move into the DDL and will be done automatically for you</li>
</ul>
<li>Web UI&#8217;s can <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCClients#Doing_your_own_discovery">bypass or do their own discovery</a> and use the DDL to auto generate user interfaces</li>
</ul>
<h2>Usability</h2>
<ul>
<li><a href="http://code.google.com/p/mcollective/wiki/SimpleRPCClients#Sending_SimpleRPC_requests_without_discovery_and_blocking">Fire-and-Forget</a> style requests, for when you just want something done but do not care about results, these requests are very quick as they do not do any discovery.</li>
<li>Agents can now be reloaded without restarting the daemon</li>
<li>A new <em>mc-inventory</em> tool that can be used to view facts, agents and classes for a node</li>
<li>Many UI enhancements to the CLI tools</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/06/14/recent_mcollective_releases_and_roadmap.php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MCollective pgrep</title>
		<link>http://www.devco.net/archives/2010/05/23/mcollective_pgrep.php</link>
		<comments>http://www.devco.net/archives/2010/05/23/mcollective_pgrep.php#comments</comments>
		<pubDate>Sun, 23 May 2010 13:19:49 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1463</guid>
		<description><![CDATA[The unix pgrep utility is great, it lets you grep through your process list and find interesting things. I wanted to do something similar but for my entire server group so built something quick ontop of MCollective. I am using the Ruby sys-proctable gem to do the hard work, it returns a massive amount of [...]]]></description>
			<content:encoded><![CDATA[<p>The unix pgrep utility is great, it lets you grep through your process list and find interesting things.  I wanted to do something similar but for my entire server group so built something quick ontop of MCollective.</p>
<p>I am using the Ruby <a href="http://raa.ruby-lang.org/project/sys-proctable/">sys-proctable</a> gem to do the hard work, it returns a massive amount of information about each process and have written a simple agent on top of this.</p>
<p>The agent supports grepping the process tree but also supports kill and pgre+kill though I have not yet implemented more than the basic grep on the command line.  Frankly the grep+kill combination scares me and I might remove it.  A simple grep slipup and you will kill all processes on all your machine <img src='http://www.devco.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Sometimes too much power is too much and should just be avoided.</p>
<p>At the moment mc-pgrep outputs a set format but I intend to make that configurable on the command line, here&#8217;s a sample:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> mc-pgrep <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>dev_server<span style="color: #000000; font-weight: bold;">/</span> ruby
&nbsp;
 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> ============================================================<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">4</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000;">4</span>
&nbsp;
dev1.my.com
       root   <span style="color: #000000;">9833</span>  ruby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>mcollectived <span style="color: #660033;">--pid</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mcollectived.pid 
       root  <span style="color: #000000;">21608</span>  <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.2<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>phusion_pass
&nbsp;
dev2.my.com
       root  <span style="color: #000000;">14568</span>  <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.2<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>phusion_pass
       root  <span style="color: #000000;">31595</span>  ruby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>mcollectived <span style="color: #660033;">--pid</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mcollectived.pid 
&nbsp;
dev3.my.com
       root   <span style="color: #000000;">1620</span>  <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.2<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>phusion_pass
       root  <span style="color: #000000;">14093</span>  ruby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>mcollectived <span style="color: #660033;">--pid</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mcollectived.pid 
&nbsp;
dev4.my.com
       root   <span style="color: #000000;">3231</span>  <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.2<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>phusion_pass
       root  <span style="color: #000000;">20557</span>  ruby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>mcollectived <span style="color: #660033;">--pid</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mcollectived.pid 
&nbsp;
   <span style="color: #660033;">----</span> process list stats <span style="color: #660033;">----</span>
        Matched hosts: <span style="color: #000000;">4</span>
    Matched processes: <span style="color: #000000;">8</span>
        Resident Size: 37.264KB
         Virtual Size: 629.578MB</pre></div></div>

<p></code></p>
<p>You can also limit it to only find zombies with the <i>-z</i> option.</p>
<p>This has been quite interesting for me, if I limit the pgrep to &#8220;.&#8221; (the pattern is regex) every machine will send back a Sys::ProcTable hash for all its processes.  This is a 50 to 70 KByte payload per server.  I&#8217;ve so far seen no problem getting his much traffic through ActiveMQ + MCollective and processing it all in a very short time:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">time</span> mc-pgrep <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;country=/uk|us/&quot;</span> .
&nbsp;
   <span style="color: #660033;">----</span> process list stats <span style="color: #660033;">----</span>
        Matched hosts: <span style="color: #000000;">20</span>
    Matched processes: <span style="color: #000000;">1958</span>
        Resident Size: 1.777MB
         Virtual Size: 60.072GB
&nbsp;
mc-pgrep <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;country=/uk|us/&quot;</span> .  0.19s user 0.06s system <span style="color: #000000;">7</span><span style="color: #000000; font-weight: bold;">%</span> cpu <span style="color: #000000;">3.420</span> total</pre></div></div>

<p></code></p>
<p>That 3.4 seconds is with a 2 second discovery overhead client machine in Germany and the filter matching UK and US machines &#8211; all the way to the West Coast &#8211; my biggest delay here is network and not MC or ActiveMQ.</p>
<p>The code can be found at my <a href="http://github.com/ripienaar/mcollective-plugins/tree/master/agent/process/">GitHub account</a> and still a bit of a work in progress, wiki pages will follow once I am happy with it.</p>
<p>And as an aside, I am slowly migrating at least my code to GitHub if not wiki and ticketing.  So far my Plugins have moved, MC will move soon too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/05/23/mcollective_pgrep.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xen Live Migration with MCollective</title>
		<link>http://www.devco.net/archives/2010/04/14/xen_live_migration_with_mcollective.php</link>
		<comments>http://www.devco.net/archives/2010/04/14/xen_live_migration_with_mcollective.php#comments</comments>
		<pubDate>Wed, 14 Apr 2010 09:50:04 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[mcollective]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1419</guid>
		<description><![CDATA[I retweeted this on twitter, but it&#8217;s just too good to not show. Over at rottenbytes.com Nicolas is showing some proof of concept code he wrote with MCollective that monitors the load on his dom0 machines and initiate live migrations of virtual machines to less loaded servers. This is the kind of crazy functionality I [...]]]></description>
			<content:encoded><![CDATA[<p>I retweeted this on twitter, but it&#8217;s just too good to not show.  <a href="http://www.rottenbytes.info/?p=291">Over at rottenbytes.com</a> Nicolas is showing some proof of concept code he wrote with <a href="http://code.google.com/p/mcollective/">MCollective</a> that monitors the load on his dom0 machines and initiate live migrations of virtual machines to less loaded servers.</p>
<p>This is the kind of crazy functionality I wanted to enable with MCollective and it makes me very glad to see this kind of thing.  The server side and client code combined is only 230 lines &#8211; very very impressive.</p>
<p>This is a part of what VMWare DRS does Nico has some ideas to add other sexy features as well as this was just a proof of concept.  The logic for what to base migrations on will be driven by a small DSL for example.</p>
<p>I asked him how long it took to knock this together: time taken to get acquainted with MCollective combined with time to write the agent and client was only 2 days, that&#8217;s very impressive.  He already knew Ruby well though <img src='http://www.devco.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   And has a Ruby gem to integrate with Xen.</p>
<p>I&#8217;m copying the output from his code below, but <a href="http://www.rottenbytes.info/?p=291">absolutely head over to his blog to check it out</a> he has the source up there too:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[mordor:~] ./mc-xen-balancer
[+] hypervisor2 : 0.0 load and 0 slice(s) running
[+] init/reset load counter for hypervisor2
[+] hypervisor2 has no slices consuming CPU time
[+] hypervisor3 : 1.11 load and 3 slice(s) running
[+] added test1 on hypervisor3 with 0 CPU time (registered 18.4 as a reference)
[+] added test2 on hypervisor3 with 0 CPU time (registered 19.4 as a reference)
[+] added test3 on hypervisor3 with 0 CPU time (registered 18.3 as a reference)
[+] sleeping for 30 seconds
&nbsp;
[+] hypervisor2 : 0.0 load and 0 slice(s) running
[+] init/reset load counter for hypervisor2
[+] hypervisor2 has no slices consuming CPU time
[+] hypervisor3 : 1.33 load and 3 slice(s) running
[+] updated test1 on hypervisor3 with 0.0 CPU time eaten (registered 18.4 as a reference)
[+] updated test2 on hypervisor3 with 0.0 CPU time eaten (registered 19.4 as a reference)
[+] updated test3 on hypervisor3 with 1.5 CPU time eaten (registered 19.8 as a reference)
[+] sleeping for 30 seconds
&nbsp;
[+] hypervisor2 : 0.16 load and 0 slice(s) running
[+] init/reset load counter for hypervisor2
[+] hypervisor2 has no slices consuming CPU time
[+] hypervisor3 : 1.33 load and 3 slice(s) running
[+] updated test1 on hypervisor3 with 0.0 CPU time eaten (registered 18.4 as a reference)
[+] updated test2 on hypervisor3 with 0.0 CPU time eaten (registered 19.4 as a reference)
[+] updated test3 on hypervisor3 with 1.7 CPU time eaten (registered 21.5 as a reference)
[+] hypervisor3 has 3 threshold overload
[+] Time to see if we can migrate a VM from hypervisor3
[+] VM key : hypervisor3-test3
[+] Time consumed in a run (interval is 30s) : 1.7
[+] hypervisor2 is a candidate for being a host (step 1 : max VMs)
[+] hypervisor2 is a candidate for being a host (step 2 : max load)
trying to migrate test3 from hypervisor3 to hypervisor2 (10.0.0.2)
Successfully migrated test3 !</pre></div></div>

<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/04/14/xen_live_migration_with_mcollective.php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
