4 Commits
v0.3 ... master

Author SHA1 Message Date
Berthold Höllmann
c33c05ae67 Add support for setting power LED via systemctl (#60)
Some checks failed
Build kernel module for TrueNAS / build-and-run (push) Has been cancelled
* Add support for setting power LED via systemctl

* Add documentation for rudimentary ugreen-power-led.service

* Add "Type=oneshot" and "RemainAfterExit=true" as suggested
2025-06-12 10:14:48 +08:00
Thomas
dc04db484c Don't mark drives in standby as failed (#59)
Some checks failed
Build kernel module for TrueNAS / build-and-run (push) Has been cancelled
The standby return code of smartctl is updated to 0 to avoid detecting it as a failure.
2025-06-07 11:31:44 +08:00
Thomas
276ae34cd1 Update ugreen-diskiomon to ignore smartctl non-critical return codes (#57)
Some checks failed
Build kernel module for TrueNAS / build-and-run (push) Has been cancelled
Smartctl will also return non-zero if it detected past errors even when currently no other errors are observed. It will set up to 8 bits to indicate the differen types of observed results, where bit 5 does not indicate a _current_ error: `SMART status check returned "DISK OK" but some attributes have been at or below threshold in the past.`

The change ignores bit 5 (= 32) when checking the exit code.

Future improvements could detect other bits to color the leds differently depending on the type of error (f.e. bit 4 might indicate a future problem and could turn the led orange instead of red)
2025-06-04 17:33:44 +08:00
Yuhao Zhou
af2b3c327a add license (#54)
Some checks failed
Build kernel module for TrueNAS / build-and-run (push) Has been cancelled
2025-04-12 22:49:48 +08:00
6 changed files with 64 additions and 2 deletions

View File

@@ -210,11 +210,13 @@ Please see `scripts/ugreen-leds.conf` for an example.
# change enp2s0 to the network device you want to monitor
systemctl start ugreen-netdevmon@enp2s0
systemctl start ugreen-diskiomon
systemctl start ugreen-power-led
# if you confirm that everything works well,
# run the command below to make the service start at boot
systemctl enable ugreen-netdevmon@enp2s0
systemctl enable ugreen-diskiomon
systemctl enable ugreen-power-led
```
- (_Optional_) To reduce the CPU usage of blinking LEDs when disks are active, you can enter the `scripts` directory and do the following things:

View File

@@ -0,0 +1,13 @@
[Unit]
Description=UGREEN LEDs daemon for configuring power LED
After=ugreen-probe-leds.service
Requires=ugreen-probe-leds.service
[Service]
Type=oneshot
ExecStart=/usr/bin/ugreen-power-led
RemainAfterExit=true
StandardOutput=journal
[Install]
WantedBy=multi-user.target

View File

@@ -274,10 +274,13 @@ if [ "$CHECK_SMART" = true ]; then
dev=${devices[$led]}
/usr/sbin/smartctl -H /dev/${dev} -n standby,1 &> /dev/null
# read the smart status return code, but ignore if the drive is on standby
/usr/sbin/smartctl -H /dev/${dev} -n standby,0 &> /dev/null
RET=$?
if [[ $RET -gt 1 ]]; then
# check return code for critical errors (any bit set except bit 5)
# possible return bits set: https://invent.kde.org/system/kpmcore/-/merge_requests/28
if (( $RET & ~32 )); then
echo "$COLOR_SMART_FAIL" > /sys/class/leds/$led/color
echo Disk failure detected on /dev/$dev at $(date +%Y-%m-%d' '%H:%M:%S)
continue

View File

@@ -110,3 +110,17 @@ COLOR_NETDEV_LINK_10000="255 255 255"
# color of the netdev when unable to ping the gateway
COLOR_NETDEV_GATEWAY_UNREACHABLE="255 0 0"
# =========== parameters for power LED ===========
# Blink settings for the power LED
# * none: no blinking (default)
# * breath <delay_on> <delay_off>: breathing blink
# * blink <delay_on> <delay_off>: blinking
BLINK_TYPE_POWER="none"
# brighness of the power LED (default: 255)
BRIGHTNESS_POWER=255
# color of the power LED (default: 255 255 255)
COLOR_POWER="255 255 255"

30
scripts/ugreen-power-led Normal file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/bash
# use variables from config file (unRAID specific)
if [[ -f /boot/config/plugins/ugreenleds-driver/settings.cfg ]]; then
source /boot/config/plugins/ugreenleds-driver/settings.cfg
fi
# load environment variables
if [[ -f /etc/ugreen-leds.conf ]]; then
source /etc/ugreen-leds.conf
fi
# Blink settings for the power LED
# * none: no blinking
# * breath <delay_on> <delay_off>: breathing blink
# * blink <delay_on> <delay_off>: blinking
BLINK_TYPE_POWER=${BLINK_TYPE_POWER:="none"}
# brighness of the power LED
BRIGHTNESS_POWER=${BRIGHTNESS_POWER:=255}
# color of the power LED
COLOR_POWER=${COLOR_POWER:="255 255 255"}
# initialize LEDs
if [[ -d /sys/class/leds/power ]]; then
echo "$BLINK_TYPE_POWER" > /sys/class/leds/power/blink_type
echo "$BRIGHTNESS_POWER" > /sys/class/leds/power/brightness
echo "$COLOR_POWER" > /sys/class/leds/power/color
fi