Skip to content

Commit

Permalink
Merge 0c13747 into 564c8fb
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Jan 23, 2017
2 parents 564c8fb + 0c13747 commit be54925
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 14 deletions.
31 changes: 19 additions & 12 deletions alignak_backend/perfdata.py
Expand Up @@ -63,7 +63,6 @@ def __init__(self, string):
self.name = self.value = self.uom = \
self.warning = self.critical = self.min = self.max = None
string = string.strip()
# print "Analysis string", string
matches = METRIC_PATTERN.match(string)
if matches:
# Get the name but remove all ' in it
Expand All @@ -74,20 +73,28 @@ def __init__(self, string):
self.critical = guess_int_or_float(matches.group(5))
self.min = guess_int_or_float(matches.group(6))
self.max = guess_int_or_float(matches.group(7))
# print 'Name', self.name
# print "Value", self.value
# print "Res", r
# print r.groups()
if self.uom == '%':
self.min = 0
self.max = 100

def __str__(self):
def __str__(self): # pragma: no cover, only for debugging purpose
string = "%s=%s%s" % (self.name, self.value, self.uom)
if self.warning:
if self.warning is not None:
string += ";%s" % (self.warning)
if self.critical:
else:
string += ";"
if self.critical is not None:
string += ";%s" % (self.critical)
else:
string += ";"
if self.min is not None:
string += ";%s" % (self.min)
else:
string += ";"
if self.max is not None:
string += ";%s" % (self.max)
else:
string += ";"
return string


Expand All @@ -106,14 +113,14 @@ def __init__(self, string):
if metric.name is not None:
self.metrics[metric.name] = metric

def __iter__(self):
def __iter__(self): # pragma: no cover, not used internally
return self.metrics.itervalues()

def __len__(self):
def __len__(self): # pragma: no cover, not used internally
return len(self.metrics)

def __getitem__(self, key):
def __getitem__(self, key): # pragma: no cover, not used internally
return self.metrics[key]

def __contains__(self, key):
def __contains__(self, key): # pragma: no cover, not used internally
return key in self.metrics
16 changes: 16 additions & 0 deletions alignak_backend/timeseries.py
Expand Up @@ -103,6 +103,22 @@ def prepare_data(item):
'uom': fields['uom']
}
)
if fields['min'] is not None:
data_timeseries['data'].append(
{
'name': fields['name'] + '_min',
'value': fields['min'],
'uom': fields['uom']
}
)
if fields['max'] is not None:
data_timeseries['data'].append(
{
'name': fields['name'] + '_max',
'value': fields['max'],
'uom': fields['uom']
}
)
return data_timeseries

@staticmethod
Expand Down

0 comments on commit be54925

Please sign in to comment.