Cloudshell 2 HW Raid 1 error notifications?

Moderators: mdrjr, odroid

Cloudshell 2 HW Raid 1 error notifications?

Unread postby goonieg » Sat Dec 16, 2017 5:37 am

I've been scouring the forums, and wiki pages and can't seem to find any info on this. (Googling "fakeraid" or "hardware raid" or jms561 and linux etc doesn't offer any info either.)

Does anyone know if it is possible to capture (or rather, for Linux to capture) if the jms561 RAID 1 is in a degraded state? It would be useful to know, and notify the end user automatically (via e-mail etc) if one of the RAID1 HDDs have failed. (Otherwise, you would have to periodically remember to check using the raidmgr_static software). If the raidmgr_static software could be run with commandline options and just return a result, I could see creating a cronjob to monitor that, and send an e-mail. But I don't think this is the case, and can't find any documentation that says this.

Perhaps I'm missing something? Its hard to test what actually happens, short of pulling a drive. Is an event triggered in the kernel? A smart status?

Steve
goonieg
 
Posts: 8
Joined: Fri Dec 15, 2017 1:23 am
languages_spoken: english
ODROIDs: XU4Q, Cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby goonieg » Sun Dec 17, 2017 3:48 pm

If anyone is curious, I decided to just try and see what happens when an error occurs by simulating a drive failure (i.e. I pulled one drive while the OpenMediaVault system was active ;)).
Anyhow, the (somewhat anticlimactic) answer seems to be....nothing (unless i missed something?).
No indication of a failure on the LCD, one HDD LED went out (obviously! ;)) no kernel message that I could see, nothing in the dmesg kernel ring buffer. I also didn't see anything in any of the /var/log logs, and I even looked through /sys/*, and /proc/* and couldn't see anything jumping out at me. (was hoping some kernel module would know, but I guess the implementation details are hidden from the OS behind the JMS561?)

The only indication that there is an issue was by using raidmgr_static console software, and sending a SR C0 command, to see that the Raid status was "Degrade". Too bad there isn't some sort of raid manager daemon that could be running (like I'm sure jmicron has for windows, or x86).

This isn't really an ideal situation, (unless you can remember to manually monitor the jmicron RAID status periodically), especially if you want to use it as your fairly reliable, always available backup destination. A degraded RAID really does need to dealt with sooner rather then later, otherwise you chance the other drive failing and your backups and file histories are gone. (feel like it happens more often then you think, especially when drives are purchased together, similar manufacturing dates, batch numbers etc.).

Anyhow, now that I know, I can come up with a workaround.
I realise I could just use the Linux Software RAID1 (mdadm etc), and configure it for e-mail notifications etc, but where's the fun in that? (oh, and according to the wiki on performance, I'd loose about 50% of the speed!).

So I have a 2 ideas kicking around in my head, and will flesh them out a little bit, and share them hopefully in the next few days when I get a chance to work on some scripting and/or code.
goonieg
 
Posts: 8
Joined: Fri Dec 15, 2017 1:23 am
languages_spoken: english
ODROIDs: XU4Q, Cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby neal » Mon Dec 18, 2017 11:27 pm

goonieg wrote:the Raid status was "Degrade".

That is very useful to make something to do.
so, I have a tiny script that I hope to help you.
Code: Select all
root@odroidxu4 # while true
do
./raidmgr_static << endl >> ./raidStatus.log
SR C0
EX
endl
sleep 1
if [ "$(grep Degrade ./raidStatus.log | wc -l)" -ne 0 ];
then
echo "Status not good"
else
echo "Status good"
fi
done
neal
 
Posts: 146
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby goonieg » Tue Dec 19, 2017 2:27 pm

I've been plugging away at a few things related to this already, but thanks for the nice little script, @neal. Your tiny script makes me want to just re-write mine as a bash script now!. Not sure why I didn't do that from the beginning. I guess I like to make things more complicated than necessary?! ;)
In anycase, I've included in this post my alpha implementation using "expect", and a modification of /bin/cloudshell-lcd for alpha testing purposes. Check them out and modify/improve/test!

From digging through raidmgr_static, I believe the only Raid Status' reported by raidmgr_static are:
Broken
Degrade
Rebuilding
Normal

These were found through actually looking for strings inside the executable (and some testing).

Knowing these status', I've been working on a combination of an "expect" script to check the raid status (by interacting with raidmgr_static), and once the status is known, to send out an e-mail (if the status is "Broken" or "Degrade"). It also updates a status text file in /var/log that works with a modified "cloudshell-lcd" to show the current RAID status on the LCD. (I've also modified the script to output disk usage of /dev/md? devices for linux software raids. The original script seems to only check for /dev/sd? devices.)

Here's the combination of code I have so far. It is far from ready (i.e. very alpha ;), and still needs to be incorporated into a service that runs periodically. The "expect" script assumes that postfix has been configured, and works to send e-mail (I just used the GUI in OpenMediaVault, rather than editing the appropriate files in /etc/postfix)
There are some features that still need to be implemented, like:
1) Only send 1 e-mail per day/hour or whatever, so it doesn't constantly send a RAID status error message everytime the script is run.
2) Better logging
3) Better email message text
4) Set up as a service that runs periodically (right now, I've just set it up as a cronjob)
5) ??

For the LCD, the modified /bin/cloudshell-lcd uses an application called "figlet" that needs to be installed. It is used to display large ascii-art words that show the current RAID status. (apt install figlet)

I'll think I'll set up a github repository at some point for these scripts, but for now I'll post the very alpha code here:
If you're interested in playing with these scripts or modifiying/improving/testing them:
Make sure to change the FROMEMAIL and TOEMAIL variables, if you want to receive e-mails.

****NOTE: This below expect script is deprecated, and doesn't work well. See the bash script posted in my next post below.

/usr/local/bin/checkRaid.exp
Code: Select all
#!/usr/bin/expect
set FROMEMAIL "FROMEMAIL@ADDRESS.COM(FROM NAME)"
set TOEMAIL "TOEMAIL@ADDRESS.COM"
set raidstatus ""
set matched ""
set LOGFILE [open "/var/log/jmicronLog.log" w]
set RAIDSTATUSFILE [open "/var/log/RAID_STATUS4LCD" w]
spawn "/usr/bin/raidmgr_static"
expect "JMS56X>"
send "SR C0\n"

expect "JMS56X>"

set resultbuffer $expect_out(buffer)
#DOS TO UNIX LINE ENDINGS.  PROBABLY DON'T NEED
set resultbuffer2 [string map {"\r\n" "\n"} $resultbuffer]

regexp {RaidStatus.*?= (.*?)\n} $resultbuffer2 matched raidstatus


set systemTime [clock seconds]
puts $LOGFILE "[clock format $systemTime -format %Y-%m-%d\ %T]"
puts $LOGFILE "***Buffer***\n$resultbuffer2 \n****\n"
puts $LOGFILE "***REGEX MATCH***\n$matched \n***\n"
puts $LOGFILE "***RaidStatus is: $raidstatus ***\n"

