mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 11:01:09 +00:00
Change nodesensors output
Be more sparing with 'ok' and '()' in output. Many of the sensors have no particular meaning if they are 'ok'. For a sensor witohut a value, the states are no longer surrounded by () to reflect that they are more first class rather than describing a primary value.
This commit is contained in:
parent
c4510b6a25
commit
5124802c9c
@ -98,7 +98,7 @@ def sensorpass(showout=True, appendtime=False):
|
||||
if 'sensors' not in reading[node]:
|
||||
continue
|
||||
for sensedata in reading[node]['sensors']:
|
||||
for redundant_state in ('Ok', 'Non-Critical', 'Critical'):
|
||||
for redundant_state in ('Non-Critical', 'Critical'):
|
||||
try:
|
||||
sensedata['states'].remove(redundant_state)
|
||||
except ValueError:
|
||||
@ -116,9 +116,18 @@ def sensorpass(showout=True, appendtime=False):
|
||||
showval = u' {0} '.format(sensedata['value'])
|
||||
if sensedata['units'] not in (None, u''):
|
||||
showval += sensedata['units']
|
||||
datadescription = [sensedata['health']]
|
||||
if sensedata['health'] != 'ok':
|
||||
datadescription = [sensedata['health']]
|
||||
else:
|
||||
datadescription = []
|
||||
datadescription.extend(sensedata['states'])
|
||||
showval += u' ({0})'.format(','.join(datadescription))
|
||||
if datadescription:
|
||||
if showval == '':
|
||||
showval += u' {0}'.format(
|
||||
','.join(datadescription))
|
||||
else:
|
||||
showval += u' ({0})'.format(
|
||||
','.join(datadescription))
|
||||
if appendtime:
|
||||
showval += ' @' + time.strftime(
|
||||
'%Y-%m-%dT%H:%M:%S')
|
||||
@ -137,10 +146,17 @@ def format_csv(csvwriter, orderedsensors, resdata, showtime=True):
|
||||
try:
|
||||
datum = resdata[nodekey][sensorkey]['value']
|
||||
if datum is None:
|
||||
datum = resdata[nodekey][sensorkey]['health']
|
||||
if resdata[nodekey][sensorkey]['health'] != 'ok':
|
||||
datum = resdata[nodekey][sensorkey]['health']
|
||||
else:
|
||||
datum = ''
|
||||
if resdata[nodekey][sensorkey]['states']:
|
||||
datum += ',' + ','.join(
|
||||
healthstates = ','.join(
|
||||
resdata[nodekey][sensorkey]['states'])
|
||||
if datum != '':
|
||||
datum = ','.join([datum, healthstates])
|
||||
else:
|
||||
datum = healthstates
|
||||
rowdata.append(datum)
|
||||
except KeyError:
|
||||
rowdata.append('N/A')
|
||||
|
Loading…
Reference in New Issue
Block a user