]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: add temperature sensor fields in json_smart_log
authorGuan Junxiong <guanjunxiong@huawei.com>
Wed, 21 Jun 2017 05:09:23 +0000 (13:09 +0800)
committerKeith Busch <keith.busch@intel.com>
Mon, 26 Jun 2017 20:01:22 +0000 (16:01 -0400)
Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com>
nvme-print.c

index 6005e065c8740be04f138606537b9d08b16e4ea0..f2fa67fe993b772f329557219265462dd44c5d3c 100644 (file)
@@ -1645,6 +1645,8 @@ void json_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname)
 void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char *devname)
 {
        struct json_object *root;
+       int c;
+       char key[21];
 
        unsigned int temperature = ((smart->temperature[1] << 8) |
                smart->temperature[0]);
@@ -1681,6 +1683,16 @@ void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char
                        le32_to_cpu(smart->warning_temp_time));
        json_object_add_value_int(root, "critical_comp_time",
                        le32_to_cpu(smart->critical_comp_time));
+
+       for (c=0; c < 8; c++) {
+               __s32 temp = le16_to_cpu(smart->temp_sensor[c]);
+
+               if (temp == 0)
+                       continue;
+               sprintf(key, "temperature_sensor_%d",c+1);
+               json_object_add_value_int(root, key, temp);
+       }
+
        json_object_add_value_int(root, "thm_temp1_trans_count",
                        le32_to_cpu(smart->thm_temp1_trans_count));
        json_object_add_value_int(root, "thm_temp2_trans_count",