This is an old revision of the document!
Disable LUN in thinprovision warning threshold
# chvdisk_warning.sh
#!/bin/bash
#
#@(#) Scripts to remove warning threshold on volumes
#
# version: 1.0 10-2023 Manu
dir=`dirname $0`
. $dir/.env
DATE=$(date +%Y%m%d)
YEAR=$(date +%Y)
MONTH=$(date +%m)
user_repoting="report"
SSH="ssh -o ConnectTimeout=30 ${user_repoting}@"
list=$binpath/storage_list.txt
storage=v7000-01
#----------------------
get_disklist ()
{
date
${SSH}${storage} "lsvdisk -delim : -nohdr" > $logpath/lsvdisk.${storage}.txt
for vol in $(cat $logpath/lsvdisk.${storage}.txt | cut -d':' -f2 | sort -u)
do
echo "$vol: "$(${SSH}${storage} "lsvdisk $vol" | egrep 'warning|copy_id')
done > $logpath/lsvdisk.${storage}.warning
}
#----------------------
generate_svccmd ()
{
for line in $(cat $logpath/lsvdisk.${storage}.warning | sed 's/\ copy_id/,copy_id/g' | sed 's/\ /;/g')
do
vdisk=$(echo $line | cut -d':' -f1)
line1=$(echo $line | cut -d':' -f2- | sed 's/,//' | cut -d',' -f1)
copy1=$(echo $line1 | sed 's/copy_id;//' | cut -d';' -f1)
warning1=$(echo $line1 | cut -d';' -f4)
line2=$(echo $line | cut -d':' -f2- | sed 's/,//' | cut -d',' -f2- | sed 's/,//')
copy2=$(echo $line2 | sed 's/copy_id;//' | cut -d';' -f1)
warning2=$(echo $line2 | cut -d';' -f4)
if [[ "$warning1" -ne "" ]]
then
if [[ "$warning1" -ne "0" ]]
then
echo "chvdisk -copy $copy1 -warning 0 $vdisk"
fi
fi
if [[ "$warning2" -ne "" ]]
then
if [[ "$warning2" -ne "0" ]]
then
echo "chvdisk -copy $copy2 -warning 0 $vdisk"
fi
fi
done
}
#########################
main ()
{
date
echo "*** Get SVC disk list"
get_disklist
echo "*** Generate SVC cmd"
generate_svccmd > $logpath/chvdisk.cmd
}
main > $logname 2>&1
cat $logpath/chvdisk.cmd
Daily copy auditlog into a file and consolidate per year
# check_audit_log.sh
#!/bin/bash
#
#@(#) Scripts to collect auditlogs from SVC / V7K users, once per day
# archived by month / year and visible on wiki
#
# version: 1.0 01-2020 Manu
dir=`dirname $0`
. $dir/.env
DATE=$(date +%Y%m%d)
YEAR=$(date +%Y)
MONTH=$(date +%m)
workdir=/workdir/svc/backup/auditlog
savedir=$workdir/$YEAR
index=$workdir/auditlog.txt
user_repoting="report"
SSH="ssh -o ConnectTimeout=30 ${user_repoting}@"
list=$binpath/storage_list.txt
# create backup folder
if [[ ! -d $savedir ]]
then
mkdir -p $savedir
fi
#----------------------
get_auditlog ()
{
date
for storage in $(cat ${list})
do
echo "Audit log for $storage"
if [ -f $savedir/${storage}_${MONTH}.out ]
then
cp $savedir/${storage}_${MONTH}.out $savedir/${storage}_${MONTH}.log
fi
${SSH}${storage} "catauditlog -delim ';'" >> $savedir/${storage}_${MONTH}.log
cat $savedir/${storage}_${MONTH}.log | sort -u > $savedir/${storage}_${MONTH}.out
done
}
#----------------------
generate_log_file ()
{
# find all files .out create up to 300 days
# Formating page for Dokuwiki
echo "====== Last User Audit log for storage ======
" > ${index}
for storage in $(cat ${list})
do
Ustorage=$(echo ${storage} | tr 'a-z' 'A-Z')
output=$workdir/auditlog_${storage}.txt
cat /dev/null > $output
for file1 in $(find $workdir -name "${storage}_*.out" -mtime -300)
do
cat $file1 | grep -v "/dumps/svc.config" | sort -u >> $output
done
cat $output | sort -u > $output.2
tac $output.2 > $output.1
echo "====== Last Changes on ${Ustorage} ======" > $output
date "+%d-%m-%Y %H:%M" >> $output
echo '<code>' >> $output
cat $output.1 >> $output
echo '
' » $output
echo "[[storage:svc:auditlog_${storage}|${Ustorage}]]
“ » ${index}
rm -f $output.1 $output.2
done }
#———————————————— send_wiki() { dokupath=/var/www/html/dokuwiki/data/pages/storage/svc dokuuser=apache dokugrp=apache
for file1 in auditlog_*.txt do
sudo su - root -c "/bin/cp $workdir/$file1 $dokupath"
done
sudo su - root -c ”/bin/cp ${index} $dokupath“ sudo su - root -c ”/bin/chown -R $dokuuser.$dokugrp $dokupath“
}
######################### # Main ######################### main () { date echo “* Get audit log on storage” get_auditlog echo “* Generate main audit log file” generate_log_file echo “*** Copy to Wiki” send_wiki }
main > $logname 2>&1 </code>