<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ganglia — Bcfg2 1.3.0 documentation</title> <link rel="stylesheet" href="../../../../../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../../../../', VERSION: '1.3.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../../../../_static/jquery.js"></script> <script type="text/javascript" src="../../../../../_static/underscore.js"></script> <script type="text/javascript" src="../../../../../_static/doctools.js"></script> <script type="text/javascript" src="../../../../../_static/sidebar.js"></script> <link rel="shortcut icon" href="../../../../../_static/favicon.ico"/> <link rel="top" title="Bcfg2 1.3.0 documentation" href="../../../../../index.html" /> <link rel="up" title="TGenshi" href="../../tgenshi.html" /> <link rel="next" title="grub.conf" href="grubconf.html" /> <link rel="prev" title="clients.xml" href="clientsxml.html" /> <link rel="stylesheet" href="../../../../../_static/bcfg2.css" type=""/> </head> <body> <div style="text-align: left; padding: 10px 10px 15px 15px"> <a href="../../../../../index.html"><img src="../../../../../_static/bcfg2_logo.png" border="0" alt="sampledoc"/></a> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../../../../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../../../../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="grubconf.html" title="grub.conf" accesskey="N">next</a> |</li> <li class="right" > <a href="clientsxml.html" title="clients.xml" accesskey="P">previous</a> |</li> <li><a href="../../../../../index.html">home</a> | </li> <!--<li><a href="../../../../../search.html">search</a> | </li>--> <li><a href="../../../../../help/index.html">help</a> | </li> <li><a href="../../../../../contents.html">documentation </a> »</li> <li><a href="../../../../../contents.html" >Bcfg2 documentation 1.3.0</a> »</li> <li><a href="../../../../index.html" >The Bcfg2 Server</a> »</li> <li><a href="../../../index.html" >Plugins</a> »</li> <li><a href="../../tgenshi.html" accesskey="U">TGenshi</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="ganglia"> <h1>ganglia<a class="headerlink" href="#ganglia" title="Permalink to this headline">¶</a></h1> <p>Another interesting example of Genshi templating is to automatically generate <tt class="docutils literal"><span class="pre">gmond</span></tt>/<tt class="docutils literal"><span class="pre">gmetad</span></tt> configuration files. The idea is that each cluster is headless: it communicates with the rest of the cluster members on an isolated multicast IP address and port. Any of the cluster members is therefore isolated on that particular ip/port pair. Additionally, each <tt class="docutils literal"><span class="pre">gmond</span></tt> instance <strong>also</strong> listens on UDP. This allows for any of the cluster members to be polled for information on the entire cluster!</p> <p>The second part of the trick is in <tt class="docutils literal"><span class="pre">gmetad.conf</span></tt>. Here, we dynamically generate a list of clusters (based on profiles names) and a list of members to poll (based on the clients in said profiles). As the number of profiles and client grows, this list will grow automatically as well. When a new host is added, <tt class="docutils literal"><span class="pre">gmetad</span></tt> will receive an updated configuration and act accordingly.</p> <p>There <strong>is</strong> one caveat though. The <tt class="docutils literal"><span class="pre">gmetad.conf</span></tt> parser is hard coded to read 16 arguments per <tt class="docutils literal"><span class="pre">data_source</span></tt> line. If you have more than 15 nodes in a cluster, you will see a warning in the logs. You can either ignore it, or truncate the list to the first 15 members.</p> <p>In our environment, a profile is a one to one match with the role of that particular host. You can also do this based on groups, or any other client property.</p> <div class="section" id="bundler-ganglia-xml"> <h2>Bundler/ganglia.xml<a class="headerlink" href="#bundler-ganglia-xml" title="Permalink to this headline">¶</a></h2> <div class="highlight-xml"><div class="highlight"><pre><span class="nt"><Bundle</span> <span class="na">name=</span><span class="s">'ganglia'</span><span class="nt">></span> <span class="nt"><Package</span> <span class="na">name=</span><span class="s">'ganglia-gmond'</span> <span class="nt">/></span> <span class="nt"><Package</span> <span class="na">name=</span><span class="s">'ganglia-gmond-modules-python'</span> <span class="nt">/></span> <span class="nt"><Path</span> <span class="na">name=</span><span class="s">'/etc/ganglia/gmond.conf'</span> <span class="nt">/></span> <span class="nt"><Service</span> <span class="na">name=</span><span class="s">'gmond'</span> <span class="nt">/></span> <span class="nt"><Action</span> <span class="na">name=</span><span class="s">'gmond-reload'</span> <span class="nt">/></span> <span class="nt"><Group</span> <span class="na">name=</span><span class="s">'gmetad-server'</span><span class="nt">></span> <span class="nt"><Package</span> <span class="na">name=</span><span class="s">'ganglia-gmetad'</span><span class="nt">/></span> <span class="nt"><Package</span> <span class="na">name=</span><span class="s">'ganglia-web'</span><span class="nt">/></span> <span class="nt"><Package</span> <span class="na">name=</span><span class="s">'rrdtool'</span><span class="nt">/></span> <span class="nt"><Path</span> <span class="na">name=</span><span class="s">'/etc/ganglia/gmetad.conf'</span> <span class="nt">/></span> <span class="nt"><Service</span> <span class="na">name=</span><span class="s">'gmetad'</span> <span class="nt">/></span> <span class="nt"></Group></span> <span class="nt"></Bundle></span> </pre></div> </div> </div> <div class="section" id="rules-services-ganglia-xml"> <h2>Rules/services-ganglia.xml<a class="headerlink" href="#rules-services-ganglia-xml" title="Permalink to this headline">¶</a></h2> <div class="highlight-xml"><div class="highlight"><pre><span class="nt"><Rules</span> <span class="na">priority=</span><span class="s">'10'</span><span class="nt">></span> <span class="nt"><Service</span> <span class="na">name=</span><span class="s">'gmond'</span> <span class="na">type=</span><span class="s">'chkconfig'</span> <span class="na">status=</span><span class="s">'on'</span> <span class="nt">/></span> <span class="nt"><Group</span> <span class="na">name=</span><span class="s">'gmetad-server'</span><span class="nt">></span> <span class="nt"><Service</span> <span class="na">name=</span><span class="s">'gmetad'</span> <span class="na">type=</span><span class="s">'chkconfig'</span> <span class="na">status=</span><span class="s">'on'</span> <span class="nt">/></span> <span class="nt"></Group></span> <span class="nt"></Rules></span> </pre></div> </div> </div> <div class="section" id="cfg-etc-ganglia-gmetad-conf-gmetad-conf-genshi"> <h2>Cfg/etc/ganglia/gmetad.conf/gmetad.conf.genshi<a class="headerlink" href="#cfg-etc-ganglia-gmetad-conf-gmetad-conf-genshi" title="Permalink to this headline">¶</a></h2> <div class="highlight-none"><div class="highlight"><pre>{% python client_metadata = metadata.query.all() profile_array = {} seen = [] for item in client_metadata: if item.profile not in seen: seen.append(item.profile) profile_array[item.profile]=[] profile_array[item.profile].append(item.hostname) seen.sort() %}\ gridname "Our Grid" {% for profile in seen %} data_source "${profile}" \ {% for host in profile_array[profile] %}\ ${host} \ {% end %}\ {% end %} rrd_rootdir "/var/lib/ganglia/rrds" </pre></div> </div> </div> <div class="section" id="cfg-etc-ganglia-gmond-conf-gmod-conf-genshi"> <h2>Cfg/etc/ganglia/gmond.conf/gmod.conf.genshi<a class="headerlink" href="#cfg-etc-ganglia-gmond-conf-gmod-conf-genshi" title="Permalink to this headline">¶</a></h2> <div class="highlight-none"><div class="highlight"><pre>{% python import random random.seed(metadata.profile) last_octet=random.randint(2,254) %}\ /* $$Id$$ $$HeadURL$$ */ /* This configuration is as close to 2.5.x default behavior as possible The values closely match ./gmond/metric.h definitions in 2.5.x */ globals { daemonize = yes setuid = yes user = nobody debug_level = 0 max_udp_msg_len = 1472 mute = no deaf = no host_dmax = 1800 /* 30 minutes */ cleanup_threshold = 604800 /*secs=1 week */ gexec = no send_metadata_interval = 0 } /* If a cluster attribute is specified, then all gmond hosts are wrapped inside * of a <CLUSTER> tag. If you do not specify a cluster tag, then all <HOSTS> will * NOT be wrapped inside of a <CLUSTER> tag. */ cluster { name = "${metadata.profile}" owner = "user@company.net" latlong = "unspecified" url = "unspecified" } /* The host section describes attributes of the host, like the location */ host { location = "unspecified" } /* Feel free to specify as many udp_send_channels as you like. Gmond used to only support having a single channel */ udp_send_channel { host = ${metadata.hostname} port = 8649 } udp_send_channel { mcast_join = 239.2.11.${last_octet} port = 8649 ttl = 1 } /* You can specify as many udp_recv_channels as you like as well. */ udp_recv_channel { port = 8649 bind = ${metadata.hostname} } udp_recv_channel { mcast_join = 239.2.11.${last_octet} bind = 239.2.11.${last_octet} port = 8649 } /* You can specify as many tcp_accept_channels as you like to share an xml description of the state of the cluster */ tcp_accept_channel { port = 8649 } /* Each metrics module that is referenced by gmond must be specified and loaded. If the module has been statically linked with gmond, it does not require a load path. However all dynamically loadable modules must include a load path. */ modules { /* [snip] */ </pre></div> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../../../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">ganglia</a><ul> <li><a class="reference internal" href="#bundler-ganglia-xml">Bundler/ganglia.xml</a></li> <li><a class="reference internal" href="#rules-services-ganglia-xml">Rules/services-ganglia.xml</a></li> <li><a class="reference internal" href="#cfg-etc-ganglia-gmetad-conf-gmetad-conf-genshi">Cfg/etc/ganglia/gmetad.conf/gmetad.conf.genshi</a></li> <li><a class="reference internal" href="#cfg-etc-ganglia-gmond-conf-gmod-conf-genshi">Cfg/etc/ganglia/gmond.conf/gmod.conf.genshi</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="clientsxml.html" title="previous chapter">clients.xml</a></p> <h4>Next topic</h4> <p class="topless"><a href="grubconf.html" title="next chapter">grub.conf</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../../../../_sources/server/plugins/generators/examples/genshi/ganglia.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../../../../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../../../../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../../../../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="grubconf.html" title="grub.conf" >next</a> |</li> <li class="right" > <a href="clientsxml.html" title="clients.xml" >previous</a> |</li> <li><a href="../../../../../index.html">home</a> | </li> <!--<li><a href="../../../../../search.html">search</a> | </li>--> <li><a href="../../../../../help/index.html">help</a> | </li> <li><a href="../../../../../contents.html">documentation </a> »</li> <li><a href="../../../../../contents.html" >Bcfg2 documentation 1.3.0</a> »</li> <li><a href="../../../../index.html" >The Bcfg2 Server</a> »</li> <li><a href="../../../index.html" >Plugins</a> »</li> <li><a href="../../tgenshi.html" >TGenshi</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009-2013, Narayan Desai. Last updated on Mar 20, 2013. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>