User Tools

Site Tools


tsm:tsm_report_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tsm:tsm_report_script [2023/06/20 16:58]
manu
tsm:tsm_report_script [2023/06/21 17:42] (current)
manu [version 06-2023]
Line 1373: Line 1373:
 { {
 echo "# Check last DB backup date" echo "# Check last DB backup date"
-$DSMADMC $OPT_COMMA $OPT_DATAONLY "​select LAST_BACKUP_DATE,​LAST_REORG,​TRANSLATE('​a bc:​de:​fg',​ DIGITS(current_timestamp-LAST_BACKUP_DATE),​ '​_______abcdefgh_____',​ ' ') as ELAPTIME from db" | sed '​s/​\./,/​g'​ | cut -d','​ -f1,3,5 | sed '​s/,/;/​g'​ | sed 's/\ /|/g' > $TMPFILE.last_backup_db_tsm1+$DSMADMC $OPT_COMMA $OPT_DATAONLY "​select LAST_BACKUP_DATE,​LAST_REORG,​TRANSLATE('​a bc:​de:​fg',​ DIGITS(current_timestamp-LAST_BACKUP_DATE),​ '​_______abcdefgh_____','​ ') as ELAPTIME from db" | sed '​s/​\./,/​g'​ | cut -d','​ -f1,3,5 | sed '​s/,/;/​g'​ | sed 's/\ /|/g' > $TMPFILE.last_backup_db_tsm1
  
 if [ $(tail -1 $TMPFILE.last_backup_db_tsm1 | egrep -q '​^[0-9][0-9]';​echo $?) -ne 0 ] if [ $(tail -1 $TMPFILE.last_backup_db_tsm1 | egrep -q '​^[0-9][0-9]';​echo $?) -ne 0 ]
Line 1776: Line 1776:
 rm $TMPFILE.scratch1 2>/​dev/​null rm $TMPFILE.scratch1 2>/​dev/​null
  
-for type in $(cat $TMPFILE.paths1 | cut -d';'​ -f1 | sort | uniq)+for type in $(cat $TMPFILE.paths1 ​2>/​dev/​null ​| cut -d';'​ -f1 | sort | uniq)
 do do
   online=$(cat $TMPFILE.paths1 | grep "​^$type"​ | cut -d';'​ -f2 | grep '​YES'​ | wc -l | awk '​{print $1}')   online=$(cat $TMPFILE.paths1 | grep "​^$type"​ | cut -d';'​ -f2 | grep '​YES'​ | wc -l | awk '​{print $1}')
Line 1793: Line 1793:
   echo "​TD;​$NAGIOSTAG;​$TAG;​$type;​$online;​$offline"​ >> $TMPFILE.paths   echo "​TD;​$NAGIOSTAG;​$TAG;​$type;​$online;​$offline"​ >> $TMPFILE.paths
 done done
-rm $TMPFILE.paths1+rm $TMPFILE.paths1 ​2>/​dev/​null
  
-for line in $(cat $TMPFILE.drives1)+for line in $(cat $TMPFILE.drives1 ​2>/​dev/​null)
 do do
   end=$(echo $line | cut -d';'​ -f4)   end=$(echo $line | cut -d';'​ -f4)
Line 1804: Line 1804:
   fi   fi
 done done
-for library in $(cat $TMPFILE.drives1 | cut -d';'​ -f1 | sort | uniq)+for library in $(cat $TMPFILE.drives1 ​2>/​dev/​null ​| cut -d';'​ -f1 | sort | uniq)
 do do
   online=$(cat $TMPFILE.drives1 | grep "​^$library"​ | cut -d';'​ -f4 | grep '​YES'​ | wc -l | awk '​{print $1}')   online=$(cat $TMPFILE.drives1 | grep "​^$library"​ | cut -d';'​ -f4 | grep '​YES'​ | wc -l | awk '​{print $1}')
Line 1832: Line 1832:
 echo "​TH;​4;​TAG;​VOLUME_NAME;​STGPOOL_NAME;​ACCESS;​WRITE_ERRORS;​READ_ERRORS"​ > $TMPFILE.volume_error echo "​TH;​4;​TAG;​VOLUME_NAME;​STGPOOL_NAME;​ACCESS;​WRITE_ERRORS;​READ_ERRORS"​ > $TMPFILE.volume_error
 $DSMADMC $OPT_COMMA $OPT_DATAONLY "​select VOLUME_NAME,​STGPOOL_NAME,​ACCESS,​WRITE_ERRORS,​READ_ERRORS from volumes where ACCESS<>'​READWRITE'​ and ACCESS<>'​OFFSITE'"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -iv "​found|return"​ | grep -v '​^/'​ | sed "​s/​^/​TD;​2;​$TAG;/"​ >> $TMPFILE.volume_error $DSMADMC $OPT_COMMA $OPT_DATAONLY "​select VOLUME_NAME,​STGPOOL_NAME,​ACCESS,​WRITE_ERRORS,​READ_ERRORS from volumes where ACCESS<>'​READWRITE'​ and ACCESS<>'​OFFSITE'"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -iv "​found|return"​ | grep -v '​^/'​ | sed "​s/​^/​TD;​2;​$TAG;/"​ >> $TMPFILE.volume_error
-$DSMADMC $OPT_COMMA $OPT_DATAONLY "​select VOLUME_NAME,​STGPOOL_NAME,​ACCESS,​WRITE_ERRORS,​READ_ERRORS from volumes where WRITE_ERRORS<>'​0'​ or READ_ERRORS<>'​0'"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -iv "​found|return"​ | sed "​s/​^/​TD;​1;​$TAG;/"​ >> $TMPFILE.volume_error+$DSMADMC $OPT_COMMA $OPT_DATAONLY "​select VOLUME_NAME,​STGPOOL_NAME,​ACCESS,​WRITE_ERRORS,​READ_ERRORS from volumes where WRITE_ERRORS<>'​0'​ or READ_ERRORS<>'​0'"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -iv "​found|return" ​| grep -v '​^/' ​| sed "​s/​^/​TD;​1;​$TAG;/"​ >> $TMPFILE.volume_error
 $DSMADMC $OPT_COMMA $OPT_DATAONLY "​select CONTAINER_NAME,​STGPOOL_NAME,​STATE from containers where STATE<>'​AVAILABLE'​ and TYPE<>'​CLOUD'"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -iv "​found|return"​ | sed "​s/​^/​TD;​1;​$TAG;/"​ | sed "​s/​$/;​0;​0/"​ >> $TMPFILE.volume_error $DSMADMC $OPT_COMMA $OPT_DATAONLY "​select CONTAINER_NAME,​STGPOOL_NAME,​STATE from containers where STATE<>'​AVAILABLE'​ and TYPE<>'​CLOUD'"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -iv "​found|return"​ | sed "​s/​^/​TD;​1;​$TAG;/"​ | sed "​s/​$/;​0;​0/"​ >> $TMPFILE.volume_error
 } }