##Possible RAID STATES
##Broken
##Degrade
##Rebuilding
##Normal


switch $raidstatus {
  Degrade {
    puts $RAIDSTATUSFILE "Degraded"
    puts $LOGFILE "\n\n!!!RAID IS DEGRADED!!!\n"
    set EMAILBODY [open "/tmp/raidMailMessage.txt" w]
    puts $EMAILBODY "Your RAID is in a DEGRADED STATE\n\nInvestigate and repair as soon as possible..."
    close $EMAILBODY
    exec mailx -a "From:${FROMEMAIL}" -s "!!!DEGRADED RAID!!!" ${TOEMAIL} < /tmp/raidMailMessage.txt &
  }
  Broken {
    puts $RAIDSTATUSFILE "Broken"
    puts $LOGFILE "\n\n!!!RAID IS BROKEN!!!\n"
    set EMAILBODY [open "/tmp/raidMailMessage.txt" w]
    puts $EMAILBODY "Your RAID is in a BROKEN STATE\n\nInvestigate and repair as soon as possible..."
    close $EMAILBODY
    exec mailx -a "From:${FROMEMAIL}" -s "!!!BROKEN RAID!!!" ${TOEMAIL} < /tmp/raidMailMessage.txt &
  }
  Rebuilding {
    puts $RAIDSTATUSFILE "Rebuilding"
    puts $LOGFILE "\n\nRAID is Rebuilding\n"
    set EMAILBODY [open "/tmp/raidMailMessage.txt" w]
    puts $EMAILBODY "Your RAID is currently rebuilding..."
    close $EMAILBODY
    exec mailx -a "From:${FROMEMAIL}" -s "Rebuilding RAID" ${TOEMAIL} < /tmp/raidMailMessage.txt &   
  }
  Normal {
    puts $RAIDSTATUSFILE "Normal"
    puts $LOGFILE "\n\nRAID is Normal\n"
  }
  default {
    puts $RAIDSTATUSFILE "Unknown"
    puts $LOGFILE "\n\nUNKNOWN RAID STATUS"
    set EMAILBODY [open "/tmp/raidMailMessage.txt" w]
    puts $EMAILBODY "Your RAID status is unknown. Perhaps you haven't configured the JMicron as a RAID?"
    close $EMAILBODY
    exec mailx -a "From:${FROMEMAIL}" -s "UNKNOWN RAID STATUS" ${TOEMAIL} < /tmp/raidMailMessage.txt &
  }
}

close $LOGFILE
close $RAIDSTATUSFILE
send "EX\n"
puts "\n"


/bin/cloudshell-lcd
Code: Select all
#!/bin/bash
# hardkernel CloudShell Screen update
#
# requires the following packages:
# curl sysstat figlet
# Steve's Mod - display disk usage of /dev/md? devices
#    -Read a raid status, and display on screen
#
#

############## Configuration

# Disable LCD Slepp mode
echo -e '\033[9;0]' > /dev/tty1

# console font
# More fonts on: /usr/share/consolefonts
export TERM="linux"
#export CONSOLE_FONT="Lat7-Fixed13"
#export CONSOLE_FONT="Lat7-Fixed18"
export CONSOLE_FONT="Lat15-Terminus12x6"
#export CONSOLE_FONT="Lat15-Terminus14"

# Output Console (ttyX)
export OUTPUT_CONSOLE="1"

# Network Interface: enx001e06323348, wlan0, ....
export NETIF=eth0

# Screen refresh in seconds
export REFRESH="1"

# CPU Temperature in C or F
export TEMPERATURE_FORMAT="C"

# External IP Refresh counts
# The time to update the ip in counts is acquired by using the following formula
# seconds_to_refresh = EXT_IP_REFRESH * REFRESH
export EXT_IP_REFRESH="10"

# assign the script to cpu0
PID=$$
taskset -cp 1 $PID

