http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98831

Revision: 98831
Author:   ben
Date:     2011-10-03 23:38:20 +0000 (Mon, 03 Oct 2011)
Log Message:
-----------
changed gaglia_parser to look for data from the data_sources lines in 
gmetad.conf rather than iterating across nannybot# hosts.

Modified Paths:
--------------
    trunk/debs/ganglios/debian/changelog
    trunk/debs/ganglios/src/ganglia_parser

Modified: trunk/debs/ganglios/debian/changelog
===================================================================
--- trunk/debs/ganglios/debian/changelog        2011-10-03 23:30:40 UTC (rev 
98830)
+++ trunk/debs/ganglios/debian/changelog        2011-10-03 23:38:20 UTC (rev 
98831)
@@ -1,3 +1,9 @@
+ganglios (1.1) stable; urgency=low
+
+  * changed listXMLSources to read the list from /etc/ganglia/gmetad.conf
+
+ -- Ben Hartshorne <bhartsho...@wikimedia.org> Mon, 3 Oct 2011 16:35:00 -0700
+
 ganglios (1.0-1) stable; urgency=low
 
   * Initial release

Modified: trunk/debs/ganglios/src/ganglia_parser
===================================================================
--- trunk/debs/ganglios/src/ganglia_parser      2011-10-03 23:30:40 UTC (rev 
98830)
+++ trunk/debs/ganglios/src/ganglia_parser      2011-10-03 23:38:20 UTC (rev 
98831)
@@ -102,39 +102,20 @@
 
 def listXMLSources():
     """ returns a list of hosts to fetch ganglia stats from (the gmond
-    collector nodes).  In a small network, this will likely be a single host.
-    You could simply hardcode the list if there is no coherent naming scheme.
-    In our network, the hosts are named 'nannybot1', 'nannybot2', etc.  This
-    function polls nannybots of increasing number until it finds 3 that don't
-    respond and considers itself done."""
-    i = 0
-    missed = 0
+    collector nodes).  Pulls this list from the gmetad.conf.  This will only
+    work when the ganglia_parser script is run on the same host as the ganglia
+    web UI and aggregator host."""
     nannybots = []
     logger.info("Retrieving list of nannybots...")
-    while True:
-        try:
-            nannybot_addr = socket.gethostbyname('nannybot%d.lindenlab.com' % 
i)
-            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-            s.settimeout(15.0)
-            s.connect((nannybot_addr, 8649))
-            s.close()
-            nannybots.append('nannybot%d.lindenlab.com' % i)
-            logger.info('Checking nannybot%d.lindenlab.com: [OK]' % i)
-            missed = 0
-        except (socket.gaierror):
-            logger.info('Checking nannybot%d.lindenlab.com: [FAILED]' % i)
-            missed += 1
-            if missed > 3:
-                break
-        except (socket.error, socket.timeout), e:
-            logger.warning('Checking nannybot%d.lindenlab.com: [FAILED] with 
error %s' % (i, e))
-            # a connection error (rather than non-existent) should not count 
towards 
-            # the three missing that mark the end of the nannybots.
-        except Exception, e:
-            logger.critical('Caught unexpected exception while checking 
nannybot%d: %s' % (i, e))
-            logger.critical('EXITING...')
-            raise e
-        i += 1
+    # so long as ganglios is running on the same host as the ganglia web ui, it
+    # can use ganglia's gmetad.conf to get the list of sources.
+    gmetadconf = open('/etc/ganglia/gmetad.conf')
+    datasourcere = re.compile('^data_source "(?P<name>[^"]*)" 
(?P<hostlist>.*)')
+    for line in gmetadconf.readlines():
+        match = datasourcere.match(line)
+        if match:
+            for host in match.group(2).split():
+                nannybots.append(host)
 
     return nannybots
 


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to