From f45054474c94713e627ce96beb8cdcf34592aa38 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Fri, 15 Jul 2016 09:36:30 -0400 Subject: [PATCH] smart plugin: add IgnoreSleepMode option to ignore sleeping disks This option enables the smart plugin to use disks that libatasmart mistakenly reports as asleep. This happens because libatasmart has not been updated to incorporate support for newer idle states in the ATA spec. --- src/collectd.conf.pod | 8 ++++++++ src/smart.c | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 24dc59db..37a4d6b6 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -6456,6 +6456,14 @@ collected. If at least one B option is given and no B or set to B, B matching disks will be collected. If B is set to B, all disks are collected B the ones matched. +=item B B|B + +Normally, the C plugin will ignore disks that are reported to be asleep. +This option disables the sleep mode check and allows the plugin to collect data +from these disks anyway. This is useful in cases where libatasmart mistakenly +reports disks as asleep because it has not been updated to incorporate support +for newer idle states in the ATA spec. + =back =head2 Plugin C diff --git a/src/smart.c b/src/smart.c index 7b39aaee..45bfd171 100644 --- a/src/smart.c +++ b/src/smart.c @@ -35,12 +35,14 @@ static const char *config_keys[] = { "Disk", - "IgnoreSelected" + "IgnoreSelected", + "IgnoreSleepMode" }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); static ignorelist_t *ignorelist = NULL; +static int ignore_sleep_mode = 0; static int smart_config (const char *key, const char *value) { @@ -60,6 +62,11 @@ static int smart_config (const char *key, const char *value) invert = 0; ignorelist_set_invert (ignorelist, invert); } + else if (strcasecmp ("IgnoreSleepMode", key) == 0) + { + if (IS_TRUE (value)) + ignore_sleep_mode = 1; + } else { return (-1); @@ -165,10 +172,13 @@ static void smart_handle_disk (const char *dev) DEBUG ("smart plugin: disk %s has no SMART support.", dev); goto end; } - if (sk_disk_check_sleep_mode (d, &awake) < 0 || !awake) + if (!ignore_sleep_mode) { - DEBUG ("smart plugin: disk %s is sleeping.", dev); - goto end; + if (sk_disk_check_sleep_mode (d, &awake) < 0 || !awake) + { + DEBUG ("smart plugin: disk %s is sleeping.", dev); + goto end; + } } if (sk_disk_smart_read_data (d) < 0) { -- 2.30.2