En:MonitoringYaCyWithGanglia
Aus YaCyWiki
For help, howto setup and configure ganglia, see http://ganglia.sourceforge.net/
- Install ganglia with package manager
- restart the daemon when a network interface comes up: /etc/network/if-up.d/
- enable python modules, create /etc/ganglia/conf.d/python.conf:
modules { module { name = "python_module" path = "/usr/lib/ganglia/modpython.so" params = "/usr/lib/ganglia/python_modules" } } include ('/etc/ganglia/conf.d/*.pyconf')
- install yacy modul, create file /usr/lib/ganglia/python_modules/yacy.py:
from xml.dom.minidom import parse from urllib2 import urlopen def yacy_handler(field, convert): def handler(name): try: x = parse(urlopen("http://localhost:8090/Network.xml")) return convert(x.getElementsByTagName("your")[0].getElementsByTagName(field)[0].firstChild.data.strip()) except IOError: return 0 return 0 return handler def metric_init(params): global descriptors yacy_peername = {'name': 'yacy_peername', 'call_back': yacy_handler("name", str), 'time_max': 3600, 'value_type': 'string', 'units': '', 'slope': 'zero', 'format': '%s', 'description': 'YaCy Peername', 'groups': 'yacy'} yacy_version = {'name': 'yacy_version', 'call_back': yacy_handler("version", str), 'time_max': 60, 'value_type': 'string', 'units': '', 'slope': 'zero', 'format': '%s', 'description': 'YaCy Version', 'groups': 'yacy'} yacy_uptime = {'name': 'yacy_uptime', 'call_back': yacy_handler("uptime", str), 'time_max': 60, 'value_type': 'string', 'units': '', 'slope': 'zero', 'format': '%s', 'description': 'YaCy Uptime', 'groups': 'yacy'} yacy_type = {'name': 'yacy_type', 'call_back': yacy_handler("type", str), 'time_max': 60, 'value_type': 'string', 'units': '', 'slope': 'zero', 'format': '%s', 'description': 'YaCy Type', 'groups': 'yacy'} yacy_links = {'name': 'yacy_links', 'call_back': yacy_handler("links", int), 'time_max': 60, 'value_type': 'uint', 'units': '', 'slope': 'positive', 'format': '%u', 'description': 'Links on this peer', 'groups': 'yacy'} yacy_words = {'name': 'yacy_words', 'call_back': yacy_handler("words", int), 'time_max': 60, 'value_type': 'uint', 'units': '', 'slope': 'positive', 'format': '%u', 'description': 'Words on this peer', 'groups': 'yacy'} yacy_ppm = {'name': 'yacy_ppm', 'call_back': yacy_handler("ppm", int), 'time_max': 60, 'value_type': 'uint', 'units': 'ppm', 'slope': 'positive', 'format': '%u', 'description': 'Indexing pages per minute', 'groups': 'yacy'} yacy_qph = {'name': 'yacy_qph', 'call_back': yacy_handler("qph", float), 'time_max': 60, 'value_type': 'float', 'units': 'qph', 'slope': 'positive', 'format': '%f', 'description': 'Search queries per hour', 'groups': 'yacy'} yacy_seeds = {'name': 'yacy_seeds', 'call_back': yacy_handler("seeds", int), 'time_max': 60, 'value_type': 'uint', 'units': '', 'slope': 'positive', 'format': '%u', 'description': 'Seeds', 'groups': 'yacy'} descriptors = [yacy_peername, yacy_version, yacy_uptime, yacy_type, yacy_links, yacy_words, yacy_ppm, yacy_qph, yacy_seeds] return descriptors def metric_cleanup(): '''Clean up the metric module.''' pass #This code is for debugging and unit testing if __name__ == '__main__': metric_init(None) for d in descriptors: v = d['call_back'](d['name']) print 'value for %s is %s' % (d['name'], v)
- load yacy modul, create file /etc/ganglia/conf.d/yacy.pyconf:
modules { module { name = "yacy" language = "python" } } collection_group { collect_every = 10 time_threshold = 50 metric { name = "yacy_peername" title = "YaCy peername" value_threshold = 1 } metric { name = "yacy_version" title = "YaCy version" value_threshold = 1 } metric { name = "yacy_uptime" title = "YaCy uptime" value_threshold = 100 } metric { name = "yacy_type" title = "YaCy type" value_threshold = 1 } metric { name = "yacy_links" title = "YaCy links" value_threshold = 10 } metric { name = "yacy_words" title = "YaCy words" value_threshold = 10 } metric { name = "yacy_ppm" title = "YaCy ppm" value_threshold = 0.1 } metric { name = "yacy_qph" title = "YaCy qph" value_threshold = 0.1 } metric { name = "yacy_seeds" title = "YaCy seeds" value_threshold = 2 } }