Line 1852: Line 1852:
 NAGIOSTAG=0 NAGIOSTAG=0
 TAG=TAG TAG=TAG
 +
 HEADER="​TH;​4;​TAG;​DOMAIN_NAME;​NODE_NAME"​ HEADER="​TH;​4;​TAG;​DOMAIN_NAME;​NODE_NAME"​
  
Line 1953: Line 1954:
  
 #​---------------------------- #​----------------------------
-check_expired_data ​()+check_expired_filespaces ​()
 { {
 echo "# Collect expired filespaces"​ echo "# Collect expired filespaces"​
-$DSMADMC $OPT_COMMA $OPT_DATAONLY "​select NODE_NAME,​FILESPACE_NAME,​FILESPACE_ID,​FILESPACE_TYPE,​CAPACITY,​PCT_UTIL,​to_char(char(BACKUP_END),'​YYYY-MM-DD'​) as LAST_ACCESS from filespaces where node_name<>''​ order by node_name"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | sed -e '​s/"//​g'​ -e "​s/'//​g"​ | sed -e '​s/​\\a/​\\A/​g'​ -e '​s/​\\b/​\\B/​g'​ -e '​s/​\\c/​\\C/​g'​ -e '​s/​\\f/​\\F/​g'​ -e '​s/​\\n/​\\N/​g'​ -e '​s/​\\r/​\\R/​g'​ -e '​s/​\\t/​\\T/​g'​ -e '​s/​\\v/​\\V/​g'​ | sed -e '​s/​^/"/'​ -e "​s/​^/'/"​ | sed -e '​s/​$/"/'​ -e "​s/​$/'/"​ | egrep -v "​ANR2034E|ANS8001I"​ > $TMPFILE.filespaces_last_access.tmp+if [ ${filespace_stat} == "​no"​ ] 
 +then 
 +  ​$DSMADMC $OPT_COMMA $OPT_DATAONLY "​select NODE_NAME,​FILESPACE_NAME,​FILESPACE_ID,​FILESPACE_TYPE,​CAPACITY,​PCT_UTIL,​to_char(char(BACKUP_END),'​YYYY-MM-DD'​) as LAST_ACCESS from filespaces where node_name<>''​ order by node_name"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | sed -e '​s/"//​g'​ -e "​s/'//​g"​ | sed -e '​s/​\\a/​\\A/​g'​ -e '​s/​\\b/​\\B/​g'​ -e '​s/​\\c/​\\C/​g'​ -e '​s/​\\f/​\\F/​g'​ -e '​s/​\\n/​\\N/​g'​ -e '​s/​\\r/​\\R/​g'​ -e '​s/​\\t/​\\T/​g'​ -e '​s/​\\v/​\\V/​g'​ | sed -e '​s/​^/"/'​ -e "​s/​^/'/"​ | sed -e '​s/​$/"/'​ -e "​s/​$/'/"​ | egrep -v "​ANR2034E|ANS8001I"​ > $TMPFILE.filespaces_last_access.tmp
  
-$DSMADMC $OPT_COMMA $OPT_DATAONLY "​select NODE_NAME,​FILESPACE_ID,​sum(REPORTING_MB) as MB,​sum(NUM_FILES) as nb_files from occupancy group by NODE_NAME,​FILESPACE_ID order by NODE_NAME"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -v "​ANR2034E|ANS8001I"​ > $TMPFILE.occupancy_per_filespace.tmp+  ​$DSMADMC $OPT_COMMA $OPT_DATAONLY "​select NODE_NAME,​FILESPACE_ID,​sum(REPORTING_MB) as MB,​sum(NUM_FILES) as nb_files from occupancy group by NODE_NAME,​FILESPACE_ID order by NODE_NAME"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -v "​ANR2034E|ANS8001I"​ > $TMPFILE.occupancy_per_filespace.tmp
  
-echo "​TH;​4;​TAG;​NODE_NAME;​FILESPACE_NAME;​FILESPACE_ID;​FILESPACE_TYPE;​CAPACITY;​PCT_UTIL;​LAST_ACCESS;​REPORTING_SIZE_MB;​NB_FILES"​ > $TMPFILE.filespaces_last_access+  ​echo "​TH;​4;​TAG;​NODE_NAME;​FILESPACE_NAME;​FILESPACE_ID;​FILESPACE_TYPE;​CAPACITY;​PCT_UTIL;​LAST_ACCESS;​REPORTING_SIZE_MB;​NB_FILES"​ > $TMPFILE.filespaces_last_access
  
-for line in $(cat $TMPFILE.filespaces_last_access.tmp) +  ​for line in $(cat $TMPFILE.filespaces_last_access.tmp) 
-do +  do 
-  end=$(echo $line | cut -d';'​ -f7 | sed -e '​s/"//​g'​ -e "​s/'//​g"​) +    end=$(echo $line | cut -d';'​ -f7 | sed -e '​s/"//​g'​ -e "​s/'//​g"​) 
-  node=$(echo $line | cut -d';'​ -f1 | sed -e '​s/"//​g'​ -e "​s/'//​g"​) +    node=$(echo $line | cut -d';'​ -f1 | sed -e '​s/"//​g'​ -e "​s/'//​g"​) 
-  fsid=$(echo $line | cut -d';'​ -f3) +    fsid=$(echo $line | cut -d';'​ -f3) 
-  grep "​^$node;​$fsid;"​ $TMPFILE.occupancy_per_filespace.tmp > /dev/null 2>&1 +    grep "​^$node;​$fsid;"​ $TMPFILE.occupancy_per_filespace.tmp > /dev/null 2>&​1 
-  if [ $? -eq 0 ] +    if [ $? -eq 0 ]
-  then +
-    ​occ=$(grep "​^$node;​$fsid;"​ $TMPFILE.occupancy_per_filespace.tmp | cut -d';'​ -f3,4) +
-  else +
-    occ="​EMPTY;"​ +
-  fi +
-  node_exception=$(echo ${node_expired} | sed -e '​s/​^/;/'​ -e '​s/,/;​\|;/​g'​ -e '​s/​$/;/'​) +
-  ​if [ $(echo ";​$node;"​ | egrep "​${node_exception}"​ > /​dev/​null;​echo ​$?-eq 0 +
-  then +
-    NAGIOSTAG=4 +
-  else +
-    if [[ "​$end"​ < "​$EXPIRED"​ ]]+
     then     then
-      ​NAGIOSTAG=1+      ​occ=$(grep "​^$node;​$fsid;"​ $TMPFILE.occupancy_per_filespace.tmp | cut -d';'​ -f3,4)
     else     else
-      ​NAGIOSTAG=0+      ​occ="​EMPTY;"​
     fi     fi
-  ​fi +    node_exception=$(echo ${node_expired} | sed -e '​s/​^/;/'​ -e '​s/,/;​\|;/​g'​ -e '​s/​$/;/'​) 
-  echo "​TD;​$NAGIOSTAG;​$TAG;​$line;​$occ"​ | sed -e '​s/"//​g'​ -e "​s/'//​g"​ >> $TMPFILE.filespaces_last_access +    if [ $(echo ";​$node;"​ | egrep "​${node_exception}"​ > /​dev/​null;​echo $?) -eq 0 ] 
-done+    then 
 +      NAGIOSTAG=4 
 +    else 
 +      if [[ "​$end"​ < "​$EXPIRED"​ ]] 
 +      then 
 +        NAGIOSTAG=1 
 +      else 
 +        NAGIOSTAG=0 
 +      ​fi 
 +    fi 
 +    ​echo "​TD;​$NAGIOSTAG;​$TAG;​$line;​$occ"​ | sed -e '​s/"//​g'​ -e "​s/'//​g"​ >> $TMPFILE.filespaces_last_access 
 +  done
  
-rm $TMPFILE.filespaces_last_access.tmp $TMPFILE.occupancy_per_filespace.tmp +  ​rm $TMPFILE.filespaces_last_access.tmp $TMPFILE.occupancy_per_filespace.tmp
-if [ ${filespace_stat} == "​no"​ ] +
-then +
-  rm $TMPFILE.filespaces_last_access > /dev/null 2>&1+
 fi fi
 +}
  
 +#​----------------------------
 +check_expired_nodes ()
 +{
 echo "# Collect expired nodes" echo "# Collect expired nodes"
 $DSMADMC $OPT_COMMA $OPT_DATAONLY "​SELECT node_name,​domain_name,​platform_name,​client_os_level,​TRIM(CHAR(client_version))||'​.'​||TRIM(CHAR(client_release))||'​.'​||TRIM(CHAR(client_level))||'​-'​||TRIM(CHAR(client_sublevel)) as TSM_Version,​DATE(lastacc_time) AS LASTACC_TIME,​TCP_NAME,​TCP_ADDRESS FROM nodes order by node_name"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -v "​ANR2034E|ANS8001I"​ > $TMPFILE.nodes_last_access.tmp $DSMADMC $OPT_COMMA $OPT_DATAONLY "​SELECT node_name,​domain_name,​platform_name,​client_os_level,​TRIM(CHAR(client_version))||'​.'​||TRIM(CHAR(client_release))||'​.'​||TRIM(CHAR(client_level))||'​-'​||TRIM(CHAR(client_sublevel)) as TSM_Version,​DATE(lastacc_time) AS LASTACC_TIME,​TCP_NAME,​TCP_ADDRESS FROM nodes order by node_name"​ | sed '​s/,/;/​g'​ | sed 's/\ /|/g' | egrep -v "​ANR2034E|ANS8001I"​ > $TMPFILE.nodes_last_access.tmp
Line 2081: Line 2085:
 <meta http-equiv="​Content-Type"​ content="​text/​html;​ charset=utf-8">​ <meta http-equiv="​Content-Type"​ content="​text/​html;​ charset=utf-8">​
 </​head>​ </​head>​
-<h1>TSM Backup ​Report'​ $server $(date "​+%d-%m-%Y %H:​%M"​) version: $tsmversion '</​h1>​+<h1>Spectrum Protect ​Report'​ $server $(date "​+%d-%m-%Y %H:​%M"​) version: $tsmversion '</​h1>​
 <​body>​ <​body>​
 <br> <br>
Line 2167: Line 2171:
   rm  $TMPFILE* 2> /dev/null   rm  $TMPFILE* 2> /dev/null
   htmlfile=$logpath/​tsm_daily_report_${TODAY}_${server}.html   htmlfile=$logpath/​tsm_daily_report_${TODAY}_${server}.html
-  if [ $($DSMADMC "q db" ​| grep -q ANS1017E; echo $?) -eq 0 ]+  if [ $(timeout 5 $DSMADMC "q db" ​> /dev/null 2>&1; echo $?) -ne 0 ]
   then   then
     subject=$(echo "TSM daily report $TODAY from location $server DOWN !!!")     subject=$(echo "TSM daily report $TODAY from location $server DOWN !!!")
Line 2187: Line 2191:
     check_library     check_library
     d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s)     d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s)
-#    ​check_volume_error+    ​check_volume_error
     d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s)     d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s)
     auditocc     auditocc
