sonic-buildimage/platform/broadcom/sonic-platform-modules-ragile/common/script/ssdmon
pettershao-ragilenetworks abccdaeb6c
[Ragile]Adapt kernel 5.10 for broadcom on RA-B6510-48V8C (#14809)
* Adapt kernel 5.10 for broadcom on RA-B6510-48V4C

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>

* update

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>

* update

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>

* update

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>

* update

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>

* modify one-image.mk file

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>

* modify debian/rule.mk

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>

* Add platform.json file

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>

---------

Signed-off-by: pettershao-ragilenetworks <pettershao@ragilenetworks.com>
2023-08-04 12:01:49 -07:00

83 lines
2.5 KiB
Python
Executable File

#!/usr/bin/env python3
#
# ssdmon
#
# Command-line utility to check SSD health and parameters
#
try:
import argparse
import os
import sys
from sonic_py_common import device_info, logger
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
DEFAULT_DEVICE = "/dev/sda"
SYSLOG_IDENTIFIER = "ssdmon"
# Global logger instance
log = logger.Logger(SYSLOG_IDENTIFIER)
def import_ssd_api(diskdev):
"""
Loads platform specific or generic ssd_mon module from source
Raises an ImportError exception if none of above available
Returns:
Instance of the class with SSD API implementation (vendor or generic)
"""
# try to load platform specific module
try:
platform_path, _ = device_info.get_paths_to_platform_and_hwsku_dirs()
platform_plugins_path = os.path.join(platform_path, "plugins")
sys.path.append(os.path.abspath(platform_plugins_path))
from ssd_util import SsdUtil
except ImportError as e:
log.log_warning("Platform specific SsdMon module not found.")
return SsdUtil(diskdev)
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
# ==================== Entry point ====================
def ssdmon():
if os.geteuid() != 0:
print("Root privileges are required for this operation")
sys.exit(1)
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--device", help="Device name to show health info", default=DEFAULT_DEVICE)
parser.add_argument("-t", "--temperature", action="store_true", default=False, help="Show only temperature")
parser.add_argument("-j", "--health", action="store_true", default=False, help="Show only health")
args = parser.parse_args()
ssd = import_ssd_api(args.device)
if args.temperature:
print(ssd.get_temperature())
return
if args.health:
print(ssd.get_health())
return
print("Device Model : {}".format(ssd.get_model()))
print("Firmware : {}".format(ssd.get_firmware()))
print("Serial : {}".format(ssd.get_serial()))
print("Health : {}{}".format(ssd.get_health(), "%" if is_number(ssd.get_health()) else ""))
print("Remain Life : {}{}".format(ssd.get_remaining_life(), "%" if is_number(ssd.get_remaining_life()) else ""))
print("Temperature : {}{}".format(ssd.get_temperature(), "C" if is_number(ssd.get_temperature()) else ""))
print("SATA Rate : {}".format(ssd.get_sata_rate()))
if __name__ == '__main__':
ssdmon()