get_external_ip() {
   export EXTERNAL_IP=$(/usr/bin/curl -s http://mdrjr.net/ip.php)
}

get_full_date() {
   export DATE=$(date +"%Y-%m-%d %H:%M:%S")
}

get_hostname() {
   export HOSTNAME=$(hostname)
}

get_os_distributor() {
   export OS_DISTRIBUTOR=$(lsb_release -i | awk '{ print $3 }')
}

get_internal_ip() {
   export INTERNAL_IP=$(hostname -I | cut -d ' ' -f 1)
}

get_ethernet_speed() {
   export SPEED_ETH0=$(cat /sys/class/net/eth*/speed)
}

get_net_tx_rx_realtime() {
   local net_txrx=($(sar -n DEV 1 1 | awk '$2 == "'$NETIF'" {printf "%.1f %.1f", $5/1024, $6/1024; exit;}'))
   export NET_TX=${net_txrx[0]}
   export NET_RX=${net_txrx[1]}
}

get_disk_mount_info() {
   SATA=($(awk '/^\/dev\/[ms]d/ {printf "%s ", $1}' /proc/mounts))
}

get_disk_info() {
   local t=$(df -h)
   local iostat=$(iostat -y -m 1 1)

   for i in "${!SATA[@]}"
   do
      # escape / --> \/
      escaped_regex="${SATA[$i]//\//\\/}"
      #DISK_SIZE[$i]=$(echo "$t" | awk '/^'"$escaped_regex"'/ {print $2}')
      DISK_USED[$i]=$(echo "$t" | awk '/^'"$escaped_regex"'/ {print $3}')
      DISK_FREE[$i]=$(echo "$t" | awk '/^'"$escaped_regex"'/ {print $4}')
      DISK_USED_PCT[$i]=$(echo "$t" | awk '/^'"$escaped_regex"'/ {print $5}')

      local SAT=$(expr "${SATA[$i]#"/dev/"}" : '\([a-z]*\)')
      DISK_R[$i]=$(echo "$iostat" | awk '/^'"$SAT"'/ {print $3}')
      DISK_W[$i]=$(echo "$iostat" | awk '/^'"$SAT"'/ {print $4}')
   done
}

get_disk_temperature() {
   for i in "${!SATA[@]}"
   do
      # declare and assign variable seperately to avoid masking return value
      DISK_TEMP[$i]=" (IDLE)"
      if (( ${DISK_R[$i]%.*} > 0 )) || (( ${DISK_W[$i]%.*} > 0 ))
      then

         local t
         t=$(smartctl -a "${SATA[$i]}" -d sat | grep "Temp")
         if (( $? == 0 ))
         then
            local temp=$(echo $t | awk '{print $10}')
            DISK_TEMP[$i]="${CRED} Temp: $temp$TEMPERATURE_FORMAT"
         else
            DISK_TEMP[$i]=""
         fi
      fi
   done
}

get_memory_info() {
   # in Mbytes
   export MEM_AVAILABLE=$(awk '/^MemAvailable:/ {printf "%d", $2/1024}' /proc/meminfo)
   export MEM_TOTAL=$(awk '/^MemTotal:/ {printf "%d", $2/1024}' /proc/meminfo)
   export MEM_USED=$((MEM_TOTAL - MEM_AVAILABLE))
}

get_system_info() {
   export UBUNTU_VERSION=$(lsb_release -r | awk '{print $2}')
   export KERNEL_VERSION=$(uname -r | awk -F "-" '{print $1}')
}

get_cpu_usage() {
   export CPU_USAGE=$(mpstat 1 1 | awk '/Average/ {printf "%.1f", 100-$12}')
}

get_cpu_clock() {
   speed_a7=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
   speed_a15=$(cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq)
   export SPEED_CPU_A7="$((speed_a7/1000))"
   export SPEED_CPU_A15="$((speed_a15/1000))"
}

get_cpu_temperature() {
   _t=$(($(</sys/class/thermal/thermal_zone0/temp) / 1000))
   if [ "$TEMPERATURE_FORMAT" = "C" ]; then
      export CPU_TEMP="$_t"C
   else
      _t1=$((_t * 9 / 5 + 32))
      export CPU_TEMP="$_t1"F
   fi
}

get_samba_connections() {
   if [ ! -f /usr/bin/smbstatus ]; then
      export SAMBA_CONNECTIONS=0
   else
      export SAMBA_CONNECTIONS=$(smbstatus -b | grep -c ipv)
   fi
}

get_nfs_connections() {
   export NFS_CONNECTIONS=$(netstat -an | grep 2049 | grep -c ESTA)
}

get_process_count() {
   export PROCESS_COUNT=$(ps xa | wc -l)
}

# local variables
ext_ip_refresh_c=0
COFF=$(tput sgr0)
CBRED=$(tput setab 1)
CBBLACK=$(tput setab 0)
CBLACK=$(tput setaf 0)
CGREEN=$(tput setaf 2)
CRED=$(tput setaf 1)
CBLUE=$(tput setaf 6)
CWHITE=$(tput setaf 7)

oc="/dev/tty$OUTPUT_CONSOLE"

# font setup
setfont $CONSOLE_FONT > $oc

# Ensure that we are in the right TTY
chvt $OUTPUT_CONSOLE

# infinite loop
while true; do

   # Ensure that we are in the right TTY
   chvt $OUTPUT_CONSOLE

   # check if EXT_IP_REFRESH
   #if (( (ext_ip_refresh_c % EXT_IP_REFRESH) == 0 )); then
   #   get_external_ip
   #fi
   
   # increment $ext_ip_refresh_c
   #ext_ip_refresh_c=$((ext_ip_refresh_c+1))

   # get data
   get_internal_ip
   get_ethernet_speed
   get_hostname
   get_os_distributor
   get_disk_mount_info
   get_disk_info
   get_disk_temperature
   get_full_date
   #get_net_tx_rx_realtime
   #get_memory_info
   get_system_info
   get_cpu_clock
   get_cpu_usage
   get_cpu_temperature
   #get_samba_connections
   #get_nfs_connections
   #get_process_count

   # clear the screen every loop
   # we only wipe the screen when we are ready to write data to it
   clear > $oc

   # format the data on screen
   echo -e "$CBLUE$HOSTNAME $COFF: $DATE" > $oc
   echo -e "$OS_DISTRIBUTOR $CGREEN$UBUNTU_VERSION$COFF       Kernel $CGREEN$KERNEL_VERSION$COFF" > $oc
   # line CPU Usage
   echo -e "CPU Usage: $CBLUE$CPU_USAGE%$COFF  CPU Temp: $CRED$CPU_TEMP$COFF" > $oc
   echo -e "A15 : $CBLUE$SPEED_CPU_A15 MHz$COFF   A7 : $CBLUE$SPEED_CPU_A7 MHz$COFF" > $oc
   # Line Memory
   #echo -e "Memory Free: $CBLUE$MEM_AVAILABLE MB$COFF   Used: $CBLUE$MEM_USED MB$COFF" > $oc
   # Line IP Addresses
   #echo -e "IP: $CBLUE$INTERNAL_IP$COFF Ext IP: $CBLUE$EXTERNAL_IP$COFF" > $oc
   echo -e "IP: $CBLUE$INTERNAL_IP$COFF @ $CBLUE$SPEED_ETH0 Mbps$COFF" > $oc
   # Line network usage
   #echo -e "TX: $CBLUE$NET_TX MB/s$COFF RX: $CBLUE$NET_RX MB/s$COFF" > $oc
   # Line Disk Space

   
   for i in "${!SATA[@]}"
   do
      echo "" > $oc
      echo -e "${SATA[$i]} ${DISK_TEMP[$i]}$COFF" > $oc
      echo -e "R/W $CBLUE${DISK_R[$i]}$COFF / $CBLUE${DISK_W[$i]}$COFF MB/s" > $oc
      echo -ne "Disk Used: $CBLUE${DISK_USED[$i]}$COFF ($CBLUE${DISK_USED_PCT[$i]}$COFF)  Free: $CBLUE${DISK_FREE[$i]}$COFF" > $oc
   done

   # Line Samba
   #echo -e "Samba Clients: $CBLUE$SAMBA_CONNECTIONS$COFF" > $oc
   # line NFS
   #echo -e "NFS Connections: $CBLUE$NFS_CONNECTIONS$COFF" > $oc
   # line Processes

#RAID STATUS
   if [ -f /var/log/RAID_STATUS4LCD ]; then
     RAID_STATUS4LCD=$(cat /var/log/RAID_STATUS4LCD)
     echo "" > $oc
     echo "" > $oc
     if [ "$RAID_STATUS4LCD" = "Normal" ]; then
       echo "Raid Status:${CGREEN}" > $oc
       figlet "$RAID_STATUS4LCD" > $oc
       echo "${COFF}" > $oc
     elif [ "$RAID_STATUS4LCD" = "Rebuilding" ]; then
       echo "Raid Status:${CBLUE}" > $oc
       figlet "$RAID_STATUS4LCD" > $oc
       echo "${COFF}" > $oc
     else
##ALTERNATE PRINT OUT STYLE
###       printf "Raid Status:\n${CBRED}!!!!!!!!!!!!!!!!!!!!\n!!${COFF}%*s%*s${CBRED}!!\n!!!!!!!!!!!!!!!!!!!!${COFF}% 20s ${COFF} \r\n${COFF} " $(((${#RAID_STATUS4LCD}+16)/2)) $RAID_STATUS4LCD $(((17-${#RAID_STATUS4LCD})/2)) > $oc
       echo "Raid Status:${CBRED}" > $oc
       figlet "$RAID_STATUS4LCD" > $oc
       echo "${COFF}" > $oc
     fi
   fi
   # sleep
   sleep $REFRESH

done

Last edited by goonieg on Tue Jan 16, 2018 2:56 pm, edited 2 times in total.
goonieg
 
Posts: 8
Joined: Fri Dec 15, 2017 1:23 am
languages_spoken: english
ODROIDs: XU4Q, Cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby goonieg » Thu Dec 21, 2017 4:33 am

If anyone is interested, it turns out that the scripting language "expect" and cron do not seem to play well together. Although the checkRAID.exp script posted above works when manually run from the terminal, it does weird things when run as a cron job (it is like there output from the raidmgr_static gets missed? Log file is mostly empty, etc, and so the raid status is falsely set to "Unknown", and thus getting many Raid Status Unknown e-mails that the script sends out.).

Instead of trying to figure out what was going on, I've re-implemented the script using bash (using the idea @neal posted), and it is actually quite a bit simpler. It is basically a direct port, and I still want to add the features I've previously mentioned. Seems to work great as a scheduled cronjob. (I just use the Open Mediavault scheduler to run this every 30min right now, and I haven't gotten any false "Raid status unknown e-mails". Will probably make it run more often in the future.)

Anyhow, here is the script. Don't forget to change the TO_EMAIL and FROM_EMAIL variables.

checkRAID.bash

Code: Select all
#!/bin/bash

RAID_MANAGER=/usr/bin/raidmgr_static
RAID_STATUS_FILE="/var/log/RAID_STATUS4LCD"
FROM_EMAIL="FROMEMAIL@ADDRESS.COM(ODROIDXU4)"
TO_EMAIL="TOEMAIL@ADDRESS.COM"
LOGFILE="/var/log/JMICRON_RAID_CONTROLLER.log"

date | tee $LOGFILE
##The Following call to the RAID manager using DC C0
#outputs the controller info, which is fairly detailed, and happens to also include the RAID status.
## SR C0  would work as well, but would only show information about the RAID.
$RAID_MANAGER << endl | tee -a $LOGFILE
DC C0
EX
endl
sleep 1

RAID_STATUS=`grep RaidStatus $LOGFILE | awk '{ print $NF }'`
echo | tee -a $LOGFILE
echo | tee -a $LOGFILE
echo "The current JMicron RAID controller status is: $RAID_STATUS" | tee -a $LOGFILE

##Possible RAID STATES
##Broken
##Degrade
##Rebuilding
##Normal

case $RAID_STATUS in
    Degrade)
      echo "Degraded" > $RAID_STATUS_FILE
      printf "`date`\nYour RAID is in a DEGRADED STATE!\n\nIt is recommended that an investigation and repair or \nreplacement of the failing drive be done as soon as possible.\nUse $RAID_MANAGER to determine which drive has failed.\n" | mailx -a "From: ${FROM_EMAIL}" -s "!!!DEGRADED RAID!!!" ${TO_EMAIL}
      ;;
  Broken)
      echo "Broken" > $RAID_STATUS_FILE
      printf "`date`\nYour RAID is in a BROKEN STATE!\n\nIt is recommended that an investigation and repair be done as soon as possible.\n" | mailx -a "From: ${FROM_EMAIL}" -s "!!!BROKEN RAID!!!" ${TO_EMAIL}
      ;;
  Rebuilding)
      echo "Rebuilding" > $RAID_STATUS_FILE
      printf "`date`\nYour RAID is currently rebuilding.\n" | mailx -a "From: ${FROM_EMAIL}" -s "Rebuilding RAID..." ${TO_EMAIL}
      ;;
  Normal)
      echo "Normal" > $RAID_STATUS_FILE
      printf "`date`\nYour RAID is Normal\n"
      ;;
  *)
      echo "Unknown" > $RAID_STATUS_FILE
      printf "`date`\nHmm, Not sure what's going on with the RAID.  Your RAID status is unknown. This isn't necessarily a bad thing, it just means we couldn't grab the status\n" | mailx -a "From $FROM_EMAIL" -s "Unknown RAID Status..." ${TO_EMAIL}
      ;;
