Skip to content

Commit ef9716a

Browse files
[psud] Store PSU temperature and voltage information to database (sonic-net#61)
System health feature requires PSU temperature and voltage information, need store them to database for host side use.
1 parent 9b8bfa1 commit ef9716a

File tree

1 file changed

+19
-4
lines changed
  • sonic-psud/scripts

1 file changed

+19
-4
lines changed

sonic-psud/scripts/psud

+19-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ PSU_INFO_TABLE = 'PSU_INFO'
3838
PSU_INFO_KEY_TEMPLATE = 'PSU {}'
3939
PSU_INFO_PRESENCE_FIELD = 'presence'
4040
PSU_INFO_STATUS_FIELD = 'status'
41+
PSU_INFO_TEMP_FIELD = 'temp'
42+
PSU_INFO_TEMP_TH_FIELD = 'temp_threshold'
43+
PSU_INFO_VOLTAGE_FIELD = 'voltage'
44+
PSU_INFO_VOLTAGE_MAX_TH_FIELD = 'voltage_max_threshold'
45+
PSU_INFO_VOLTAGE_MIN_TH_FIELD = 'voltage_min_threshold'
4146

4247
PSU_INFO_UPDATE_PERIOD_SECS = 3
4348

@@ -247,7 +252,7 @@ class DaemonPsud(DaemonBase):
247252

248253
while not self.stop.wait(PSU_INFO_UPDATE_PERIOD_SECS):
249254
psu_db_update(psu_tbl, psu_num)
250-
self.update_psu_data()
255+
self.update_psu_data(psu_tbl)
251256
self._update_led_color(psu_tbl)
252257

253258
logger.log_info("Stop daemon main loop")
@@ -260,17 +265,17 @@ class DaemonPsud(DaemonBase):
260265

261266
logger.log_info("Shutting down...")
262267

263-
def update_psu_data(self):
268+
def update_psu_data(self, psu_tbl):
264269
if not platform_chassis:
265270
return
266271

267272
for index, psu in enumerate(platform_chassis.get_all_psus()):
268273
try:
269-
self._update_single_psu_data(index + 1, psu)
274+
self._update_single_psu_data(index + 1, psu, psu_tbl)
270275
except Exception as e:
271276
logger.log_warning("Failed to update PSU data - {}".format(e))
272277

273-
def _update_single_psu_data(self, index, psu):
278+
def _update_single_psu_data(self, index, psu, psu_tbl):
274279
name = try_get(psu.get_name)
275280
if not name:
276281
name = PSU_INFO_KEY_TEMPLATE.format(index)
@@ -325,6 +330,16 @@ class DaemonPsud(DaemonBase):
325330
if set_led:
326331
self._set_psu_led(psu, psu_status)
327332

333+
fvs = swsscommon.FieldValuePairs(
334+
[(PSU_INFO_TEMP_FIELD, str(temperature)),
335+
(PSU_INFO_TEMP_TH_FIELD, str(temperature_threshold)),
336+
(PSU_INFO_VOLTAGE_FIELD, str(voltage)),
337+
(PSU_INFO_VOLTAGE_MIN_TH_FIELD, str(voltage_low_threshold)),
338+
(PSU_INFO_VOLTAGE_MAX_TH_FIELD, str(voltage_high_threshold)),
339+
])
340+
psu_tbl.set(PSU_INFO_KEY_TEMPLATE.format(index), fvs)
341+
342+
328343
def _set_psu_led(self, psu, psu_status):
329344
try:
330345
color = psu.STATUS_LED_COLOR_GREEN if psu_status.is_ok() else psu.STATUS_LED_COLOR_RED

0 commit comments

Comments
 (0)