From 63307c331e0ebb2fbba327566c245caa91d51852 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 17 Feb 2026 16:19:41 -0500 Subject: [PATCH] Have nodesensors and nodehealth be more adaptive to partial server data. --- confluent_client/bin/nodehealth | 8 ++++---- confluent_client/bin/nodesensors | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/confluent_client/bin/nodehealth b/confluent_client/bin/nodehealth index 2cba8b92..ebceb16d 100755 --- a/confluent_client/bin/nodehealth +++ b/confluent_client/bin/nodehealth @@ -84,13 +84,13 @@ def main(): healthexplanations[node] = [] for sensor in health[node]['sensors']: explanation = sensor['name'] + ':' - if sensor['value'] is not None: + if sensor.get('value', None) is not None: explanation += str(sensor['value']) - if sensor['units'] is not None: + if sensor.get('units', None) is not None: explanation += sensor['units'] - if sensor['states']: + if sensor.get('states', None): explanation += ',' - if sensor['states']: + if sensor.get('states', None): explanation += ','.join(sensor['states']) healthexplanations[node].append(explanation) if node in healthbynode and node in healthexplanations: diff --git a/confluent_client/bin/nodesensors b/confluent_client/bin/nodesensors index 2222abfd..dc1d749b 100755 --- a/confluent_client/bin/nodesensors +++ b/confluent_client/bin/nodesensors @@ -123,7 +123,7 @@ def sensorpass(showout=True, appendtime=False): if 'sensors' not in reading[node]: continue for sensedata in reading[node]['sensors']: - if sensedata['value'] is None and options.skipnumberless: + if sensedata.get('value', None) is None and options.skipnumberless: continue for redundant_state in ('Non-Critical', 'Critical'): try: @@ -134,17 +134,17 @@ def sensorpass(showout=True, appendtime=False): resultdata[node][sensedata['name']] = sensedata sensorname = sensedata['name'] sensorheaders[sensorname] = sensorname - if sensedata['units'] not in (None, u''): + if sensedata.get('units', None) not in (None, u''): sensorheaders[sensorname] += u' ({0})'.format( sensedata['units']) if showout: - if sensedata['value'] is None: + if sensedata.get('value', None) is None: showval = '' elif isinstance(sensedata['value'], float): showval = u' {0} '.format(floatformat(sensedata['value'])) else: - showval = u' {0} '.format(sensedata['value']) - if sensedata['units'] not in (None, u''): + showval = u' {0} '.format(sensedata.get('value', '')) + if sensedata.get('units', None) not in (None, u''): showval += sensedata['units'] if sensedata.get('health', 'ok') != 'ok': datadescription = [sensedata['health']]