esac
Last edited by goonieg on Fri Feb 23, 2018 6:58 pm, edited 1 time in total.
goonieg
 
Posts: 8
Joined: Fri Dec 15, 2017 1:23 am
languages_spoken: english
ODROIDs: XU4Q, Cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby goonieg » Thu Dec 21, 2017 5:11 am

If anyone is interested, here are the LCD screenshots, using the posted scripts (i.e. the modified cloudshell-lcd)
Normal Status
normal.png
normal.png (1.98 KiB) Viewed 3144 times


Rebuilding Status
Rebuilding.png
Rebuilding.png (2.04 KiB) Viewed 3144 times


Degraded Status
Degraded.png
Degraded.png (2.03 KiB) Viewed 3144 times


Broken Status
Broken.png
Broken.png (1.95 KiB) Viewed 3144 times


Unknown Status
Unknown.png
Unknown.png (2.01 KiB) Viewed 3144 times
goonieg
 
Posts: 8
Joined: Fri Dec 15, 2017 1:23 am
languages_spoken: english
ODROIDs: XU4Q, Cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby odroid » Thu Dec 21, 2017 10:15 am

Very artful and useful RAID status notification.
Thank you for sharing a nice idea.
User avatar
odroid
Site Admin
 
Posts: 28610
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby mad_ady » Thu Dec 21, 2017 1:27 pm

Regarding expect and cron, there are two things you should consider:
1. Cron uses a different environment than your shell, so you'll need to use absolute file paths everywhere
2. Some programs may need information such as the number of rows and columns from the controlling tty. When running from cron there is no controlling tty. You could either fake it and run your script inside screen or there are ways to bind a tcl program to an existing tty to inherit its attributes (I've used it for perl's Expect module).
Nice work on the ascii art!
User avatar
mad_ady
 
Posts: 4465
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby goonieg » Fri Dec 29, 2017 6:30 am

Ha, Thanks for the ascii art compliments, but alas I can't take any credit for it.
I'm using "figlet" in the script! :)

The large ascii-art was really meant to be a notification that was large, obvious and noticeable! (in addition to sending e-mails). The actual device is across the room, and I wanted to be able to glance at it from across the room and notice if it was in an error state! (i.e. If I see red, something is wrong!).

I may still play around with "expect" and cron, mostly just to learn it better, and see if I can get it to work (I suppose I could use screen?, but it just seems to be adding more and more complexity!).

Haven't really had time to make more code modifications over this holiday season, but I may get back to in in the next few days!
goonieg
 
Posts: 8
Joined: Fri Dec 15, 2017 1:23 am
languages_spoken: english
ODROIDs: XU4Q, Cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby rquaif » Tue Jan 16, 2018 6:02 am

