Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox] Fix thermal control issue: use natural sort for fan status and thermal status #836

Merged
merged 3 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/fanshow
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import argparse

from tabulate import tabulate
from swsssdk import SonicV2Connector
from natsort import natsorted


header = ['FAN', 'Speed', 'Direction', 'Presence', 'Status', 'Timestamp']
Expand All @@ -32,7 +33,7 @@ class FanShow(object):
return

table = []
for key in keys:
for key in natsorted(keys):
key_list = key.split('|')
if len(key_list) != 2: # error data in DB, log it and ignore
print('Warn: Invalid key in table FAN_INFO: {}'.format(key))
Expand All @@ -47,18 +48,21 @@ class FanShow(object):
else:
speed = '{}%'.format(data_dict[SPEED_FIELD_NAME])
except ValueError as e:
print('Warn: cannot convert speed value from {}'.format(data_dict[SPEED_FIELD_NAME]))
speed = data_dict[SPEED_FIELD_NAME]

presence = data_dict[PRESENCE_FIELD_NAME].lower()
presence = 'Present' if presence == 'true' else 'Not Present'
status = data_dict[STATUS_FIELD_NAME].lower()
status = 'OK' if status == 'true' else 'Not OK'
if status == 'true':
status = 'OK'
elif status == 'false':
status = 'Not OK'
else:
status = 'N/A'

table.append((name, speed, data_dict[DIRECTION_FIELD_NAME], presence, status, data_dict[TIMESTAMP_FIELD_NAME]))

if table:
table.sort()
print(tabulate(table, header, tablefmt='simple', stralign='right'))
else:
print('No fan status data available\n')
Expand Down
6 changes: 3 additions & 3 deletions scripts/tempershow
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import argparse

from tabulate import tabulate
from swsssdk import SonicV2Connector
from natsort import natsorted


header = ['NAME', 'Temperature', 'High Threshold', 'Low Threshold', 'Critical High Threshold', 'Critical Low Threshold', 'Warning Status', 'Timestamp']
header = ['Sensor', 'Temperature', 'High TH', 'Low TH', 'Crit High TH', 'Crit Low TH', 'Warning', 'Timestamp']

TEMPER_TABLE_NAME = 'TEMPERATURE_INFO'
TEMPER_FIELD_NAME = 'temperature'
Expand All @@ -34,7 +35,7 @@ class TemperShow(object):
return

table = []
for key in keys:
for key in natsorted(keys):
key_list = key.split('|')
if len(key_list) != 2: # error data in DB, log it and ignore
print('Warn: Invalid key in table {}: {}'.format(TEMPER_TABLE_NAME, key))
Expand All @@ -53,7 +54,6 @@ class TemperShow(object):
))

if table:
table.sort()
print(tabulate(table, header, tablefmt='simple', stralign='right'))
else:
print('No tempeature data available\n')
Expand Down