Skip to content

Commit

Permalink
add ATA disk mapping, zpool check, netdev check, and a config file (#15)
Browse files Browse the repository at this point in the history
1. Add the config file /etc/ugreen-leds.conf for environment variables used in ugreen-diskiomon (see scripts/ugreen-leds.conf)
2. Make the blinking of netdev activities, colors of different disk states / NIC link speeds configurable
3. Add the check of zpool health
4. Add the check of gateway connectivity and the link speed of network device
5. Split the systemd service to ugreen-diskiomon.service and ugreen-netdevmon@<device name>.service
6. HCTL mapping will fail in some cases (hctl mapping for SATA drives only #14), UGOS uses ATA number to map disks to slots. I changed the default mapping to ATA, which can be shown by the following scripts:
  • Loading branch information
miskcoo committed Jun 21, 2024
1 parent 1dbc4c4 commit 522f93b
Show file tree
Hide file tree
Showing 7 changed files with 400 additions and 91 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ To blink the `disk` LED when a block device is active, you can use the `ledtrig-

#### Start at Boot (for Debian 12)

The configure file of `ugreen-diskiomon` and `ugreen-netdevmon` is `/etc/ugreen-led.conf`. Please see `scripts/ugreen-leds.conf` for an example.

- Edit `/etc/modules-load.d/ugreen-led.conf` and add the following lines:
```
i2c-dev
Expand All @@ -163,27 +165,36 @@ ledtrig-netdev

- Copy files in the `scripts` directory:
```bash
# copy the scripts
scripts=(ugreen-diskiomon ugreen-netdevmon ugreen-probe-leds)
for f in ${scripts[@]}; do
chmod +x "scripts/$f"
cp "scripts/$f" /usr/bin
done
# copy the configuration file, you can change it if needed
cp scripts/ugreen-leds.conf /etc/ugreen-leds.conf
# copy the systemd services
cp scripts/*.service /etc/systemd/system/
systemctl daemon-reload
# change enp2s0 to the network device you want to monitor
systemctl start ugreen-ledmon@enp2s0
systemctl start ugreen-netdevmon@enp2s0
systemctl start ugreen-diskiomon
# if you confirm that everything works well,
# run the command below to make the service start at boot
systemctl enable ugreen-ledmon@enp2s0
systemctl enable ugreen-netdevmon@enp2s0
systemctl enable ugreen-diskiomon
```

## Disk Mapping

To make the disk LEDs useful, we should map the disk LEDs to correct disk slots. First of all, we should highlight that using `/dev/sdX` is never a smart idea, as it may change at every boot. In the script `ugreen-diskiomon` we provide two mapping methods: **by HCTL** and **by serial**.
To make the disk LEDs useful, we should map the disk LEDs to correct disk slots. First of all, we should highlight that using `/dev/sdX` is never a smart idea, as it may change at every boot. In the script `ugreen-diskiomon` we provide three mapping methods: **by ATA**, **by HCTL** and **by serial**.

The best mapping method is using serial numbers, but it needs to record them manually and fill the `DISK_SERIAL` array in `/etc/ugreen-leds.conf`. We use ATA mapping by default, and find that UGOS also uses a similar mapping method (see [#15](https://github.com/miskcoo/ugreen_dx4600_leds_controller/pull/15)). See the comments in `scripts/ugreen-leds.conf` for more details.

The HCTL mapping depends on how the SATA controllers are connected to the PCIe bus and the disk slots. To check the HCTL order, you can run the following command, and check the serial of your disks:

Expand All @@ -200,7 +211,7 @@ sdg 6:0:0:0 XXKH3SXX
sdh 7:0:0:0 XXJDB1XX
```

As far as we know, the mapping between HCTL and the disk serial are stable at each boot (see [#4](https://github.com/miskcoo/ugreen_dx4600_leds_controller/pull/4) and [#9](https://github.com/miskcoo/ugreen_dx4600_leds_controller/issues/9)). However, it has been reported that the exact order is model-dependent (see [#9](https://github.com/miskcoo/ugreen_dx4600_leds_controller/issues/9)). In DX4600 Pro and DXP8800 Plus, the mapping is `X:0:0:0 -> diskX`, but In the DXP6800 Pro, `0:0:0:0` and `1:0:0:0` are mapped to `disk5` and `disk6`, and `2:0:0:0` to `6:0:0:0` are mapped to `disk1` to `disk4`, so you should change the array `hctl_map` in `ugreen-diskiomon` accordingly.
As far as we know, the mapping between HCTL and the disk serial are stable at each boot (see [#4](https://github.com/miskcoo/ugreen_dx4600_leds_controller/pull/4) and [#9](https://github.com/miskcoo/ugreen_dx4600_leds_controller/issues/9)). However, it has been reported that the exact order is model-dependent (see [#9](https://github.com/miskcoo/ugreen_dx4600_leds_controller/issues/9)). In DX4600 Pro and DXP8800 Plus, the mapping is `X:0:0:0 -> diskX`, but in DXP6800 Pro, `0:0:0:0` and `1:0:0:0` are mapped to `disk5` and `disk6`, and `2:0:0:0` to `6:0:0:0` are mapped to `disk1` to `disk4`. The script will use `dmidecode` to detect the device model, but I suggest to check the mapping outputed by the script manually.

## Communication Protocols

Expand Down
Loading

0 comments on commit 522f93b

Please sign in to comment.