[ SEA-GHOST MINI SHELL]
# Software raid Monitoring
# - Static items to return capabilities and unused devices
UserParameter=vfs.md.personalities, grep '^Personalities' /proc/mdstat | cut -d ' ' -f 3- | grep '[[:alpha:]]' || echo '<none>'
UserParameter=vfs.md.unused, grep '^unused devices:' /proc/mdstat | cut -d ' ' -f 3- | grep '[[:alpha:]]' || echo '<none>'
# - LLD Discovery item that will return all 'md*' devices with raid level and status. The raid level and status macro's can be used as filters in the discovery rule.
UserParameter=vfs.md.discovery, echo -n '{ "data":[ ' ; awk '/^md/ { gsub("raid","",$4); printf "{ \"{#MDDEVICE}\":\"" $1 "\",\"{#MDSTATUS}\":\"" $3 "\",\"{#MDLEVEL}\":\"" $4 "\" }," }' /proc/mdstat | sed 's/,$//'; echo ' ] }'
# - Prototype items to be used with each 'md*' device
UserParameter=vfs.md.status[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep $1 | awk '{ print $$3 }'
UserParameter=vfs.md.level[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep $1 | awk '{ gsub("raid","",$$4); print $$4 }'
UserParameter=vfs.md.members[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep $1 | cut -d ' ' -f 5- | tr -d ';'
UserParameter=vfs.md.nummembers[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep $1 | cut -d ' ' -f 5- | tr -d ';' | wc -w
UserParameter=vfs.md.size[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep -o '[[:digit:]].* blocks' | sed 's/ blocks//'
UserParameter=vfs.md.needed[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep -o '\[[[:digit:]]*\/[[:digit:]]*\]' | sed -e 's/.*\[\([[:digit:]]*\)\/[[:digit:]]*\]/\1/'
UserParameter=vfs.md.active[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep -o '\[[[:digit:]]*\/[[:digit:]]*\]' | sed -e 's/.*\[[[:digit:]]*\/\([[:digit:]]*\)\]/\1/'
UserParameter=vfs.md.up[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep -o '\[[U_F]*\]' | grep -o 'U' | wc -l
UserParameter=vfs.md.down[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep -o '\[[U_F]*\]' | grep -o '_' | wc -l
UserParameter=vfs.md.recoverperc[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep -o 'recovery\ =\ .*%' | sed -e 's/recovery\ =\ \(.*\)%/\1/' | grep '[[:digit:]]' || echo 100
UserParameter=vfs.md.recoverspeed[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep -o 'speed=[[:digit:]].*\/sec' | sed -e 's/speed=\(.*\)\/sec/\1/' -e 's/K/000/' -e 's/M/000000/' -e 's/G/000000000/' | grep '[[:digit:]]' || echo 0
UserParameter=vfs.md.recovereta[*], sed -e 's/^\ *$/EoB/' -e 's/$/;/' -n -e "/$1\b/,/EoB;/p" /proc/mdstat | grep -o 'finish=.*\ ' | sed -e 's/finish=\(.*\)/\1/' | grep '[[:digit:]]' || echo 0
SEA-GHOST - SHELL CODING BY SEA-GHOST