xcp-ng / xcp-ng-xapi-plugins

XCP-ng's specific XAPI plugins
GNU Affero General Public License v3.0
6 stars 9 forks source link

Smart plugin working with Dell hardware RAID #45

Open olivierlambert opened 3 weeks ago

olivierlambert commented 3 weeks ago

Currently, the smartctl plugin doesn't work with a Dell hardware RAID controller. In that case, the smartctl command will return:

smartctl 6.5 2016-05-07 r4318 [x86_64-linux-4.19.0+1] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

Smartctl open device: /dev/sda failed: DELL or MegaRaid controller, please try adding '-d megaraid,N'

So we should catch this very specific case to try using smartctl differently. Here is how to make it work. First, we need to smartctl --scan in order to find all the devices. This will return (for example):

/dev/sda -d scsi # /dev/sda, SCSI device
/dev/bus/0 -d megaraid,0 # /dev/bus/0 [megaraid_disk_00], SCSI device
/dev/bus/0 -d megaraid,1 # /dev/bus/0 [megaraid_disk_01], SCSI device

Now, we need to interate on all devices "megaraid" that exists, in our example 0 and 1:

smartctl -a /dev/bus/0 -d megaraid,0

and:

smartctl -a /dev/bus/0 -d megaraid,1

I suppose we could also try first to check if there's /dev/bus/ devices and treat them if we detect them. In any case, we need to catch that error.

1234Erwan commented 3 weeks ago

Here is an attempt to patch the problem : https://github.com/xcp-ng/xcp-ng-xapi-plugins/pull/46