LEDs on GoFlex Net September 14, 2013 08:32AM |
Registered: 11 years ago Posts: 168 |
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # For LED control on Seagate GoFlex Net that's been Debianised # (c) Don Charisma 2013 - http://DonCharisma.com iostat -z 1 | awk -W interactive ' BEGIN { sda="none"; sda_prev="none"; sdb="none"; sdb_prev="none"; md1="none"; md1_prev="none"; cpu20="none"; cpu20_prev="none"; cpu40="none"; cpu40_prev="none"; cpu60="none"; cpu60_prev="none"; cpu80="none"; cpu80_prev="none"; cpu_utilise=0 } # if hard drives or RAID active, set flag for LED /sda/ { sda="timer"; } /sdb/ { sdb="timer"; } /md1/ { md1="default-on"; } # Find the line with CPU info, pick the last number = percentage idle # subtract it from 100 to give CPU utilisation /\..*\..*\..*\..*\..*\..*/ { cpu_utilise = 100 - $6; if (cpu_utilise >= 20.0) { cpu20="default-on"; } if (cpu_utilise >= 40.0) { cpu40="default-on"; } if (cpu_utilise >= 60.0) { cpu60="default-on"; } if (cpu_utilise >= 80.0) { cpu80="default-on"; } } /Device:/ { if (sda != sda_prev) { print sda > "/sys/class/leds/status:white:left0/trigger"; fflush( "/sys/class/leds/status:white:left0/trigger" ); } if (sdb != sdb_prev) { print sdb > "/sys/class/leds/status:white:left1/trigger"; fflush( "/sys/class/leds/status:white:left1/trigger" ); } if (md1 != md1_prev) { print md1 > "/sys/class/leds/status:white:left2/trigger"; fflush( "/sys/class/leds/status:white:left2/trigger" ); print md1 > "/sys/class/leds/status:white:left3/trigger"; fflush( "/sys/class/leds/status:white:left3/trigger" ); } if (cpu20 != cpu20_prev) { print cpu20 > "/sys/class/leds/status:white:right0/trigger"; fflush( "/sys/class/leds/status:white:right0/trigger" ); } if (cpu40 != cpu40_prev) { print cpu40 > "/sys/class/leds/status:white:right1/trigger"; fflush( "/sys/class/leds/status:white:right1/trigger" ); } if (cpu60 != cpu60_prev) { print cpu60 > "/sys/class/leds/status:white:right2/trigger"; fflush( "/sys/class/leds/status:white:right2/trigger" ); } if (cpu80 != cpu80_prev) { print cpu80 > "/sys/class/leds/status:white:right3/trigger"; fflush( "/sys/class/leds/status:white:right3/trigger" ); } sda_prev=sda; sda="none"; sdb_prev=sdb; sdb="none"; md1_prev=md1; md1="none"; cpu20_prev=cpu20; cpu20="none"; cpu40_prev=cpu40; cpu40="none"; cpu60_prev=cpu60; cpu60="none"; cpu80_prev=cpu80; cpu80="none"; } END { print "The end"; } ' & exit 0
# for iostat apt-get install sysstat
Re: LEDs on GoFlex Net September 22, 2013 12:54PM |
Registered: 11 years ago Posts: 168 |