diff options
-rw-r--r-- | mof/60_LMI_Hardware.mof | 4 | ||||
-rw-r--r-- | src/hardware/LMI_DiskDriveProvider.c | 6 | ||||
-rw-r--r-- | src/hardware/smartctl.c | 11 | ||||
-rw-r--r-- | src/hardware/smartctl.h | 1 |
4 files changed, 21 insertions, 1 deletions
diff --git a/mof/60_LMI_Hardware.mof b/mof/60_LMI_Hardware.mof index f0a0659..4639978 100644 --- a/mof/60_LMI_Hardware.mof +++ b/mof/60_LMI_Hardware.mof @@ -1362,6 +1362,10 @@ class LMI_DiskDrive: CIM_DiskDrive [ Implemented(true), Description("Capacity of disk drive, in bytes."), Units("Bytes"), PUnit("Byte") ] uint64 Capacity; + + [ Implemented(true), Description("Current temperature of disk drive, in degrees Celsius"), + Units("Celsius"), PUnit("Celsius") ] + sint16 Temperature; }; [ Version("0.5.0"), Provider("cmpi:cmpiLMI_DiskDriveRealizes"), Association ] 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; /* |