Software: Apache. PHP/7.3.33 uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) Safe-mode: OFF (not secure) /opt/scripts/hv/ drwxr-xr-x |
Viewing file: Select action/file-type: #!/bin/bash #Author: Nate Kennison (nate@hivelocity.net) #Script to monitor Hardware RAID array and email report logfile="/tmp/raid.log" subject="An Error was detected with your RAID Array" body="Please check the attached log for details" mkdir -p /opt/scripts/hv/ if [[ -f /opt/scripts/hv/raid-monitor-email.txt ]];then email=$(cat /opt/scripts/hv/raid-monitor-email.txt) else read -p "Is this server managed by hivelocity? (y/yes/n/no): " answer if [[ `echo $answer | egrep '(y|yes|Y|YES)'` ]]; then email="support@hivelocity.net" else read -p "Customer's Email Address: " email fi echo $email > /opt/scripts/hv/raid-monitor-email.txt fi #detect OS if [[ -f /etc/redhat-release ]]; then os="cent" elif [[ -f /etc/debian_version ]]; then os="debian" fi #install curl if [[ -z `command -v curl` ]];then if [[ $os == "debian" ]];then apt -y install curl elif [[ $os == "cent" ]];then yum -y install curl fi fi #install unzip if [[ -z `command -v unzip` ]];then if [[ $os == "debian" ]];then apt -y install unzip elif [[ $os == "cent" ]];then yum -y install unzip fi fi #install dig if missing if [[ -z `command -v dig` ]];then if [ $os == "debian" ];then apt -y install bind-utils elif [ $os == "cent" ];then yum -y install bind-utils fi fi #install mutt if missing if [[ -z `command -v mutt` ]];then if [ $os == "debian" ];then apt -y install mutt elif [ $os == "cent" ];then yum -y install mutt fi fi #get storcli download url if [[ -z `which /opt/MegaRAID/storcli/storcli64` ]];then url="http://scripts.hivelocity.net/harden/files/storcli.zip" #download storcli wget -O /root/storcli.zip $url #unzip and install storcli unzip -o -d /root/storcli /root/storcli.zip dir=$(ls /root/storcli) installer_path="/root/storcli/$dir/univ_viva_cli_rel/Unified_storcli_all_os" if [ $os == "debian" ];then dpkg -i $installer_path/Ubuntu/*.deb elif [ $os == "cent" ];then yum -y install $installer_path/Linux/*.rpm fi rm -rf /root/storcli* fi #set storcli path storcli="/opt/MegaRAID/storcli/storcli64" email.error () { #put virtual drives to log (echo "IP: `ip a | grep inet | grep -v 'inet6\|127.0.0.1'`" echo "hostname: `hostname`" $storcli /c0 /vall show | grep Virtual -A 100 $storcli /c0 /eall /sall show | grep Drive -A 100 ) > $logfile echo $body | mutt -s "$subject" -e "set crypt_use_gpgme=no" -a "$logfile" -- "$email" } EID=$($storcli /c0 /eall /sall show | grep EID -A 2 | awk '{print $1}' | grep : | grep -v EID | cut -f1 -d":") if [[ `$storcli /c0 /vall show |grep "DG/VD" -A 2 | grep -E "Rec|OfLn|Pdgd|Dgrd"` ]];then email.error fi script_path="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/$(basename $0)"" chmod +x $script_path cp $script_path /opt/scripts/hv/ #install crontab entry if [[ -z `cat /etc/crontab |grep hv-raid-monitor.sh` ]];then echo "0 0 * * * root /opt/scripts/hv/hv-raid-monitor.sh" >> /etc/crontab fi rm -rf $logfile |
:: Command execute :: | |
--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0987 ]-- |