Thank you :D for a great solution to my problem. It makes no sense to have a RAID 1 NAS device and not have a visual means of knowing it failed. I wanted to know if my RAID 1 was really working and when I started playing with your script I found that it wasn't running correctly. In short your idea saved me a huge problem in the future.

I found that removing the email feature and simplifying the status display to a single line of text was all I really need and I would highly recommend that Hardkernel add this feature to there cloudshell-lcd program and the Cloudshell 2 instructions.

By the way adding the status check to the crontab is easy.

*/10 * * * * /usr/bin/raidcheck.sh

Will check the raid status every 10 minutes (I called my status checker raidcheck.sh but it is your program without the email feature)

It would also help if Hardshell were to add a discussion to the Cloudshell 2 wiki about hardware vers software RAID. OMV makes it too easy to setup a software raid and that has poor performance on the XU4. You really should use the hardware raid and ignore the recommendations from OMV.
rquaif
 
Posts: 2
Joined: Tue Jan 16, 2018 5:39 am
languages_spoken: english
ODROIDs: XU4, CloudShell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby goonieg » Tue Jan 16, 2018 3:25 pm

Glad the the scripts helped you out.
Hah, yeah the large lettering is probably overkill depending on where the device is! I just wanted to see it from across the room, and notice something was wrong! :) Single line of block red text would probably work too ;) (I think I was just obsessed with the program "figlet" at the time ;)

For me, I've been finding e-mailing invaluable. Issues tend to come up for me after an OMV update overwriting the S.M.A.R.T modifications (posted elsewhere in the forum). Without the modifications, the USB/controller tends to crash, and isn't available, and I only know about it after I get e-mailed that the raid status is "Unknown".
I was worried about getting too many e-mails, but my crontab is set to run every 30min. (I used the OMV GUI to set up the job, rather than crontab -e. Was curious where it would put it. Turns out in /etc/cron.d/openmediavault-userdefined)

Steve
goonieg
 
Posts: 8
Joined: Fri Dec 15, 2017 1:23 am
languages_spoken: english
ODROIDs: XU4Q, Cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby neal » Tue Jan 23, 2018 1:44 pm

neal
 
Posts: 146
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby David.B » Tue Feb 06, 2018 3:02 am

I did something similar to this when I noticed it didn't have any notification either. What I'm finding is you can crash the Xu4 querying the raid manager too often. (I was only doing it once every 15m)

Has anyone else experienced this?

I'm on latest firmware 004.
Linux odroid 4.9.28-38 #1 SMP PREEMPT Mon May 15 22:34:14 UTC 2017 armv7l armv7l armv7l GNU/Linux
Release: 16.04
David.B
 
Posts: 26
Joined: Tue Jul 19, 2016 10:34 am
languages_spoken: english
ODROIDs: C2, Xu4

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby rooted » Tue Feb 06, 2018 5:30 pm

neal wrote:Please check the below link.
https://wiki.odroid.com/accessory/add-on_boards/xu4_cloudshell2/data_recovery
Thank you @goonieg
Thank you for wiki'fying it and @goonieg for the script.
User avatar
rooted
 
Posts: 5474
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby cadelle » Sat Feb 24, 2018 3:41 am

I am relatively inexperienced when it comes to Linux and it's variants; after setting up my cloudshell2 with 2x 4TB drives in RAID1 I wanted to verify that it was actually working. It appears that a lot of issues that I have read about may have already been adjusted in the image for OMV that I recently got from sourceforge. I didn't have to do anything for my LCD display to work or for the fan. I read about CPU governance but found it was already set to "ondemand". I digress, I did the hardware RAID1 setup and after doing it I noticed that the drive size adjusted accordingly but I couldn't find a way to make sure that it was actually working. I just want to make sure that I understand the steps involved for this implementation.

Am I correct in assuming that I need to create a file (i will use your example) called checkRAID.bash , then copy the script into it and save it?

After that I assume I will need to schedule this to run? I am using the wiki recommended OMV image at the moment. I am unfamiliar with crontab but can research its use and implementation. I just wanted to check there wasn't a way to do this via the OMV web interface.

EDIT #2: Found that I could do this System --> Scheduled jobs


Lastly I am not in need of the email notification part of this but am not comfortable enough with this code to strip it myself. Would you be willing to post an amended version that does not include this feature?

EDIT: To remove the email feature would I just need to remove the variable definitions at the top of the code and then the 'printf' lines of code?
EDIT #3: Follow up noob question: Should I decide to make use of the email notifications wouldn't I need to install some sort of email service for OMV? How would it actually accomplish the sending of the emails?

Thanks so much for creating a solution to the RAID status feature that is lacking currently.
cadelle
 
Posts: 47
Joined: Sat Feb 24, 2018 3:24 am
languages_spoken: english
ODROIDs: XU4, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby neal » Mon Feb 26, 2018 11:12 am

cadelle wrote:EDIT: To remove the email feature would I just need to remove the variable definitions at the top of the code and then the 'printf' lines of code?

Yes, It is better adding comment than removing for further to reuse.

cadelle wrote:EDIT #3: Follow up noob question: Should I decide to make use of the email notifications wouldn't I need to install some sort of email service for OMV? How would it actually accomplish the sending of the emails?

