Json support for show platform temperature #3997
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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)