hpc-cluster/smart-data/blast0r.sh

21 lines
700 B
Bash
Executable File

#!/bin/bash
SERIAL=$(cat /home/ctdo/serial)
LOG=/home/ctdo/blast0r.txt
DEV=$1
SN=$(/usr/bin/udevadm info $DEV|/usr/bin/grep ID_SERIAL_SHORT| /usr/bin/cut -f 2 -d '=')
STOREPATH=/home/ctdo/smart-4
echo "abgefragt am $(date)" > $STOREPATH/$SERIAL-$SN.txt
/usr/sbin/smartctl -a $DEV >> $STOREPATH/$SERIAL-$SN.txt
echo -n "New Disk registered (Serial $SN), smartfoo written, returned with $?. ">> $LOG
PREDECESSOR=$(ls -lah $STOREPATH |grep $SN -B 1| head -n 1|cut -d ' ' -f 10|sed 's/\.txt$//')
if [ ".." == $PREDECESSOR ]
then
echo "Sortier die Platte gaaaanz vorne ein.">> $LOG
else
echo "Sortier die Platte hinter $PREDECESSOR ein">> $LOG
fi
SERIAL=$((SERIAL+1))
echo $SERIAL > /home/ctdo/serial