It uses mailx tool to get the email notification. You can see mailx command in the script and can install the command (# sudo apt-get install mailutils)
That is the internet mail service to send/receive using Linux command. You don't need to install the mail server.
neal
 
Posts: 146
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby cadelle » Tue Feb 27, 2018 6:25 am

to be clear, in order to add it as a comment I just need to put a '#' in front of the line correct?
cadelle
 
Posts: 47
Joined: Sat Feb 24, 2018 3:24 am
languages_spoken: english
ODROIDs: XU4, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby neal » Tue Feb 27, 2018 10:03 am

cadelle wrote:to be clear, in order to add it as a comment I just need to put a '#' in front of the line correct?

Yeap!
except '#!/bin/bash' in front of the first line.
neal
 
Posts: 146
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby cadelle » Fri Jun 01, 2018 6:56 am

running the script exactly as you posted it in this thread and have been working through some challenges. Using OMV trying to schedule from the GUI. user = root, command = /root/raidCHECK.bash

I am getting the following errors:

"/root/checkRAID.bash: line 13: /usr/bin/raidmgr_static: No such file or directory

The current JMicron RAID controller status is:
postdrop: warning: unable to look up public/pickup: No such file or directory"

I am no expert but it seems as if it is not able to pull the data to complete the status requirement. I definitely have a JMicorn board, could this be a permission issue for that directory or could it really just be somewhere else?

Your help is appreciated, thank you
cadelle
 
Posts: 47
Joined: Sat Feb 24, 2018 3:24 am
languages_spoken: english
ODROIDs: XU4, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby neal » Fri Jun 01, 2018 10:18 am

cadelle wrote:/root/checkRAID.bash: line 13: /usr/bin/raidmgr_static: No such file or directory


First of all, check "raidmgr_static" file to be in /usr/bin/ like
Code: Select all
# ls -l /usr/bin/raidmgr_static

If you'd get an error, you need to copy it to there.
neal
 
Posts: 146
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby cadelle » Fri Jun 01, 2018 11:29 pm

I would feel more comfortable trying to determine where it is and then adjusting your code to reflect the actual destination. I just worry that moving this file may lead to unforeseen circumstances with my RAID setup. Is there a command that will show me a file location?
cadelle
 
Posts: 47
Joined: Sat Feb 24, 2018 3:24 am
languages_spoken: english
ODROIDs: XU4, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby mad_ady » Fri Jun 01, 2018 11:44 pm

ls will not harm anything. You can try to search for your location of raidmgr_static with
Code: Select all
find / -name raidmgr_static
User avatar
mad_ady
 
Posts: 4465
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby cadelle » Fri Jun 01, 2018 11:58 pm

So two things were in my way...

1st I had recently reinstalled OMV to resolve another issue. The reason it couldn't find the file was because it wasn't there. After I installed the jmicron utility again it was in a different location but that is because I am always in root so it was root/raidmgr_static which was easy enough to make adjustments to and now I could this output when I executed my scheduled job:

Code: Select all
Fri Jun  1 07:52:43 PDT 2018

JMS56X HW RAID Manager V8.0.0.1
(C) 2008~2011 JMicron Tech, Corp. Command Line Interface RAID Manager For JMS56X.

JMS56X>
Controller[0]
-- ChipID       = 10
-- SerialNumber = 427491329
-- SuperUserPwd = ÿÿÿÿÿÿÿÿ
-- Sata[0]
------ ModelName    = WDC WD40EFRX-68N32N0                   
------ SerialNumber =      WD-WCC7K6VZ473Z
------ FirmwareVer  = 82.00A82
------ Capacity     = 3726 GB
------ PortType     = RAID Disk
------ PortSpeed    = Gen 3
------ Page0State   = Hooked to PM
------ Page0RaidIdx = 0
------ Page0MbrIdx  = 0
-- Sata[1]
------ ModelName    = WDC WD40EFRX-68N32N0                   
------ SerialNumber =      WD-WCC7K3PUX96T
------ FirmwareVer  = 82.00A82
------ Capacity     = 3726 GB
------ PortType     = RAID Disk
------ PortSpeed    = Gen 3
------ Page0State   = Hooked to PM
------ Page0RaidIdx = 0
------ Page0MbrIdx  = 1
-- Raid[0]
------ ModelName       = H/W RAID0                               
------ SerialNumber    = C3NS1P3OA6XSNHPI8GOG
------ Capacity        = 7451 GB
------ RaidStatus      = Normal
------ RaidLevel       = RAID 0
------ RaidMbrCount    = 2
------ RebuildPriority = 3
------ RaidMember[0]
--------- Ready        = 1
--------- LBA48Support = 1
--------- SataPage     = 0
--------- SataPort     = 0
--------- SataBase     = 0
--------- SataSize     = 3725 GB
------ RaidMember[1]
--------- Ready        = 1
--------- LBA48Support = 1
--------- SataPage     = 0
--------- SataPort     = 1
--------- SataBase     = 0
--------- SataSize     = 3725 GB
JMS56X>

The current JMicron RAID controller status is: Normal
Fri Jun  1 07:52:48 PDT 2018
Your RAID is Normal


Thanks for all the assistance!
cadelle
 
Posts: 47
Joined: Sat Feb 24, 2018 3:24 am
languages_spoken: english
ODROIDs: XU4, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby cadelle » Sat Jun 02, 2018 4:01 pm

So earlier I was working remotely. Upon arrival at home I am seeing that my lcd is not displaying the ASCII text-art words but the program appears to execute correctly. Any thoughts?

contents of checkRAID.bash
Code: Select all
#!/bin/bash

RAID_MANAGER=/root/raidmgr_static
RAID_STATUS_FILE="/var/log/RAID_STATUS4LCD"
#FROM_EMAIL="FROMEMAIL@ADDRESS.COM(ODROIDXU4)"
#TO_EMAIL="TOEMAIL@ADDRESS.COM"
LOGFILE="/var/log/JMICRON_RAID_CONTROLLER.log"

date | tee $LOGFILE
##The Following call to the RAID manager using DC C0
#outputs the controller info, which is fairly detailed, and happens to also inc$
## SR C0  would work as well, but would only show information about the RAID.
$RAID_MANAGER << endl | tee -a $LOGFILE
DC C0
EX
endl
sleep 1

RAID_STATUS=`grep RaidStatus $LOGFILE | awk '{ print $NF }'`


This is the output when executed from the scheduled tasks section of the omv gui

Code: Select all
Fri Jun  1 23:55:59 PDT 2018

JMS56X HW RAID Manager V8.0.0.1
(C) 2008~2011 JMicron Tech, Corp. Command Line Interface RAID Manager For JMS56X.

JMS56X>
Controller[0]
-- ChipID       = 10
-- SerialNumber = 427491329
-- SuperUserPwd = ÿÿÿÿÿÿÿÿ
-- Sata[0]
------ ModelName    = WDC WD40EFRX-68N32N0                   
------ SerialNumber =      WD-WCC7K6VZ473Z
------ FirmwareVer  = 82.00A82
------ Capacity     = 3726 GB
------ PortType     = RAID Disk
------ PortSpeed    = Gen 3
------ Page0State   = Hooked to PM
------ Page0RaidIdx = 0
------ Page0MbrIdx  = 0
-- Sata[1]
------ ModelName    = WDC WD40EFRX-68N32N0                   
------ SerialNumber =      WD-WCC7K3PUX96T
------ FirmwareVer  = 82.00A82
------ Capacity     = 3726 GB
------ PortType     = RAID Disk
------ PortSpeed    = Gen 3
------ Page0State   = Hooked to PM
------ Page0RaidIdx = 0
------ Page0MbrIdx  = 1
-- Raid[0]
------ ModelName       = H/W RAID0                               
------ SerialNumber    = C3NS1P3OA6XSNHPI8GOG
------ Capacity        = 7451 GB
------ RaidStatus      = Normal
------ RaidLevel       = RAID 0
------ RaidMbrCount    = 2
------ RebuildPriority = 3
------ RaidMember[0]
--------- Ready        = 1
--------- LBA48Support = 1
--------- SataPage     = 0
--------- SataPort     = 0
--------- SataBase     = 0
--------- SataSize     = 3725 GB
------ RaidMember[1]
--------- Ready        = 1
--------- LBA48Support = 1
--------- SataPage     = 0
--------- SataPort     = 1
--------- SataBase     = 0
--------- SataSize     = 3725 GB
JMS56X>

The current JMicron RAID controller status is: Normal
cadelle
 
Posts: 47
Joined: Sat Feb 24, 2018 3:24 am
languages_spoken: english
ODROIDs: XU4, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby odroid » Mon Jun 04, 2018 10:49 am

Is the LCD Back-lit working?
User avatar
odroid
Site Admin
 
Posts: 28610
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby cadelle » Mon Jun 04, 2018 11:16 am

Oh yeah, seeing the normal display just fine.
cadelle
 
Posts: 47
Joined: Sat Feb 24, 2018 3:24 am
languages_spoken: english
ODROIDs: XU4, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby dbdbdb » Sat Jul 14, 2018 3:05 pm

Thank you to everyone who posted info, examples, ideas.

This assumes you have installed the necessary packages/configurations for your LCD and that the LCD script "cloudshell-lcd" is running, that cloudshell-lcd and checkRAID.bash are in /bin/ and that you have access to that folder/files.

Here's something I did:
First, I took the checkRAID.bash script that was provided in the links for disk recovery. I added it to a cron under root like so:
Code: Select all
0,15,30,45 * * * * /bin/checkRAID.bash > /bin/checkRAID.txt 2>&1


This cron entry will fire off every 00, 15, 30, and 45 of every hour while the Cloudshell2 is on and will output a file /bin/checkRAID.txt (which is a file of what the screen output would look like).
In particular, I just wanted the RaidStatus (Normal, Rebuilding, Degrade (or Degraded?), Broken, Unknown) values to be read into a variable that I could read and provide as part of the status. I tried running the checkRAID.bash script and grep'ing for the data, but that wasn't working. So I switched to outputing the results of the script to a text file...

Next, I edited the cloudshell-lcd script.
after this line:
get_process_count() {
export PROCESS_COUNT=$(ps xa | wc -l)
}

...I added this:
Code: Select all
get_raid_status() {
        export RS=$(cat /bin/checkRAID.txt | grep RaidStatus)
        export RAIDSTATUS="${RS//------ RaidStatus      = /}"
}


RaidStatus ends up looking like ------ RaidStatus = Normal, but I didn't want all that in the LCD output. So I use the var/pattern/replacement method ${var/pattern/replacement} to get rid of that part into a new variable called RAIDSTATUS.

Then, down towards the bottom of the cloudshell-lcd script, after this line:
Code: Select all
        get_cpu_temperature


I added this line to call my newly added code:
Code: Select all
        get_raid_status


Lastly, I added code after this line:
# line Processes

This is the code I added:
Code: Select all
        echo "" > $oc
        case "$RAIDSTATUS" in
        "Normal"|"Rebuilding"|"Degrade"|"Degraded"|"Broken"|"Unknown")
                if [ "$RAIDSTATUS" = "Normal" ]
                then
                    echo -e "Raid Status: $CGREEN$RAIDSTATUS$COFF" > $oc
                elif [ "$RAIDSTATUS" = "Rebuilding" ]
                then
                    echo -e "Raid Status: $CBLUE$RAIDSTATUS$COFF" > $oc
                elif [ "$RAIDSTATUS" = "Degraded" -o "$RAIDSTATUS" = "Degrade" -o "$RAIDSTATUS" = "Broken" -o "$RAIDSTATUS" = "Unknown" ]
                then
                    echo -e "Raid Status: $CRED$RAIDSTATUS$COFF" > $oc
                fi
            ;;
        *)
            echo -e "Raid Status: $CRED NOSTATUS$COFF" > $oc
            ;;
        esac
        # How old is the RAID STATUS?
        LAST_RAID_STATUS_CHECK=$(stat -c %y /bin/checkRAID.txt | cut -d '.' -f1)
        echo -e "Raid Status Check: $CBLUE$LAST_RAID_STATUS_CHECK$COFF" > $oc


