summaryrefslogtreecommitdiffstats
path: root/src/hardware
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2014-02-10 18:19:15 +0100
committerPeter Schiffer <pschiffe@redhat.com>2014-02-10 18:21:24 +0100
commit4fc8bee6cea3f146bec38018e2ba734f16585191 (patch)
treec0f9467e8f0533d20dfb012f6b8341f002c02d88 /src/hardware
parenteb41fb478d0671385724f77d88af334ba999d393 (diff)
downloadopenlmi-providers-4fc8bee6cea3f146bec38018e2ba734f16585191.tar.gz
openlmi-providers-4fc8bee6cea3f146bec38018e2ba734f16585191.tar.xz
openlmi-providers-4fc8bee6cea3f146bec38018e2ba734f16585191.zip
Hardware: added temperature to the DiskDriveProvider
Diffstat (limited to 'src/hardware')
-rw-r--r--src/hardware/LMI_DiskDriveProvider.c6
-rw-r--r--src/hardware/smartctl.c11
-rw-r--r--src/hardware/smartctl.h1
3 files changed, 17 insertions, 1 deletions
diff --git a/src/hardware/LMI_DiskDriveProvider.c b/src/hardware/LMI_DiskDriveProvider.c
index cfc9ef5..feaae00 100644
--- a/src/hardware/LMI_DiskDriveProvider.c
+++ b/src/hardware/LMI_DiskDriveProvider.c
@@ -19,6 +19,7 @@
*/
#include <unistd.h>
+#include <limits.h>
#include <konkret/konkret.h>
#include "LMI_DiskDrive.h"
#include "LMI_Hardware.h"
@@ -142,6 +143,11 @@ static CMPIStatus LMI_DiskDriveEnumInstances(
smtcl_hdds[j].port_speed);
}
+ if (smtcl_hdds[j].curr_temp > SHRT_MIN) {
+ LMI_DiskDrive_Set_Temperature(&lmi_hdd,
+ smtcl_hdds[j].curr_temp);
+ }
+
break;
}
}
diff --git a/src/hardware/smartctl.c b/src/hardware/smartctl.c
index b1b0ce7..d637acc 100644
--- a/src/hardware/smartctl.c
+++ b/src/hardware/smartctl.c
@@ -40,6 +40,7 @@ void init_smctlhdd_struct(SmartctlHdd *hdd)
hdd->max_port_speed = 0;
hdd->rpm = 0xffffffff;
hdd->capacity = 0;
+ hdd->curr_temp = SHRT_MIN;
}
/*
@@ -219,7 +220,7 @@ short smartctl_get_hdds(SmartctlHdd **hdds, unsigned *hdds_nb)
for (curr_hdd = 0; curr_hdd < *hdds_nb; curr_hdd++) {
/* get smartctl output */
char command[PATH_MAX];
- snprintf(command, PATH_MAX, "smartctl -iH --identify=n %s",
+ snprintf(command, PATH_MAX, "smartctl -iH -l scttempsts --identify=n %s",
(*hdds)[curr_hdd].dev_path);
if (run_command(command, &buffer, &buffer_size) < 0) {
continue;
@@ -360,6 +361,14 @@ short smartctl_get_hdds(SmartctlHdd **hdds, unsigned *hdds_nb)
buf = NULL;
continue;
}
+ /* Temperature */
+ buf = copy_string_part_after_delim(buffer[i], "Current Temperature:");
+ if (buf) {
+ sscanf(buf, "%hd", &(*hdds)[curr_hdd].curr_temp);
+ free(buf);
+ buf = NULL;
+ continue;
+ }
}
free_2d_buffer(&buffer, &buffer_size);
diff --git a/src/hardware/smartctl.h b/src/hardware/smartctl.h
index 8b277e3..594f218 100644
--- a/src/hardware/smartctl.h
+++ b/src/hardware/smartctl.h
@@ -48,6 +48,7 @@ typedef struct _SmartctlHdd {
unsigned long max_port_speed; /* Max Port Speed in b/s */
unsigned rpm; /* RPM of drive */
unsigned long capacity; /* Drive's capacity in bytes */
+ short int curr_temp; /* Current disk temperature in Celsius */
} SmartctlHdd;
/*