diff mbox

[ndctl] ndctl, list: Add controller temperature

Message ID 152893146792.8891.9589382470202184792.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams June 13, 2018, 11:11 p.m. UTC
Emit the controller temperature if the smart payload includes this
field.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/util/json-smart.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

QI Fuli June 14, 2018, 8:34 a.m. UTC | #1
> -----Original Message-----
> From: Linux-nvdimm [mailto:linux-nvdimm-bounces@lists.01.org] On Behalf Of Dan
> Williams
> Sent: Thursday, June 14, 2018 8:11 AM
> To: linux-nvdimm@lists.01.org
> Subject: [ndctl PATCH] ndctl, list: Add controller temperature
> 
> Emit the controller temperature if the smart payload includes this field.
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  ndctl/util/json-smart.c |   10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/ndctl/util/json-smart.c b/ndctl/util/json-smart.c index
> 4020423bb8c8..9482b35a43d6 100644
> --- a/ndctl/util/json-smart.c
> +++ b/ndctl/util/json-smart.c
> @@ -109,6 +109,16 @@ struct json_object *util_dimm_health_to_json(struct ndctl_dimm
> *dimm)
>  			json_object_object_add(jhealth, "temperature_celsius",
> jobj);
>  	}
> 
> +	if (flags & ND_SMART_CTEMP_VALID) {
> +		unsigned int temp = ndctl_cmd_smart_get_ctrl_temperature(cmd);
> +		double t = ndctl_decode_smart_temperature(temp);
> +
> +		jobj = json_object_new_double(t);
> +		if (jobj)
> +			json_object_object_add(jhealth,
> +					"controller_temperature_celsius", jobj);
> +	}
> +
>  	if (flags & ND_SMART_SPARES_VALID) {
>  		unsigned int spares = ndctl_cmd_smart_get_spares(cmd);
> 
> 

Hi Dan,

I think it would be more helpful to additionally add controller_temperature_threshold to list.

Qi
diff mbox

Patch

diff --git a/ndctl/util/json-smart.c b/ndctl/util/json-smart.c
index 4020423bb8c8..9482b35a43d6 100644
--- a/ndctl/util/json-smart.c
+++ b/ndctl/util/json-smart.c
@@ -109,6 +109,16 @@  struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm)
 			json_object_object_add(jhealth, "temperature_celsius", jobj);
 	}
 
+	if (flags & ND_SMART_CTEMP_VALID) {
+		unsigned int temp = ndctl_cmd_smart_get_ctrl_temperature(cmd);
+		double t = ndctl_decode_smart_temperature(temp);
+
+		jobj = json_object_new_double(t);
+		if (jobj)
+			json_object_object_add(jhealth,
+					"controller_temperature_celsius", jobj);
+	}
+
 	if (flags & ND_SMART_SPARES_VALID) {
 		unsigned int spares = ndctl_cmd_smart_get_spares(cmd);