*** don't forget when making code changes, to reload the LCD script with:
systemctl restart cloudshell-lcd
...otherwise, the changes to the cloudshell-lcd script won't take affect.

What this does, using a case function, is check for the RaidStatus we got earlier in this script in the get_raid_status function.
If it's has a status of "Normal, Rebuilding, Degrade (or Degraded), Unknown, or Broken", it will then output to the screen: "Raid Status: <Raid Status variable>". I also color coded it.
Normal status = Green
Rebuilding status = Blue
Broken, Unknown, Degrade, Degraded = Red
...then, closing the case statement, if it didn't find any of the known status I programmed, there could be something wrong with the cron, the bash script, the text file, or other. So I wanted it to output to the screen that the Raid Status was NOSTATUS in Red.

One problem I was concerned with in my solution is what happens if the CRON breaks, doesn't run, script breaks - basically, how would I find out if the job ran and how old the information is for my RAID STATUS check. So, I came up with the solution to get the checkRAID.txt file date/time that we created from running the checkRAID.bash in CRON, format the date/time, and add it as one more line to the status screen.

Also, with my CRON firing off at 0, 15, 30, and 45 of the hour, every hour it's on, for a brief moment during those times, the RAID STATUS will report NOSTATUS. This is because the checkRAID.txt file is being (re)created and for a moment, the file does not have a RAID STATUS value causing this to happen my CASE status to trip a NOSTATUS output to the screen. This is normal and should go away in less than 4 to 7 seconds. If it doesn't investigate what the issue might be.

I have not changed the output on the LCD screen from the format and layout of the script delivered from the helpful folks who developed cloudshell-lcd script. All I ended up doing was adding "Raid Status: 'status'" at the bottom of the last line which would be drive temperature (or disk used / disk free if you are in RAID). Nothing special or cool like the giant status in other scripts.

Here's what the output looks like *I'm a forum noob, so this is probably too dang large, sorry about that:
20180718_225238 - Copy.png
20180718_225238 - Copy.png (1.06 MiB) Viewed 903 times



Thanks,

DB
dbdbdb
 
Posts: 16
Joined: Sat Jul 14, 2018 2:30 pm
languages_spoken: english
ODROIDs: xu4, c2, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby Helmut » Sat Jul 28, 2018 9:40 pm

Many thanks, dbdbdb! Works perfectly.

