Skip to content

Commit

Permalink
use application_name/type internally for details
Browse files Browse the repository at this point in the history
  • Loading branch information
lausser committed Mar 14, 2017
1 parent 2c5d257 commit 941c7a3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* 2017-03-14 3.4.3
use application_name/type internally for details
* 2017-02-27 3.4.2
prepare diff
* 2017-02-27 3.4.1
Expand Down
26 changes: 24 additions & 2 deletions coshsh/monitoringdetail.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MonitoringDetail(coshsh.item.Item):
id = 1
my_type = "detail"
class_factory = []
lower_columns = ['name', 'type']
lower_columns = ['name', 'type', 'application_name', 'application_type']

def __init__(self, params):
#print "Detail init", self.__class__, self.__class__.__name__, len(self.__class__.class_factory)
Expand All @@ -40,14 +40,36 @@ def __init__(self, params):
newcls = self.__class__.get_class(params)
if newcls:
self.__class__ = newcls
# name, type is preferred, because a detail can also be a host detail
# application_name, application_type is ok too. in any case these will be internally used
if 'name' in params:
params['application_name'] = params['name']
del params['name']
if 'type' in params:
params['application_type'] = params['type']
del params['type']
super(MonitoringDetail, self).__init__(params)
self.__init__(params)
else:
logger.info("monitoring detail of type %s for host %s / appl %s had a problem" % (params["monitoring_type"], params["host_name"], params["name"]))
logger.info("monitoring detail of type %s for host %s / appl %s had a problem" % (params["monitoring_type"], params["host_name"], params["application_name"]))
raise MonitoringDetailNotImplemented
else:
pass

def fingerprint(self):
# it does not make sense to construct an id from the random attributes
# id is used in self.add('details')
return id(self)

def application_fingerprint(self):
try:
return "%s+%s+%s" % (self.host_name, self.application_name, self.application_type)
except: pass
try:
return "%s" % (self.host_name, )
except: pass
raise "impossible fingerprint"

@classmethod
def init_classes(cls, classpath):
sys.dont_write_bytecode = True
Expand Down
12 changes: 6 additions & 6 deletions coshsh/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ def collect(self):
return False

for detail in self.objects['details'].values():
application_id = "%s+%s+%s" % (detail.host_name, detail.name, detail.type)
if application_id in self.objects['applications']:
self.objects['applications'][application_id].monitoring_details.append(detail)
elif not detail.name and not detail.type and detail.host_name in self.objects['hosts']:
self.objects['hosts'][detail.host_name].monitoring_details.append(detail)
fingerprint = detail.application_fingerprint()
if fingerprint in self.objects['applications']:
self.objects['applications'][fingerprint].monitoring_details.append(detail)
elif fingerprint in self.objects['hosts']:
self.objects['hosts'][fingerprint].monitoring_details.append(detail)
else:
logger.info("found a detail %s for an unknown application %s" % (detail, application_id))
logger.info("found a detail %s for an unknown application %s" % (detail, fingerprint))

for host in self.objects['hosts'].values():
host.resolve_monitoring_details()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def run(self):


setup(name='coshsh',
version='3.4.2',
version='3.4.3',
description='Coshsh - config generator for monitoring systems',
url='http://github.com/lausser/coshsh',
author='Gerhard Lausser',
Expand Down

0 comments on commit 941c7a3

Please sign in to comment.