Skip to content

r5r3/encled

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 

Repository files navigation

encled - SCSI Enclosure indicators (SES LED) control

This utility can be used to turn the fault/location leds of an external disk enclosure on and off. The script was tested only with supermicro shelfs and LSI controllers, but it could in principle also work with shelfs from other manufactures.

This script is a rewritten version of the original work from George Shuklin, which can be foud here: https://github.com/amarao/sdled

Compared to the original script, the new script works also without correctly populated device links in /sys/class/enclosure. This change was necessary due to Redhat Bug 1394089 (https://bugzilla.redhat.com/show_bug.cgi?id=1394089), which was not jet fixed at the time of writing.

Usage

$ encled --help
usage: encled [-h] {status,led,list} ...

encled - SCSI Enclosure indicators (SES LED) control

optional arguments:
  -h, --help         show this help message and exit

available operations:
  {status,led,list}
    status           show the status of enclosures or disks
    led              turn on/off the leds of a disk
    list             list devices in different formats

Three operations are available: status shows the locations of all disks within the shelf and the status of the LEDs, led turns LEDs on or off, and list outputs device lists in formats suitable for other commands.

Status

status shows information about the disks and the location of the disks within the shelf. The later is correct for supermicro shelfs with 24 or 44 disks. The layout of new shelfs may be added by extending the enclosure_layouts dictionary.

$ encled status --help
usage: encled status [-h] [--smart] [-e ENC] [-d DISK] [-s SLOT]

optional arguments:
  -h, --help            show this help message and exit
  --smart               run smartctl --all on the disk (requires -d).
  -e ENC, --enc ENC     the enclosure of interest.
  -d DISK, --disk DISK  the disk of interest.
  -s SLOT, --slot SLOT  the slot of interest.

To get the status of all disks in all enclosures run:

$ encled status

Enclosure: SMC, SC846P, 0c1f (/dev/sg50, 5003048017cbad7f)
--------------------------------------------------------------------------------
Slot 6: /dev/sdaw   Slot 12: /dev/sdbc  Slot 18: /dev/sdbp  Slot 24: /dev/sdbv
35000039b8812510d   35000039b88124bf5   35000039b88116235   35000039b583be56d
SN=32D0A066FD3H     SN=32D0A04EFD3H     SN=32D0A01YFD3H     SN=Z1F0A01HFD3H
Size=8.00TB V=T     Size=8.00TB V=T     Size=8.00TB V=T     Size=8.00TB V=T
Status=OK L=0 F=0   Status=OK L=0 F=0   Status=OK L=0 F=0   Status=OK L=0 F=0

The status output includes for each disk: slot number with device name, SCSI-ID, serial number (SN=), disk size with vendor initial (V=), and LED status. Long lines are truncated in the enclosure overview.

For one individual disk run:

$ encled status --disk /dev/sdx

Enclosure: LSI, SAS2X36, 0e12 (/dev/sg24, 50030480028abcdf)
Slot 24: /dev/sdx
35000cca01aaaa01c
SN=VAGSDRJL
Size=8.00TB V=T
Status=OK L=0 F=0

The --disk argument takes names like /dev/sda, the SCSI-ID (which is also used by the multipath kernel module), the serial number of the disk, or an integer representing the slot (counting from 1!).

To also display the full SMART data for a disk, add the --smart flag (requires -d or -s):

$ encled status --disk /dev/sdx --smart

This will show the disk information block followed by the output of smartctl --all.

If multiple enclosures are present, the output may be reduced to one enclosure by adding the --enc Argument. It Expects the name of the SCSI-device associated with the enclosure (e.g., /dev/sg24).

LED

led turns leds on and off again:

$ encled led --help         
usage: encled led [-h] [-e ENC] [-d DISK] {locate,fault,off}

positional arguments:
  {locate,fault,off}    select the led to turn on/off.

optional arguments:
  -h, --help            show this help message and exit
  -e ENC, --enc ENC     the enclosure of interest.
  -d DISK, --disk DISK  the disk of interest.

The difference between locate and fault depends on your specific hardware. The supermicro shelf used for testing had only one LED per disk for fault and locate. The locate command makes it blinking, the fault command turns it on continuously.

To turn on all LEDs of a specific enclosure run:

$ encled led --enc /dev/sg24 locate

To locate one specific disk run:

$ encled led --disk 35000cca01aa9437c locate

The --disk flag understands the same arguments as it does within the status operation.

List

list is intended to be used within other scripts. It can create lists of devices in formats other commands expect. Currently zpool create, pcs stonith create, and plain /dev/sd* device lists are supported.

$ encled list --help
usage: encled list [-h] --type {zpool-create,fence-mpath,dev-sd}
                   [--vdev-size VDEV_SIZE] [--vdev-type VDEV_TYPE]
                   [--first-disk FIRST_DISK] [--last-disk LAST_DISK] [-e ENC]

optional arguments:
  -h, --help            show this help message and exit
  --type {zpool-create,fence-mpath,dev-sd}
                        select the type of device list to create.
  --vdev-size VDEV_SIZE
                        number of devices within one vdev.
  --vdev-type VDEV_TYPE
                        type to use in device list for zpool-create.
  --first-disk FIRST_DISK
                        Number between 1 and the total number of disks.
  --last-disk LAST_DISK
                        Number between 1 and the total number of disks.
  -e ENC, --enc ENC     the enclosure of interest.

Create a ZFS pool from all available disks:

zpool create NAME_OF_POOL $(encled list --type zpool-create --vdev-size 6)

For a 24-disk-shelf, the command above results in:

zpool create NAME_OF_POOL raidz2 35000cca01aab63e4 35000cca01aaaeb18 35000cca01aaaeccc 35000cca01aab559c 35000cca01aa9aa58 35000cca01aa9b2b0 raidz2 35000cca01aaaeaa4 35000cca01aa9437c 35000cca01aab56c8 35000cca01aaae048 35000cca01aab5ec0 35000cca01aab4818 raidz2 35000cca01aab4434 35000cca01aa71a80 35000cca01aa6e7cc 35000cca01aab558c 35000cca01aab110c 35000cca01aab0be0 raidz2 35000cca01aab48e4 35000cca01aab4838 35000cca01aa79c10 35000cca01aa8b2e8 35000cca01aa9a830 35000cca01aaaa01c

It is also possible to use only a part of a shelf:

zpool create NAME_OF_POOL $(encled list --type zpool-create --vdev-size 6 --first-disk 1 --last-disk 6)

--type zpool-create makes use of the SCSI-ID of the disks. The --type fence-mpath makes use of the devices listed in /dev/mapper:

pcs stonith create NAME_OF_FENCE fence_mpath pcmk_host_list=HOSTNAME key=RESERVATION_KEY devices="$(encled list --type fence-mpath)" meta provides=unfencing

The command above expands to something like:

pcs stonith create NAME_OF_FENCE fence_mpath pcmk_host_list=HOSTNAME key=RESERVATION_KEY devices="/dev/mapper/35000cca01aab63e4,/dev/mapper/35000cca01aaaeb18,/dev/mapper/35000cca01aaaeccc,/dev/mapper/35000cca01aab559c,/dev/mapper/35000cca01aa9aa58,/dev/mapper/35000cca01aa9b2b0,/dev/mapper/35000cca01aaaeaa4,/dev/mapper/35000cca01aa9437c,/dev/mapper/35000cca01aab56c8,/dev/mapper/35000cca01aaae048,/dev/mapper/35000cca01aab5ec0,/dev/mapper/35000cca01aab4818,/dev/mapper/35000cca01aab4434,/dev/mapper/35000cca01aa71a80,/dev/mapper/35000cca01aa6e7cc,/dev/mapper/35000cca01aab558c,/dev/mapper/35000cca01aab110c,/dev/mapper/35000cca01aab0be0,/dev/mapper/35000cca01aab48e4,/dev/mapper/35000cca01aab4838,/dev/mapper/35000cca01aa79c10,/dev/mapper/35000cca01aa8b2e8,/dev/mapper/35000cca01aa9a830,/dev/mapper/35000cca01aaaa01c" meta provides=unfencing

The --type dev-sd outputs a plain list of /dev/sd* device names, one per line:

$ encled list --type dev-sd
/dev/sda
/dev/sdb
...

About

Control fault/locate indicators in disk slots in enclosures (SES devices)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%