For anyone interested, I made some further updates to include FAN Monitoring & Handling (adapted from https://github.com/crazyquark/xu4-cloudshell2-fancontrol/blob/master/xu4-fancontrol.sh)

Image

After line ################ Configuration
I wrote:
Code: Select all
export DISK_TEMP_THRESHOLD="38"
export CPU_TEMP_THRESHOLD="45"
export FANSTATUS="unknown"


In get_cpu_temperature() I added above the line "if [ "$TEMPERATURE_FORMAT" ...":

Code: Select all
export CPU_TEMP_N="$_t"


After get_cpu_temperature() {...
}
I copied:

Code: Select all
fan_on() {
    i2cset -y 1 0x60 0x05 0x00
}

fan_off() {
    i2cset -y 1 0x60 0x05 0x05
}


After get_raid_status() {...
}
I copied & modified:
Code: Select all
handle_fan() {
    for i in "${!DISK_TEMP[@]}"
    do
        if (( "${DISK_TEMP[$i]}" > "${DISK_TEMP_THRESHOLD}" ))
        then
            export FANSTATUS="Fan turned on (HDD)"
            FAN_CHANGED="1"
            fan_on
            return
        fi
    done
   
    if (( "${CPU_TEMP_N}" > "${CPU_TEMP_THRESHOLD}" ))
    then
        export FANSTATUS="Fan turned on (CPU)"
        FAN_CHANGED="1"
        fan_on
        return
    fi
   
    # No fuss, fan is off
    if [ "${FAN_CHANGED}" != "0" ]
    then
        export FANSTATUS="All temps nominal, fan turned off"
        FAN_CHANGED="0"
    fi
    fan_off
}


.. then added
Code: Select all
handle_fan
after line #get_process_count

.. and finally after:
Code: Select all
        echo -e "Raid Status Check: $CBLUE$LAST_RAID_STATUS_CHECK$COFF" > $oc


I added the output for Fan Status:
Code: Select all
   echo "" > $oc
      echo -e "$FANSTATUS" > $oc


.. and, to save space on the lcd, I commented the raidartwork out:
Code: Select all
##RAID STATUS
#   if [ -f /var/log/RAID_STATUS4LCD ]; then
#     RAID_STATUS4LCD=$(cat /var/log/RAID_STATUS4LCD)
#     echo "" > $oc
#     echo "" > $oc
#     if [ "$RAID_STATUS4LCD" = "Normal" ]; then
#       echo "Raid Status:${CGREEN}" > $oc
#       figlet "$RAID_STATUS4LCD" > $oc
#       echo "${COFF}" > $oc
#     elif [ "$RAID_STATUS4LCD" = "Rebuilding" ]; then
#       echo "Raid Status:${CBLUE}" > $oc
#       figlet "$RAID_STATUS4LCD" > $oc
#       echo "${COFF}" > $oc
#     else
###ALTERNATE PRINT OUT STYLE
####       printf "Raid Status:\n${CBRED}!!!!!!!!!!!!!!!!!!!!\n!!${COFF}%*s%*s${CBRED}!!\n!!!!!!!!!!!!!!!!!!!!${COFF}% 20s ${COFF} \r\n${COFF} " $(((${#RAID_STATUS4LCD}+16)/2)) $RAID_STATUS4LCD $(((17-${#RAID_STATUS4LCD})/2)) > $oc
#       echo "Raid Status:${CBRED}" > $oc
#       figlet "$RAID_STATUS4LCD" > $oc
#       echo "${COFF}" > $oc
#     fi
#   fi
   # sleep
Helmut
 
Posts: 7
Joined: Sat Jul 21, 2018 5:51 pm
languages_spoken: english

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby Helmut » Sun Jul 29, 2018 4:47 pm

I also edited
Code: Select all
cloudshell-lcd.service
in
Code: Select all
/lib/systemd/system
and added:

Code: Select all
ExecStopPost=/usr/sbin/i2cset -y 1 0x60 0x05 0x00


This enables the fan whenever the cloudshell-lcd service stops.

[Edit] Unfortunately, this also caused the Fan to turn on when shutting down [and it keeps running!]. Solution: Put the following script in a file (e.g. "shutdown-fan") and copy it to:
Code: Select all
/lib/systemd/system-shutdown/


Code: Select all
#!/bin/bash
# Shutdown Fan Script on System Shutown
#
# requires the following packages:
# i2cset
#
#

############## Configuration

fan_on() {
    i2cset -y 1 0x60 0x05 0x00
}

fan_off() {
    i2cset -y 1 0x60 0x05 0x05
}

echo "Preparing shutdown.. "
fan_off
echo "Fan turned off..Done."
Last edited by Helmut on Sat Aug 04, 2018 5:25 am, edited 1 time in total.
Helmut
 
Posts: 7
Joined: Sat Jul 21, 2018 5:51 pm
languages_spoken: english

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby dbdbdb » Mon Jul 30, 2018 2:52 pm

@Helmut - excellent - glad it worked.

Question, how did you get more on your screen? If I try to put anymore on my screen, the top line gets erased (and more lines as it goes up). Is there a way to shrink the lines/resolution on the CS2 LCD?

thanks,

DB
dbdbdb
 
Posts: 16
Joined: Sat Jul 14, 2018 2:30 pm
languages_spoken: english
ODROIDs: xu4, c2, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby Helmut » Sat Aug 04, 2018 5:45 am

Apologies for my late answer.

Not sure why I have more screen available. I am sure you know you know how set set the font size? E.g.
Code: Select all
# console font
# More fonts on: /usr/share/consolefonts
export TERM="linux"
#export CONSOLE_FONT="Lat7-Fixed13"
#export CONSOLE_FONT="Lat7-Fixed18"
export CONSOLE_FONT="Lat15-Terminus12x6"
#export CONSOLE_FONT="Lat15-Terminus14"

(code from groonig above)

Otherwise, I didn't change much. I know it is possible to set screen resolution etc., but this was set to defaults since I am using the pre-installed mmc-Ubuntu from odroid.
Initially, I followed these base setup instructions: https://wiki.odroid.com/accessory/add-o ... quicksetup
Helmut
 
Posts: 7
Joined: Sat Jul 21, 2018 5:51 pm
languages_spoken: english

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby dbdbdb » Sat Aug 04, 2018 5:41 pm

Helmut wrote:Apologies for my late answer.
Not sure why I have more screen available. I am sure you know you know how set set the font size? E.g.

Otherwise, I didn't change much. I know it is possible to set screen resolution etc., but this was set to defaults since I am using the pre-installed mmc-Ubuntu from odroid.
Initially, I followed these base setup instructions: https://wiki.odroid.com/accessory/add-o ... quicksetup



---
Thanks, no worries, and please don't apologize - you aren't at my beckon call :)
dbdbdb
 
Posts: 16
Joined: Sat Jul 14, 2018 2:30 pm
languages_spoken: english
ODROIDs: xu4, c2, cloudshell2

Re: Cloudshell 2 HW Raid 1 error notifications?

Unread postby CloudPhotos » Sat Sep 08, 2018 3:55 am

For anyone interested, I made some further updates to include FAN Monitoring & Handling


Helmut,

Your raid status, fan and display modifications to cloudshell-lcd sounds perfect for me! However, when I try to put all your modifications in the old version,
I must make a mistake or two. Do you have a clean copy of your modified cloudshell-lcd.sh file posted somewhere? Could you just put it in a code box on
this post?
Thanks for all your work!!
CloudPhotos
 
Posts: 7
Joined: Fri Sep 07, 2018 9:56 am
languages_spoken: english
ODROIDs: XU4 and CloudShell2


Return to CloudShell

Who is online

Users browsing this forum: No registered users and 1 guest