r98831 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98830‎ | r98831 | r98832 >
Date:23:38, 3 October 2011
Author:ben
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /trunk/debs/ganglios/src/ganglia_parser (modified) (history)

Diff [purge]

Index: trunk/debs/ganglios/debian/changelog
@@ -1,3 +1,9 @@
 2+ganglios (1.1) stable; urgency=low
 3+
 4+ * changed listXMLSources to read the list from /etc/ganglia/gmetad.conf
 5+
 6+ -- Ben Hartshorne <bhartshorne@wikimedia.org> Mon, 3 Oct 2011 16:35:00 -0700
 7+
28 ganglios (1.0-1) stable; urgency=low
39
410 * Initial release
Index: trunk/debs/ganglios/src/ganglia_parser
@@ -102,39 +102,20 @@
103103
104104 def listXMLSources():
105105 """ returns a list of hosts to fetch ganglia stats from (the gmond
106 - collector nodes). In a small network, this will likely be a single host.
107 - You could simply hardcode the list if there is no coherent naming scheme.
108 - In our network, the hosts are named 'nannybot1', 'nannybot2', etc. This
109 - function polls nannybots of increasing number until it finds 3 that don't
110 - respond and considers itself done."""
111 - i = 0
112 - missed = 0
 106+ collector nodes). Pulls this list from the gmetad.conf. This will only
 107+ work when the ganglia_parser script is run on the same host as the ganglia
 108+ web UI and aggregator host."""
113109 nannybots = []
114110 logger.info("Retrieving list of nannybots...")
115 - while True:
116 - try:
117 - nannybot_addr = socket.gethostbyname('nannybot%d.lindenlab.com' % i)
118 - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
119 - s.settimeout(15.0)
120 - s.connect((nannybot_addr, 8649))
121 - s.close()
122 - nannybots.append('nannybot%d.lindenlab.com' % i)
123 - logger.info('Checking nannybot%d.lindenlab.com: [OK]' % i)
124 - missed = 0
125 - except (socket.gaierror):
126 - logger.info('Checking nannybot%d.lindenlab.com: [FAILED]' % i)
127 - missed += 1
128 - if missed > 3:
129 - break
130 - except (socket.error, socket.timeout), e:
131 - logger.warning('Checking nannybot%d.lindenlab.com: [FAILED] with error %s' % (i, e))
132 - # a connection error (rather than non-existent) should not count towards
133 - # the three missing that mark the end of the nannybots.
134 - except Exception, e:
135 - logger.critical('Caught unexpected exception while checking nannybot%d: %s' % (i, e))
136 - logger.critical('EXITING...')
137 - raise e
138 - i += 1
 111+ # so long as ganglios is running on the same host as the ganglia web ui, it
 112+ # can use ganglia's gmetad.conf to get the list of sources.
 113+ gmetadconf = open('/etc/ganglia/gmetad.conf')
 114+ datasourcere = re.compile('^data_source "(?P<name>[^"]*)" (?P<hostlist>.*)')
 115+ for line in gmetadconf.readlines():
 116+ match = datasourcere.match(line)
 117+ if match:
 118+ for host in match.group(2).split():
 119+ nannybots.append(host)
139120
140121 return nannybots
141122

Status & tagging log