Skip to content

Pr json support for show platform temperature #3874

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

vikumarks
Copy link

What I did

Added json support for show platform temperature

How I did it

How to verify it

admin@sonic:~$ show platform temperature
                  Sensor    Temperature    High TH    Low TH    Crit High TH    Crit Low TH    Warning          Timestamp
------------------------  -------------  ---------  --------  --------------  -------------  ---------  -----------------
           CB_temp(0x4B)           29.5       80.0       N/A             N/A            N/A      False  20240923 00:32:07
         CPU_Core_0_temp           46.0       82.0       N/A           104.0            N/A      False  20240923 00:32:07
         CPU_Core_1_temp           46.0       82.0       N/A           104.0            N/A      False  20240923 00:32:07
         CPU_Core_2_temp           46.0       82.0       N/A           104.0            N/A      False  20240923 00:32:07
         CPU_Core_3_temp           45.0       82.0       N/A           104.0            N/A      False  20240923 00:32:07
        CPU_Package_temp           46.0       82.0       N/A           104.0            N/A      False  20240923 00:32:07
           FB_temp(0x4C)           35.0       80.0       N/A             N/A            N/A      False  20240923 00:32:07
  MB_FrontMAC_temp(0x49)           28.5       80.0       N/A             N/A            N/A      False  20240923 00:32:07
MB_LeftCenter_temp(0x4A)           28.0       80.0       N/A             N/A            N/A      False  20240923 00:32:07
   MB_RearMAC_temp(0x48)           30.5       80.0       N/A             N/A            N/A      False  20240923 00:32:07
     PSU-1 temp sensor 1            N/A        N/A       N/A             N/A            N/A      False  20240923 00:32:07
     PSU-2 temp sensor 1           37.0       80.0       N/A             N/A            N/A      False  20240923 00:32:07
admin@sonic:~$ show platform temperature --help
Usage: show platform temperature [OPTIONS]

  Show device temperature information

Options:
  --json          Output in JSON format
  -h, -?, --help  Show this message and exit.
admin@sonic:~$ show platform temperature --json
[
  {
    "Sensor": "CB_temp(0x4B)",
    "Temperature": "29.5",
    "High_TH": "80.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "N/A",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "CPU_Core_0_temp",
    "Temperature": "46.0",
    "High_TH": "82.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "104.0",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "CPU_Core_1_temp",
    "Temperature": "46.0",
    "High_TH": "82.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "104.0",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "CPU_Core_2_temp",
    "Temperature": "46.0",
    "High_TH": "82.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "104.0",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "CPU_Core_3_temp",
    "Temperature": "45.0",
    "High_TH": "82.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "104.0",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "CPU_Package_temp",
    "Temperature": "46.0",
    "High_TH": "82.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "104.0",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "FB_temp(0x4C)",
    "Temperature": "35.0",
    "High_TH": "80.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "N/A",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "MB_FrontMAC_temp(0x49)",
    "Temperature": "28.5",
    "High_TH": "80.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "N/A",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "MB_LeftCenter_temp(0x4A)",
    "Temperature": "28.0",
    "High_TH": "80.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "N/A",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "MB_RearMAC_temp(0x48)",
    "Temperature": "30.5",
    "High_TH": "80.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "N/A",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "PSU-1 temp sensor 1",
    "Temperature": "N/A",
    "High_TH": "N/A",
    "Low_TH": "N/A",
    "Crit_High_TH": "N/A",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  },
  {
    "Sensor": "PSU-2 temp sensor 1",
    "Temperature": "37.0",
    "High_TH": "80.0",
    "Low_TH": "N/A",
    "Crit_High_TH": "N/A",
    "Crit_Low_TH": "N/A",
    "Warning": "False",
    "Timestamp": "20240923 00:32:07"
  }
]

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@r12f r12f requested a review from vvolam May 8, 2025 20:53
@vvolam vvolam requested a review from Copilot May 8, 2025 21:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds JSON support to the "show platform temperature" command, allowing users to output temperature data in JSON format.

  • Added a '--json' option to the click-based command in show/platform.py.
  • Updated scripts/tempershow to handle a JSON flag via argparse and output JSON-formatted data.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
show/platform.py Added '--json' click option and updated the command to include the JSON flag.
scripts/tempershow Integrated argparse support for JSON output and modified output handling.

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

vvolam
vvolam previously approved these changes May 9, 2025
Copy link
Contributor

@vvolam vvolam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

vvolam
vvolam previously approved these changes May 10, 2025
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants