]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Initial coding
authorRandy Bates <rbates@web-site.com>
Thu, 30 Apr 2020 21:20:34 +0000 (16:20 -0500)
committerKeith Busch <kbusch@kernel.org>
Tue, 30 Jun 2020 17:31:53 +0000 (11:31 -0600)
plugins/wdc/wdc-nvme.c
plugins/wdc/wdc-nvme.h

index 791353ba63c157fdc67ca16264744e2da480aa89..548e14c6cb39cc7f6bfd7f6bf8341de8ad075d14 100644 (file)
@@ -570,6 +570,8 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *command
 static int wdc_do_drive_info(int fd, __u32 *result);
 static int wdc_vs_drive_info(int argc, char **argv, struct command *command,
                struct plugin *plugin);
+static int wdc_vs_temperature_stats(int argc, char **argv, struct command *command,
+               struct plugin *plugin);
 
 /* Drive log data size */
 struct wdc_log_size {
@@ -6543,5 +6545,34 @@ static int wdc_vs_drive_info(int argc, char **argv,
        fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret), ret);
        return ret;
 }
+static int wdc_vs_temperature_stats(int argc, char **argv,
+               struct command *command, struct plugin *plugin)
+{
+       const char *desc = "Send a vs-temperature-stats command.";
+       struct nvme_smart_log smart_log;
+       int fd, ret;
+       /* convert temperature from Kelvin to Celsius */
+
+       OPT_ARGS(opts) = {
+               OPT_END()
+       };
 
+       fd = parse_and_open(argc, argv, desc, opts);
+       if (fd < 0)
+               return fd;
 
+       wdc_check_device(fd);
+       ret = nvme_smart_log(fd, NVME_NSID_ALL, &smart_log);
+
+       if (ret == 0) {
+               int temperature = ((smart_log.temperature[1] << 8) |
+                                   smart_log.temperature[0]) - 273;
+
+               printf("temperature                             : %d C\n",
+                       temperature);
+
+       }
+
+       fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret), ret);
+       return ret;
+}
index c6b2d3faf128665f598823e7b81a25b2df8e4ae8..9c8e222810dc02c7a180363abb568ce87600094f 100644 (file)
@@ -30,6 +30,7 @@ PLUGIN(NAME("wdc", "Western Digital vendor specific extensions"),
                ENTRY("log-page-directory", "WDC Get Log Page Directory", wdc_log_page_directory)
                ENTRY("namespace-resize", "WDC NamespaceDrive Resize", wdc_namespace_resize)
                ENTRY("vs-drive-info", "WDC Get Drive Info", wdc_vs_drive_info)
+               ENTRY("vs-temperature-stats", "WDC Get Temperature Stats", wdc_vs_temperature_stats)
        )
 );