Line 2197: Line 2201:
     daily_backuparch_per_node     daily_backuparch_per_node
     d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s)     d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s)
-    ​check_expired_data+    ​check_expired_nodes 
 +    d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s) 
 +    check_expired_filespaces
     d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s)     d2=$(date +%s); echo "$(( (d2 - d1) )) seconds";​d1=$(date +%s)
     repl_status     repl_status
Line 2206: Line 2212:
   send_email $server   send_email $server
   #​copy_to_apache   #​copy_to_apache
-  rm $TMPFILE*+  rm $TMPFILE* ​2>/​dev/​null
 done done
  
Line 2214: Line 2220:
 } }
  
 +mv -f $logname ${logname}.1
 main > $logname 2>&1 main > $logname 2>&1
 </​code>​ </​code>​
Line 2237: Line 2244:
 |                ​TOTAL_CLOUD_SPACE_MB | | 11025099 | | |                ​TOTAL_CLOUD_SPACE_MB | | 11025099 | |
 |                 USED_CLOUD_SPACE_MB | | 10391137 | | |                 USED_CLOUD_SPACE_MB | | 10391137 | |
-|               LOCAL_EST_CAPACITY_MB | | 1137040 | | +|               LOCAL_EST_CAPACITY_MB | | 0.0| | 
-|                  ​LOCAL_PCT_UTILIZED | | 15881795 | |+|                  ​LOCAL_PCT_UTILIZED | | 0.0| |
  
tsm/tsm_report_script.1687273088.txt.gz · Last modified: 2023/06/20 16:58 by manu