meta data for this page
  •  

TSM napi riport shell szkript

Riportoló eszköz a TSM szerver állapotának ellenőrzésére, napi feladatok felderítésére. A szkript egyelőre Linux környezet alatt fut (AIX-osítás folyamatban). De természetesen nem kell azonos hoszton futnia a TSM szerverrel, elég ha van egy bekonfigurált, működő dsmadmc a hoszton, a megfelelő dsm.sys sztanzákkal (azokhoz a TSM szerverekhez, amiket riportolni szeretnénk). A szkript elején vannak a konfigurálható paraméterek. (changelog)

TS3310/TS3500 CLI letöltés

tsm_napi_riport.sh
#!/bin/sh
PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
################################################################
#                                                              #
#  TSM napi riport - tsm_napi_riport.sh v4.9 (2024.05.29.)     #
#  Keszitette: Agoston Peter                                   #
#  Web: http://agostonpeter.com/tsm-turi                       #
#                                                              #
################################################################
SCRIPT_VER="v4.9 (2024.05.29.)"
# Riport cimzett(ek)
# Milyen email cim(ek)re menjen a riport
	MAILTO=$1
# TSM admin (néhány funkcióhoz magasabb jogosultság kell, pl: damaged objektumok listázása)
	TSM_FELH="tsmtech"
	TSM_JELSZO="123456"
# Riportolando TSM szerver sztanzak
	TSM_SZERVEREK="tsmv5srv tsmv6srv"
# Riportolando node replikalo TSM szerver sztanzak
	TSM_REPL_SZERVEREK="tsmv6srv"
# HTML formatumu legy-e a level (0/1)
	HTML_EMAIL=1
# Csatolmanykent el legyen-e kuldve a HTML riport, ha egyebkent szoveges levelkent megy a riport (0/1)
	HTML_EMAIL_CSAT=1
# Munkafajl a futas idejere
	TMP_FILE='/tmp/tsm_napi_riport.tmp'
	TMP_HTML_FILE='/tmp/tsm_napi_riport.tmp.html'
# Mappa, ahova a futasi eredmenyeket elmenti
	LOG_DIR='/opt/tsm_napi_riport/riportok'
# Scratch riasztasi kuszob (=Max scratch - Used scratch)
	AVAILABLE_SCR_WARN=5
# X oranal regebben elo sessionok listazasa
	OLD_SESSION_ALERT=6
# Utoljara X napnal regebben bejelentkezett nodeok
	DEAD_NODE_AGE=8
# Reclamation hatarertek. Kilistazza azokat a storage poolokat, ahol olyan volumeok vannak, amiken ennel tobb a reclamalhato adat. %-os ertek
	RECLAIM_TH=50
# HADR peer statuszok lekerdezese. Kell, hogy legyen hozza SSH kulcs (lasd SSH_KEY_FILE parameter lejjebb). A szervereket is instance_user@hoszt formatumban kell megadni.
	HADR_SZERVEREK="root@hsmstore"
# IBM TS3500/TS3310 library CLI utvonal (ennek a működéséhez java jre kell)
        TSLIBCLI_PATH="~/TS3500CLI.jar"
# TS3500/TS3310 library login adatok, pl: user:jelszo@ip_vagy_dns_cim, ha tobb van, szokozzel elvalasztva, ha nincs, uresen hagyni
        TSLIBRARIES="userem:jelszava@librarym.akarmi"
 
# OS szintu lekerdezesek beallitasai:
# SSH privat kulcs teljes utvonallal az OS-es lekerdezesekhez. Egyetlen kulcsot lehet csak megadni, tehat kozos kulcs kell - azokhoz a user@hoszt parokhoz, amiket lejjebb az SSH_SZERVEREK-ben sorolunk majd fel. Ha ilyen nem akarunk, ures sztringet kell megadni
	SSH_KEY_FILE="/root/.ssh/id_rsa"
# Hoszt nevek, amikre az OS lekerdezeseket futtatni kell. A szervereket is instance_user@hoszt formatumban kell megadni.
	SSH_SZERVEREK="root@tsmv5srv"
# OS szintu lekerdezesek (0/1)
	OS_AIX_LSPS=1	# AIX paging space hasznalat
	OS_AIX_ERRPT=1	# AIX errpt kimenet
	OS_DF=1		# UNIX df kimenet
	OS_DDF=0	# UNIX HSM ddf kimenet
# Konfig resz vege ######################################################################################################################### 
# Hasznalt SQL selectek TSM-hez 
SQL_LICENSZ_HASZNALATOK='select cast(FRONTEND_CAP/1024/1024 as decimal (8,2)) as "Front-End TB",substr(FRONTEND_CAP_DATE,1,19) as "Front-End Date",FRONTEND_CLIENT_COUNT as "Front-End client count",cast(TOTALSUROCC_TB as decimal (8,2)) as "SUR TB",substr(SUROCC_DATE,1,19) as "SUR occupancy date" from status'
#SQL_LICENSZ_HASZNALATOK='select cast(FRONTEND_CAP/1024/1024 as decimal (8,2)) as "Front-End TB",substr(FRONTEND_CAP_DATE,1,19) as "Front-End Date",FRONTEND_CLIENT_COUNT as "Front-End client count",cast(TOTALSUROCC_TB as decimal (8,2)) as "SUR TB",cast(TOTALSURRETOCC_TB as decimal(8,2)) as "SUR retain TB",SUROCC_DATE as "SUR occupancy date" from status'
SQL_UTOLSO24H_ADATMOZGASAI="select nn.domain_name,summary.activity, sum(cast(summary.bytes/1024/1024/1024 as decimal(6,2))) as GB from nodes as nn, summary where (end_time between current_timestamp - 24 hours and current_timestamp) and (activity='BACKUP' or activity='RESTORE' or activity='ARCHIVE' or activity='RETRIEVE') and ((nn.node_name=summary.entity)) group by domain_name,summary.activity order by activity,domain_name asc"
SQL_UTOLSO24H_AKTIVITASAI="SELECT activity, cast(float(sum(bytes))/1024/1024/1024 as dec(8,2)) as \"GB\" FROM summary WHERE end_time>current_timestamp-24 hours and activity<>'EXPIRATION' and bytes>0 GROUP BY activity"
SQL_3X_MISSED="select substr(a.node_name,1,20) as \"NODE NAME\", substr(a.schedule_name,1,25) as SCHEDULE, substr(b.contact,1,20) as \"CONTACT\", substr(char(count(*)),1,4) as \"3 DAY COUNT\",(days(current_timestamp)-days(b.lastacc_time)) as \"LAST SEEN\" from EVENTS a, nodes b where (a.scheduled_start >=current_timestamp - 3 days) and a.node_name=b.node_name and a.status='Missed' and a.node_name is not NULL and a.schedule_name not like 'RMAN_%%_LOG%%' and a.schedule_name not like 'SQL_%%_LOG%%' group by a.node_name, a.schedule_name, b.contact, b.lastacc_time having count(*)>=3 order by \"3 DAY COUNT\" desc"
SQL_QUERY_PROC_V6="SELECT process_num, substr(process,1,20) as PROCESS, substr(char(start_time),1,19) AS START_TIME,substr(char(day(current_timestamp - start_time)),1,2) AS \"(D)\" ,substr(char((current_timestamp - start_time)hours),1,2) AS \"(HH)\", substr(char((current_timestamp - start_time)minutes),1,2) AS \"(MM)\", cast(float(bytes_processed/1024/1024) AS DEC(12,2)) AS MB, cast((cast(bytes_processed as dec(18,0))/cast(timestampdiff(2,char(current_timestamp-start_time)) as decimal(18,0))) / 1024 / 1024 AS DEC (18,2)) AS \"MB/s\" FROM processes"
SQL_QUERY_PROC_V5="SELECT process_num, substr(process,1,20) as PROCESS, substr(char(start_time),1,19) AS START_TIME,substr(char(days(current_timestamp) - days(start_time)),1,2) AS \"(D)\" ,substr(char((current_timestamp - start_time)hours),1,2) AS \"(HH)\", substr(char((current_timestamp - start_time)minutes),1,2) AS \"(MM)\", cast(float(bytes_processed/1024/1024) AS DEC(12,2)) AS \"MB\", cast((cast(float(bytes_processed/1024/1024) AS DEC(12,2)) / INT((current_timestamp - start_time) SECONDS)) AS DEC(12,2)) AS \"MB/s\" from processes"
SQL_QUERY_SESS_V6="SELECT SESSION_ID, CLIENT_NAME, substr(char(start_time),1,19) AS START_TIME,substr(char(day(current_timestamp - start_time)),1,2) AS \"(D)\" ,substr(char((current_timestamp - start_time)hours),1,2) AS \"(HH)\", substr(char((current_timestamp - start_time)minutes),1,2) AS \"(MM)\", STATE,WAIT_SECONDS, cast(float(bytes_sent) /1024/1024 AS DEC(12,2)) AS \"Sent MB\", cast(float(bytes_received) /1024/1024 AS DEC(10,2)) AS \"Rec. MB\" FROM sessions WHERE SESSION_TYPE='Node' and (current_timestamp - start_time)hours>$OLD_SESSION_ALERT" # AND (BYTES_RECEIVED>1024*1024 OR BYTES_SENT>1024*1024)"
SQL_QUERY_SESS_V5="SELECT SESSION_ID, CLIENT_NAME, substr(char(start_time),1,19) AS START_TIME,substr(char(days(current_timestamp) - days(start_time)),1,2) AS \"(D)\" ,substr(char((current_timestamp - start_time)hours),1,2) AS \"(HH)\", substr(char((current_timestamp - start_time)minutes),1,2) AS \"(MM)\", STATE,WAIT_SECONDS, cast(float(bytes_sent) /1024/1024 AS DEC(12,2)) AS \"Sent MB\", cast(float(bytes_received) /1024/1024 AS DEC(10,2)) AS \"Rec. MB\" FROM sessions WHERE SESSION_TYPE='Node' and int((current_timestamp - start_time)hours)>$OLD_SESSION_ALERT" # AND (BYTES_RECEIVED>1024*1024 OR BYTES_SENT>1024*1024)"
SQL_Q_FAILED_EVENTS="select substr(node_name,1,17) as \"NODE NAME\", substr(schedule_name,1,23) as \"SCHEDULE NAME\", cast ( SUBSTR ( CHAR ( actual_start ) , 1 , 19 ) as char ( 19 ) ) AS \"ACTUAL START\", substr((completed-scheduled_start)minutes || ' min',1,7) as \"RUNTIME\" , case when result=0 then ' 0-Succesfull' when result=4 then ' 4-Skipped Files' when result=8 then ' 8-Warnings' when result=12 then '12-Errors' else cast(result as char(7)) end as \"RESULT\" from events where (current_timestamp - 24 hours)<scheduled_start and status='Failed' order by node_name"
SQL_NDMP_MENTESEK="SELECT substr(substr(message,locate('/',message),locate(', ',message,locate('/',message)+1)-locate('/',message)),1,30) as VirtualFS, substr(first_record_time,1,16) as START_TIME, TRANSLATE('a bc:de:fg', DIGITS(last_record_time - first_record_time), '_______abcdefgh_____',' ') as Backup_time, substr(comp_message,locate('completion state of ',comp_message)+20,7) as Result FROM (\
    SELECT pf.message, pc.comp_message, MIN(al.date_time) AS first_record_time, MAX(al.date_time) AS last_record_time FROM actlog al JOIN ( \
    SELECT process, message FROM actlog WHERE (message LIKE '%Full%/%' or message LIKE '%Diff%/%') AND date_time >= CURRENT TIMESTAMP - 48 HOURS) pf ON al.process = pf.process \
	JOIN ( \
    SELECT process, message as comp_message FROM actlog WHERE (message LIKE '%bytes with a completion state%') AND date_time >= CURRENT TIMESTAMP - 48 HOURS) pc ON al.process = pc.process \
    WHERE al.date_time >= CURRENT TIMESTAMP - 48 HOURS \
    GROUP BY pf.message, pc.comp_message \
) order by first_record_time"
SQL_Q_SCRATCH="select library_name || ': ' ||substr(MEDIATYPE,1,10) as Media_type, count(*) as Scratch from libvolumes where status='Scratch' group by library_name, MEDIATYPE"
SQL_Q_NOSCRATCH="select distinct library_name,'0' as \"SCRATCH\" from libvolumes where library_name not in (select distinct library_name from libvolumes where status='Scratch' group by library_name)"
#SQL_DRIVE_USAGE="SELECT substr(library_name,1,20) as LIBRARY_NAME, decimal(SUM(float(hour(end_time - start_time)*60+minute(end_time - start_time)))/1440*100/count(DISTINCT substr(drive_name,1,posstr(drive_name,' '))),5,1) as \"24H LOAD (%)\" FROM summary WHERE activity='TAPE MOUNT' AND current_timestamp - 1 days < start_time  GROUP BY library_name"
SQL_NEM_HASZNALT_OPTIONSETEK="select OPTIONSET_NAME from CLOPTSETS where OPTIONSET_NAME not in (select OPTION_SET from nodes where OPTION_SET!='NULL')"
SQL_KEVES_SCRATCH="select STGPOOL_NAME,MAXSCRATCH-NUMSCRATCHUSED as \"SCRATCH\" from stgpools where MAXSCRATCH-${AVAILABLE_SCR_WARN}<NUMSCRATCHUSED AND MAXSCRATCH>0"
SQL_OFFLINE_PATHOK="select count(*) from paths where not online='YES'"
SQL_OFFLINE_DRIVEOK="select count(*) from drives where not online='YES'"
SQL_TEVES_PRIV_SZALAGOK="SELECT volume_name, library_name FROM libvolumes WHERE status='Private' AND last_use IS NULL AND volume_name NOT IN (SELECT volume_name FROM volumes) and (owner=(select server_name from status) or owner IS NULL)"
SQL_PROBLEMAS_VOLUMEOK="select count(*) from volumes where (access!='READWRITE' AND access!='OFFSITE')"
SQL_DEAD_NODES="select node_name, (days(current_timestamp)-days(lastacc_time)) as \"LAST ACCESS\" from nodes where locked='NO' and (days(current_timestamp)-days(lastacc_time))>$DEAD_NODE_AGE"
SQL_REFUSED_NODES="SELECT substr(date_time,1,19) || ' ' || message as MSG from actlog WHERE msgno in (0421,0422,0424,0425,0426,0427,0428,0429,0430,0432,0435,0437) and date_time>current_timestamp-24 hours ORDER BY date_time ASC"
SQL_RECLAIMABLE_VOL_NUM="select stgpool_name,count(*) as \"RECLAIMABLE_VOLS\", substr(access,1,10) as ACCESS from volumes where pct_reclaim>$RECLAIM_TH and status='FULL' group by stgpool_name,access order by stgpool_name"
SQL_DEDUP_SAVINGS="select stgpool_name, cast((SPACE_SAVED_MB / 1024) as dec(10,2)) as \"SPACE_SAVED_GB\" from stgpools where SPACE_SAVED_MB>0"
SQL_MISSING_COPYGROUP_DEST="select substr(DOMAIN_NAME,1,15) as \"DOMAIN NAME\",substr(SET_NAME,1,15) as \"SET NAME\",substr(CLASS_NAME,1,15) as \"CLASS NAME\",substr(COPYGROUP_NAME,1,15) as \"COPYGROUP_NAME\",substr(DESTINATION,1,15) as \"DESTINATION\" from bu_copygroups where DESTINATION not in (select stgpool_name from stgpools)"
SQL_ACTLOG_ERRORS="SELECT substr(char(date_time),1,19) || ' ' || message as MSG from actlog WHERE severity in ('E','S') and msgno not in(2034,1930,1931,0944) and message not like 'ANE%' and date_time>current_timestamp-24 hours ORDER BY msg ASC"
SQL_REORG_MESSAGES="SELECT substr(date_time,1,19) || ' ' || message as MSG from actlog WHERE msgno in(0293,0294,0317,0318,0336,0337) and date_time>current_timestamp-24 hours ORDER BY date_time ASC"
SQL_HWERR_MESSAGES="SELECT substr(date_time,1,19) || ' ' || message as MSG from actlog WHERE msgno in(8943,8944,8359,8949,8311,8873,8471,8381,8300) and date_time>current_timestamp-24 hours ORDER BY date_time ASC"
SQL_COMPARE_PRIMARY_COPY_POOLS="SELECT pooltype,CAST(FLOAT(sum((est_capacity_mb/1024) * pct_utilized / 100)) AS DEC(12,2)) as total_data_gb,((SELECT CAST(FLOAT(sum((est_capacity_mb/1024) * pct_utilized / 100)) AS DEC(18,2)) FROM stgpools WHERE pooltype='PRIMARY') - (SELECT CAST(FLOAT(sum((est_capacity_mb/1024) * pct_utilized / 100)) AS DEC(18,2)) FROM stgpools WHERE pooltype='COPY')) as pending_copy_gb FROM stgpools where pooltype!='ACTIVEDATA' GROUP BY pooltype"
SQL_CLIENTO_MESSAGES="SELECT substr(date_time,1,19) || ' ' || message as MSG from actlog WHERE msgno in(2050,2053,2297) and date_time>current_timestamp-24 hours ORDER BY date_time ASC"
# HTML kodok
HTML_VONAL="<hr align=center width=\"70%\" noshade style=\"color: #D2D2D2\" size=\"1\">"
HTML_MODUL_LABLEC="</pre></div>"
HTML_TABLA_FEJLEC="<table style=\"word-break: break-all; word-wrap: break-word; min-width: 750px; max-width: 960px; border: 2px solid #D2D2D2;background-color:#F1F1F1; padding: 15px; font-size: 14px; font-family: courier;\"><tr><td>"
HTML_TABLA_LABLEC="</td></tr></table>"
# Fuggvenyek, egyeb valtozok
SSH_OPT="-o BatchMode=yes -o ConnectTimeout=5 -i $SSH_KEY_FILE"
export LANG=en_US
 
read -r -d '' JS_CODE << EOF
<head>
<script language="JavaScript" type="text/javascript">
<!-- Copyright 2005, Sandeep Gangadharan -->
<!-- For more free scripts go to http://www.sivamdesign.com/scripts/ -->
<!--
if (document.getElementById) {
document.writeln('<style type="text/css"><!--')
document.writeln('.texter {display:block} @media print {.texter {display:block;}}')
document.writeln('//--></style>') }
 
function openClose(theID) {
if (document.getElementById(theID).style.display == "block") { document.getElementById(theID).style.display = "none" }
else { document.getElementById(theID).style.display = "block" } }
 
function Collapse(ez) {
if (ez.style.color == "gray") { ez.style.color = "#006DC7"; ez.innerHTML=ez.innerHTML.replace("[+]","[-]"); ez.innerHTML=ez.innerHTML.replace("gray","#006DC7")}
else { ez.style.color = "gray"; ez.innerHTML=ez.innerHTML.replace("[-]","[+]"); ez.innerHTML=ez.innerHTML.replace("#006DC7","gray") } }
// -->
</script>
</head>
EOF
 
function szerverver {
	I=0
	for TSM_SZERVER in $TSM_SZERVEREK; do
		I=$((I+1))
		if [ $1 = $TSM_SZERVER ]; then echo $TSM_SZERVER_VER | cut -d" " -f $I; fi
	done
}
 
function fejlec {
	FEJLEC=`echo $1 | tr '[:lower:]' '[:upper:]'`	
#	KIMENET="/ $FEJLEC \\"
#	for I in `seq 1 $(((110-${#FEJLEC})/2))`; do
#		KIMENET="_$(echo $KIMENET)_"
#	done
	echo "_-_:: $FEJLEC ::_-_" >> $TMP_FILE
	RAND_ID=`date '+%s%N'`
	echo "<div onClick=\"openClose('${RAND_ID}');Collapse(this)\" style=\"cursor:hand; cursor:pointer; color: #006DC7;\">_-_:: [-] $FEJLEC ::_-_</div>\n<div id=\"${RAND_ID}\" class=\"texter\" style=\"display: block\"><pre style=\"white-space: pre-wrap; text-align: left\">" >> $TMP_HTML_FILE
}
 
control_c()
# run if user hits control-c
{
	echo -en "\n*** Ouch! Ertem a celzast, maris takaritok... ***\n"
	rm napi_ellenorzes.tmp 2>/dev/null
	rm $TMP_FILE 2>/dev/null
	rm $TMP_HTML_FILE 2>/dev/null
	rm /tmp/tsm_napi_riport_${DATUM}.html 2>/dev/null
	exit 1
}
 
# trap keyboard interrupt (control-c)
trap control_c SIGINT
# Program torzs
declare -A TSM_SZERVERNEVEK
declare -A TSM_SZERVERNEV
STARTTIME=`date "+%s"`
>$TMP_FILE
>$TMP_HTML_FILE
echo "$HTML_TABLA_FEJLEC" >> $TMP_HTML_FILE
echo '<div style="text-align: center; font-size: 48px; font-weight: bold;">' >> $TMP_HTML_FILE
echo "TSM napi riport" | tee -a $TMP_HTML_FILE >> $TMP_FILE
echo '</div><div style="text-align: center;">' >> $TMP_HTML_FILE
date | tee -a $TMP_HTML_FILE >> $TMP_FILE
echo "</div><br>" >> $TMP_HTML_FILE
# Hasznalt sztanzak ellenorzese
fejlec "Vizsgalando TSM sztanza konfigok mukodesenek ellenorzese" | tee -a $TMP_HTML_FILE >> $TMP_FILE
for TSM_SZERVER in $TSM_SZERVEREK; do
        VER=$((`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER q opt | sed -n -e 's/Server Version \([0-9]\),.*/\1/p' -e 's/[\t\s]*//g'`))
        LONG_VER=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER q opt | sed -n -e  's/Server Version \([0-9]\), Release \([0-9]\), Level \([0-9]\+\)\.\([0-9]\+\).*/\1.\2.\3.\4/p' | sed -e 's/^[^0-9]*//g')
        TSM_SZERVERNEV[$TSM_SZERVER]=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER q opt | sed -n -e 's/Session established with server \([^:]*\):.*/\1/p')
        if [ "$VER" != "0" ]; then
                OK="OK! (v${LONG_VER} - ${TSM_SZERVERNEV[$TSM_SZERVER]})"
                TSM_SZERVERNEVEK_TMP="$TSM_SZERVERNEVEK_TMP ${TSM_SZERVERNEV[$TSM_SZERVER]}"
                TSM_SZERVEREK_TMP="$TSM_SZERVEREK_TMP $TSM_SZERVER"
                TSM_SZERVER_VER="$TSM_SZERVER_VER $VER"
        else
                OK="Sikertelen! A szerver kihagyasra kerul a riportbol."
        fi
        echo "${TSM_SZERVER}: $OK" | awk -F'|' '{printf "> @%-35s %-12s\n",$1,$2}' | tee -a $TMP_HTML_FILE | tee -a $TMP_FILE
done
TSM_SZERVEREK=${TSM_SZERVEREK_TMP# }
TSM_SZERVERNEVEK=${TSM_SZERVERNEVEK_TMP# }
if [ `echo $TSM_SZERVEREK | grep -c '[a-zA-Z]'` -eq 0 ]; then
	echo "Nincs hasznalhato sztanza a konfigomban."
	exit 1
fi
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "adatbazis kihasznaltsag"
datediff() {
    d1=$(date -d "$1" +%s)
    d2=$(date -d "$2" +%s)
    echo $(( (d1 - d2) / 86400 ))
}
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        TOTAL=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -tabdel -displ=tabl q db f=d | head -n1 | awk '{ print $2 }' | sed 's/,//g'`
        WARN='<img align="middle" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAPFBMVEVTQj78AQE3gXz8AQH7AQH6AgL4AgLsBwbbDQz4AwL8AQH8AQH8AQH5AgLwBgXyBQX7AQH6AgL2AwP8AQHRQKRJAAAAE3RSTlMD+wHcxIdkIhFH8uHfeS8vypNRz5cftAAAAGpJREFUGNNlj1cOACEIRK1r7/e/64oZEhP5UHiBYRAUSnjn/P44qjVaG1u5/tI6kT7UcReSSCSiWqZ8DHpzU0JZymQIp8dufXMD44XTN9COwZwAGFm9L4xAtBSI0loArGVjEsYe689xz/k/H5UJk4XCt8UAAAAASUVORK5CYII=">';
        case `szerverver $TSM_SZERVER` in
                5) USED=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -tabdel -displ=tabl q db f=d | head -n1 | awk '{ print $1 }' | sed 's/,//g'`;
                   LASTDBB=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=table -tabdel "q db f=d" | awk '{print $19" "$20}');;
                6) USED=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -tabdel -displ=tabl q db f=d | head -n1 | awk '{ print $3 }' | sed 's/,//g'`
                   LASTDBB=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=table -tabdel "q db f=d" | awk '{print $18" "$19}');;
                7) USED=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -tabdel -displ=tabl q db f=d | head -n1 | awk '{ print $3 }' | sed 's/,//g'`
                   #LASTDBB=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=table -tabdel "q db f=d" | awk '{print $19" "$20}');;
                   LASTDBB=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=table -tabdel "select TO_CHAR(LAST_BACKUP_DATE,'MM/DD/YYYY HH24:MI:SS') from db");;
                8) USED=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -tabdel -displ=tabl q db f=d | head -n1 | awk '{ print $3 }' | sed 's/,//g'`
                   #LASTDBB=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=table -tabdel "q db f=d" | awk '{print $14" "$15}');;
                   LASTDBB=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=table -tabdel "select TO_CHAR(LAST_BACKUP_DATE,'MM/DD/YYYY HH24:MI:SS') from db");;
        esac
        [[ $(datediff "$LASTDBB" "$(date '+%m/%d/%Y %H:%M:%S' )") -lt -1 ]] && WARNING=$WARN
        echo 'Kihasznaltsag: '`echo "scale=2; 100 * $USED / $TOTAL" | bc`"%   (Utolso sikeres DB mentes : ${LASTDBB}) ${WARNING}" | tee -a $TMP_HTML_FILE | sed 's/<img .*>//' >> $TMP_FILE;
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Licensz hasznalat"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        echo ' Front-End GB     Front-End Date            Front-End client count  |       SUR TB     SUR occupancy date' | tee -a $TMP_HTML_FILE >> $TMP_FILE
        echo '-------------     --------------------     -----------------------  |  -----------     --------------------' | tee -a $TMP_HTML_FILE >> $TMP_FILE
        dsmadmc  -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -tabdel -displ=tabl "$SQL_LICENSZ_HASZNALATOK" | egrep -v '(ANR|ANS)' | awk -F' ' '{printf "%13s     %-22s     %21s  |  %11d     %-20s\n", $1, $2, $3, $4, $5}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "archlog kihasznaltsag"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        case `szerverver $TSM_SZERVER` in
                5)
                TOTAL=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y q log | awk '{ print $1 }' | sed 's/,//'`
                USED=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y q log | awk '{ print $9 }' | sed 's/,//'`; TOTAL=1
                ;;
                6)
                TOTAL=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y q log f=d | awk '{ print $6 }' | sed 's/,//'`
                USED=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y q log f=d | awk '{ print $7 }' | sed 's/,//'`
                ;;
                7)
                TOTAL=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y q log f=d | awk '{ print $9 }' | sed 's/,//'`
                USED=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y q log f=d | awk '{ print $10 }' | sed 's/,//'`
                ;;
                8)
                TOTAL=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y q log f=d | awk '{ print $9 }' | sed 's/,//'`
                USED=`dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y q log f=d | awk '{ print $10 }' | sed 's/,//'`
                ;;
	esac
	USED=`echo "scale=2; 100 * $USED / $TOTAL" | bc`
	[[ ${#USED} -lt 5 ]] && USED="0$USED"
	echo "Kihasznaltsag: ${USED}%" | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
if [ "$HADR_SZERVEREK" ]; then
fejlec "HADR statusz(ok)"
for HADR_SZERVER in $HADR_SZERVEREK; do
        STAT=`ssh $SSH_OPT ${HADR_SZERVER} ". /home/${HADR_SZERVER%%@*}/.profile; db2pd -hadr -db tsmdb1" | grep HADR_STATE | awk -F\= '{print $1" "$2}'`
        BUF=`ssh $SSH_OPT ${HADR_SZERVER} ". /home/${HADR_SZERVER%%@*}/.profile; db2pd -hadr -db tsmdb1" | grep STANDBY_RECV_BUF_PERCENT | awk -F\= '{print $2}'`
        echo "${HADR_SZERVER##*@} $STAT $BUF" | awk '{printf "> %-10s HADR statusz: %15s - %-10s (StandByRcvBufUsed: %-3s \%)\n",$1,$2,$3,$4}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
fi
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "futo processzek"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	echo "PROCESS_NUM   PROCESS                START_TIME            ELAPTIME              MB               MB/s" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	echo "-----------   --------------------   -------------------   -----------   ----------   ----------------" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	case `szerverver $TSM_SZERVER` in
                5) dsmadmc -pa=$TSM_JELSZO -id=$TSM_FELH -dataonly=y -se=${TSM_SZERVER} -commadel -displ=list "${SQL_QUERY_PROC_V5}" | egrep -v '(ANR|ANS)' | awk -F',' '{printf "%-11s   %-20s   %-19s   %2dd %2dh %2dm   %11s %17s\n", $1, $2, $3, $4, $5, $6, $7, $8 ,$9}' | tee -a $TMP_HTML_FILE >> $TMP_FILE;;
                [6-9]) dsmadmc -pa=$TSM_JELSZO -id=$TSM_FELH -dataonly=y -se=${TSM_SZERVER} -commadel -displ=list "${SQL_QUERY_PROC_V6}" | egrep -v '(ANR|ANS)' | awk -F',' '{printf "%-11s   %-20s   %-19s   %2dd %2dh %2dm   %11s %17s\n", $1, $2, $3, $4, $5, $6, $7, $8 ,$9}' | tee -a $TMP_HTML_FILE >> $TMP_FILE;;
	esac
	echo | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "mediawait-es szerver session-ok"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -pa=$TSM_JELSZO -id=$TSM_FELH -se=${TSM_SZERVER} -dataonly=y -displ=tabl "select server_name from servers" | egrep -v '(ANR|ANS)' | while read LF_CLIENT; do
                (dsmadmc -pa=$TSM_JELSZO -id=$TSM_FELH -se=${TSM_SZERVER} -dataonly=y -tabdel "$LF_CLIENT: q se" || echo "Kapcsolodasi hiba!") | sed "s/^/${LF_CLIENT}: /" | egrep '(hiba|MediaW)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
        done
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "$OLD_SESSION_ALERT oranal regebb ota nyitott node session"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	echo "SESSION_ID   CLIENT_NAME            START_TIME            ELAPTIME     STATUS               Sent MB    Recieved MB" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	echo "----------   --------------------   -------------------   ----------   -------------   ------------   ------------" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	if [ `szerverver $TSM_SZERVER` -eq 5 ]; then SQL_QUERY_SESS=$SQL_QUERY_SESS_V5; else SQL_QUERY_SESS=$SQL_QUERY_SESS_V6; fi
        dsmadmc -pa=$TSM_JELSZO -id=$TSM_FELH -dataonly=y -se=${TSM_SZERVER} -commadel -displ=list "${SQL_QUERY_SESS}" | egrep -v '(ANR|ANS)' | awk -F',' '{printf "%10s   %-20s   %19s  %2dd %2dh %2dm   %-6s (%3ss)   %12s   %12s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10}' | tee -a $TMP_HTML_FILE >> $TMP_FILE 
        echo | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "scratch szalagok szama"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "${SQL_Q_NOSCRATCH}" | grep -v '^$' | egrep -v '(ANR|ANS)' | awk '{printf "%-15s %10s %3s\n",$1,$3,$2}' | tee -a $TMP_HTML_FILE>> $TMP_FILE
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "${SQL_Q_SCRATCH}" | grep -v '^$' | egrep -v '(ANR|ANS)' | awk '{printf "%-15s %10s %3s\n",$1,$3,$2}' | tee -a $TMP_HTML_FILE>> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
if [[ "$TSLIBRARIES" ]]; then
fejlec "esetleges beavatkozast igenyelheto kezeletlen library esemenyek"
for TSLIBRARY in $TSLIBRARIES; do
    TSLIB_FELH=${TSLIBRARY%%:*}
    TSLIB_JELSZO=${TSLIBRARY#*:}
    TSLIB_JELSZO=${TSLIB_JELSZO%@*}
    TSLIB_HOSZT=${TSLIBRARY##*@}
    echo "> @${TSLIB_HOSZT}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE
    if [ $(java -jar ${TSLIBCLI_PATH} --version | awk '{print $1}') = 'TS3310CLI' ]; then
        java -jar ${TSLIBCLI_PATH} -u ${TSLIB_FELH} -p ${TSLIB_JELSZO} -a ${TSLIB_HOSZT} --viewOperatorInterventions -t 30000 |  awk -F',' '/UnOpened/{print $6" |"$2" | "$4}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
    else
        java -jar ${TSLIBCLI_PATH} -u ${TSLIB_FELH} -p ${TSLIB_JELSZO} -a ${TSLIB_HOSZT} --setMaxSocketExceptionRetries 3 --viewErrorLog 30 |  head -n10 | awk -F',' '{print $3" |"$4" |"$7" | "$1}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
    fi
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
fi
 
#_________________________________________________________________________________________________________________________________________________________________
if [[ "$TSLIBRARIES" ]]; then
fejlec "cleaning szalagok allapota"
for TSLIBRARY in $TSLIBRARIES; do
    TSLIB_FELH=${TSLIBRARY%%:*}
    TSLIB_JELSZO=${TSLIBRARY#*:}
    TSLIB_JELSZO=${TSLIB_JELSZO%@*}
    TSLIB_HOSZT=${TSLIBRARY##*@}
    echo "> @${TSLIB_HOSZT}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE
    if [ $(java -jar ${TSLIBCLI_PATH} --version | awk '{print $1}') = 'TS3310CLI' ]; then
        java -jar ${TSLIBCLI_PATH} -u ${TSLIB_FELH} -p ${TSLIB_JELSZO} -a ${TSLIB_HOSZT} --viewCleaningCartridges -t 30000 | sed '1d' | awk -F', ' '{sub(/ */,"",$1); sub(/ */,"",$NF); print $1" ("$NF" tisztitas maradt)"}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
    else
        java -jar ${TSLIBCLI_PATH} -u ${TSLIB_FELH} -p ${TSLIB_JELSZO} -a ${TSLIB_HOSZT} --viewCleaningCartridges --setMaxSocketExceptionRetries 3 | awk -F', ' '/Slot/{sub(/ */,"",$1); sub(/ */,"",$6); print $1" ("$6" tisztitas maradt)"}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
    fi
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
fi
 
#_________________________________________________________________________________________________________________________________________________________________
if [[ "$TSLIBRARIES" ]]; then
fejlec "ures slotok szama a library-ben"
for TSLIBRARY in $TSLIBRARIES; do
    TSLIB_FELH=${TSLIBRARY%%:*}
    TSLIB_JELSZO=${TSLIBRARY#*:}
    TSLIB_JELSZO=${TSLIB_JELSZO%@*}
    TSLIB_HOSZT=${TSLIBRARY##*@}
    echo "> @${TSLIB_HOSZT}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE
    if [ $(java -jar ${TSLIBCLI_PATH} --version | awk '{print $1}') = 'TS3310CLI' ]; then
        java -jar ${TSLIBCLI_PATH} -u ${TSLIB_FELH} -p ${TSLIB_JELSZO} -a ${TSLIB_HOSZT} -viewSystemSummary | awk 'BEGIN{RS=ORS="\n\n";FS=OFS="\n"}/Storage Slots/' | awk '{a[$1]=$2}END{print a["Empty:"]"/"a["Total:"]}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
    else
        java -jar ${TSLIBCLI_PATH} -u ${TSLIB_FELH} -p ${TSLIB_JELSZO} -a ${TSLIB_HOSZT} -viewSystemSummary | awk '/empty/{print $5}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
    fi
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
fi
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "drive kihasznaltsag library-kben"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVER}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
 
 FILLER="#"
 declare -A MATRIX
 QUERY_DATE=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER -dataonly=y -commadel "select date(current_timestamp) || ' 00:00:00.000000' from sysibm.sysdummy1")
 LIBRARIES=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER -dataonly=y -commadel "select distinct library_name from drives where online='YES'")
 
 for LIBRARY in $LIBRARIES; do
SQL="select ORA, cast(round(sum(USAGE) / (select count(*) from drives where online='YES' and library_name='${LIBRARY}')) as dec(4,0)) from (
select concat(date(start_time) || ' ',substr(time(start_time),1,2)) as ORA, sum( cast(CASE WHEN substr(end_time,1,13)=substr(start_time,1,13) THEN timestampdiff(4,end_time-start_time) WHEN substr(end_time,1,13)>substr(start_time,1,13) THEN timestampdiff(4,timestamp(concat(date(start_time) || ' ', substr(time(start_time),1,2) || ':59:59.000000'))-start_time) END as dec(5,2))) /60*100 as USAGE from summary where ACTIVITY='TAPE MOUNT' and library_name='${LIBRARY}' and start_time<timestamp('$QUERY_DATE') and start_time>timestamp('$QUERY_DATE') - 1 days group by concat(date(start_time) || ' ',substr(time(start_time),1,2))
UNION ALL
select concat(date(end_time) || ' ',substr(time(end_time),1,2)) as ORA, sum( cast(CASE WHEN substr(end_time,1,13)>substr(start_time,1,13) THEN timestampdiff(4,end_time-timestamp(concat(date(end_time) || ' ', substr(time(end_time),1,2) || ':00:00.000000'))) END as dec(5,2))) /60*100 as USAGE from summary where ACTIVITY='TAPE MOUNT' and library_name='${LIBRARY}' and end_time<timestamp('$QUERY_DATE') and end_time>timestamp('$QUERY_DATE') - 1 days group by concat(date(end_time) || ' ',substr(time(end_time),1,2))
) group by ORA ORDER BY ORA"
SQL2="select concat(date(start_time+1 hours) || ' ',substr(time(start_time+1 hours),1,2)) as ORA, cast(CASE WHEN substr(end_time,1,13)>substr(start_time+1 hours,1,13) THEN timestampdiff(8,timestamp(concat(date(end_time) || ' ',substr(time(end_time),1,2)) || ':00:00.000000')-timestamp(concat(date(start_time+1 hours) || ' ',substr(time(start_time+1 hours),1,2)) || ':00:00.000000')) END as dec(5,0)) *60  as USAGE from summary where ACTIVITY='TAPE MOUNT' and library_name='${LIBRARY}' and start_time>timestamp('$QUERY_DATE') - 1 days and start_time<timestamp('$QUERY_DATE') ORDER BY start_time"
SQL_DRIVE_USAGE="SELECT decimal(SUM(float(hour(end_time - start_time)*60+minute(end_time - start_time)))/1440*100/count(DISTINCT substr(drive_name,1,posstr(drive_name,' '))),5,1) as \"24H LOAD (%)\" FROM summary WHERE activity='TAPE MOUNT' AND date(current_timestamp) - 1 days < start_time and end_time<date(current_timestamp) and library_name='${LIBRARY}' GROUP BY library_name"
 
NUM_OF_DRIVES=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER -dataonly=y -commadel "select count(*) from drives where online='YES' and library_name='${LIBRARY}'")
 
NR=0
rm -rf $TMP_FILE.drvusage $TMP_FILE.drvusage.2
# Matrix inicializalasa
for J in {1..24}; do
    for I in {1..24}; do
        MATRIX[$I,$J]=" "
    done
    printf "%02d, 0\n"  "$((10#$J-1))" >> $TMP_FILE.drvusage
    printf "%02d, 0\n"  "$((10#$J-1))" >> $TMP_FILE.drvusage.2
done
AKT_DATUM=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER -dataonly=y "select date(current_timestamp - 1 days) from sysibm.sysdummy1" | sed 's/ //g')
 
# Lekerdezem az adott oranal regebben kezdodott es kesobb vegzodott hasznalatot
# Az SQL a jelolt oratol kezdve annyi oran at tarto mountot ad vissza, ahanyszor az ertekben a 60 megvan.
# Ennek alapjan adok hozza ertekeket az adott naphoz
dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER -dataonly=y -commadel "${SQL2}" | grep "$AKT_DATUM" | sed 's/^[^ ]* //' | grep ',[0-9]*$' | while read SOR; do
    HOUR=$(echo $SOR | awk -F',' '{print $1}')
    VALUE=$(echo $SOR | awk -F',' '{print $2}')
    OLD_VALUE=$(grep "^$HOUR," ${TMP_FILE}.drvusage.2 | awk -F',' '{print $2}')
    while [[ "$VALUE" -gt 0 ]]; do
        USAGE=$(echo "scale=2; (1/${NUM_OF_DRIVES}*100) + $OLD_VALUE" | bc | sed 's/\..*$//')
        sed -i "s/^$HOUR,.*/$HOUR, $USAGE/" $TMP_FILE.drvusage.2
        HOUR=$((10#$HOUR+1))
        [[ $HOUR -lt 10 ]] && HOUR="0$HOUR"
        VALUE=$((10#$VALUE-60))
    done
done
 
# Az ures orakkal valo kiegeszitese az adatfajlnak
dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=$TSM_SZERVER -dataonly=y -commadel "$SQL" | sed 's/^[^ ]* //' | while read SOR; do
    HOUR=$(echo $SOR | awk -F',' '{print $1}')
    VALUE=$(echo $SOR | awk -F',' '{print $2}')
    sed -i "s/^$HOUR,.*/$HOUR, $VALUE/" $TMP_FILE.drvusage
done
# A diagram matrix feltoltese
while read SOR; do
    NR=$((10#$NR+1))
    HOUR=$(echo $SOR | awk -F',' '{print $1}')
    VALUE=$(echo $SOR | awk -F',' '{print $2}')
    COL=$(($NR*2))
    MATRIX[1,$NR]=$HOUR
    for I in {2..11}; do
        # 10-re kerekites varazslas
        if [[ $(echo "scale=2; $VALUE/10" | bc | awk '{printf("%d\n",$1 + 0.5)}') -le $(((10#$I-2))) ]]; then
            # Az 50%-os segedmutato
            [[ $I -eq 7 || $I -eq 2 ]] && MATRIX[$I,$NR]="_" ||  MATRIX[$I,$NR]=" "
        else
            MATRIX[$I,$NR]="$FILLER"
        fi
    done
    MATRIX[$((10#$I+1)),$NR]="_"
done <<< "`paste $TMP_FILE.drvusage $TMP_FILE.drvusage.2 | awk '{print $1, ($2 + $4)}'`"
 
# Diagram matrix kiirasa a \ tengelyre tukrozve, majd - tengelyre tukrozve
echo '<div style="margin: 10px 130px 10px 130px;"><pre style="padding:10px;  background-color: #4B4B4B; color: white; border: 2px solid #D2D2D2;">' >> $TMP_HTML_FILE
echo $AKT_DATUM | sed  -e :a -e 's/^.\{1,'$((10#$NR*3))'\}$/ & /;ta' | tee -a $TMP_HTML_FILE >> $TMP_FILE
for ((J=1;J<=NR;J++)) do
    for ((I=1;I<=NR;I++)) do
        if [[ ${MATRIX[$J,$I]} =~ [0-9] ]]; then
            printf "%3s" ${MATRIX[$J,$I]}
        else
            printf "%3s" ${MATRIX[$J,$I]}${MATRIX[$J,$I]}
        fi
    done
    [[ $J -eq 7 || $J -eq 2 || $J -eq 12 ]] && printf " _%3s\n" "$((($J-2)*10))%" || echo
done | tac  | tail -n 13 | tee -a $TMP_HTML_FILE >> $TMP_FILE
 
TOTAL_DRV_USAGE=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=yes -commadel "$SQL_DRIVE_USAGE" | egrep -v '(ANR|ANS)')
echo "${LIBRARY} (Teljes kihasznaltsag: ${TOTAL_DRV_USAGE}%)" | sed  -e :a -e 's/^.\{1,'$((10#$NR*3))'\}$/ & /;ta'  >> $TMP_FILE
echo "<b>${LIBRARY} (Teljes kihasznaltsag: ${TOTAL_DRV_USAGE}%)</b>" | sed  -e :a -e 's/^.\{1,'$((10#$NR*3))'\}$/ & /;ta' >> $TMP_HTML_FILE
echo '</pre></div>' >> $TMP_HTML_FILE
echo -e "\n\n" >> $TMP_FILE
 
 done # for LIBRARY in $LIBRARIES; do
 
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "kevesebb, mint $AVAILABLE_SCR_WARN hasznalhato scratch szalaggal rendelkezo storage poolok"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=yes "$SQL_KEVES_SCRATCH" | grep '[0-9]$' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "readonly, unavailable es destroyed volume-ok szama"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "$SQL_PROBLEMAS_VOLUMEOK" | sed -n 's/[^0-9]*//gp' | sed 's/$/ db/' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "fals private szalagok ('private' statuszu, megis a 'Last use' datum erteke NULL)"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "$SQL_TEVES_PRIV_SZALAGOK" | grep -v '^AN[RS][0-9][0-9][0-9][0-9][SEWID]' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "offline driveok szama"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "$SQL_OFFLINE_DRIVEOK" | sed -n 's/[^0-9]*//gp' | sed 's/$/ db/' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "offline pathok szama"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "$SQL_OFFLINE_PATHOK" | sed -n 's/[^0-9]*//gp' | sed 's/$/ db/' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "elmult 24 ora NDMP mentesei"
echo "VIRTUALFS                           START_TIME            BACKUP_TIME" | tee -a $TMP_HTML_FILE >> $TMP_FILE
echo "-------------------------------     -----------------     ------------" | tee -a $TMP_HTML_FILE >> $TMP_FILE
for TSM_SZERVER in $TSM_SZERVEREK; do
    echo "> @${TSM_SZERVER}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=tabl "$SQL_NDMP_MENTESEK" | egrep -v '(ANS|ANR)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
#_________________________________________________________________________________________________________________________________________________________________
fejlec "sikertelen admin utemezesek (utolso 24h)"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} q ev \* t=a begint=-24:00 endd=today endt=now | grep Failed | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "sorozatosan (elmult 3 napban min. 3x) Missed statuszu utemezesek es nodajaik"
echo "NODE NAME                 SCHEDULE                       CONTACT                   3 DAY COUNT         LAST SEEN" | tee -a $TMP_HTML_FILE >> $TMP_FILE
echo "---------------------     --------------------------     ---------------------     ------------     ------------" | tee -a $TMP_HTML_FILE >> $TMP_FILE
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "$SQL_3X_MISSED" | egrep -v "(ANR|ANS)" | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "elmult 24h Failed kliens utemezesei"
echo "NODE NAME              SCHEDULE NAME                ACTUAL START             RUNTIME      RESULT" | tee -a $TMP_HTML_FILE >> $TMP_FILE
echo "------------------     ------------------------     --------------------     --------     -----------------"| tee -a $TMP_HTML_FILE >> $TMP_FILE
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=tabl "$SQL_Q_FAILED_EVENTS" | egrep -v '(ANS|ANR)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "storage pool masolasi hibak (utolso 24h)"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=yes -displ=list 'q act s="copy storage pool" begint=-24' | grep -B1 "Unreadable Bytes: [^0]" | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "primary es copy poolban tarolt adatmennyisegek"
echo 'POOLTYPE                               TOTAL_DATA_GB            PENDING_COPY_GB' | tee -a $TMP_HTML_FILE >> $TMP_FILE
echo '--------------------------------     ---------------     ----------------------' | tee -a $TMP_HTML_FILE >> $TMP_FILE
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "$SQL_COMPARE_PRIMARY_COPY_POOLS" | egrep -v '(ANS|ANR)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Automatikusan lemigralt diszk poolok migracioinak szama az elmult 24 oraban"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        POOLS=$(dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "select stgpool_name from stgpools where devclass='DISK'" | tr '\n' '|' | sed 's/ //g')
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=list "q ac s='Migration process * automatically' begint=-24" | awk /${POOLS%|}/'{print $10" ("$12$13")"}' | sort | sed -e 's/Mig//g' -e 's/,)/)/g' | uniq -c | awk '{printf "%2sx %-20s %10s\n",$1,$2,$3}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "tsm szerver(ek) adatmozgasai (utolso 24h)"
echo 'DOMAIN_NAME       ACTIVITY                     GB' | tee -a $TMP_HTML_FILE >> $TMP_FILE
echo '---------------   ---------------   -------------' | tee -a $TMP_HTML_FILE >> $TMP_FILE
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -commadel -dataonly=y -displ=list "${SQL_UTOLSO24H_ADATMOZGASAI}" | egrep "(ARCHIVE|BACKUP|RESTORE|RETRIEVE)" | awk -F',' '{printf "%-15s   %-15s   %10s GB\n",$1,$2,$3}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "TSM szerverek aktivitasa (utolso 24h)"
echo 'ACTIVITY                          GB' | tee -a $TMP_HTML_FILE >> $TMP_FILE
echo '-----------------------   ----------' | tee -a $TMP_HTML_FILE >> $TMP_FILE
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -commadel -displ=list -dataonly=yes "${SQL_UTOLSO24H_AKTIVITASAI}" | grep '.[0-9][0-9]$' | awk -F',' '{printf "%-20s   %10s GB\n",$1,$2}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "az utolso 24 ora legtovabb tarto menteseinek nodejai"
>$TMP_FILE.toptime
for TSM_SZERVER in $TSM_SZERVEREK; do
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "q ac msgno=4964 begint=-24" | egrep -v "(ANR|ANS)" | sed "s/^.*$/${TSM_SZERVER} &/" | awk '{printf $1": "$7" "$11"\n"}' | sed -e 's/)//' -e 's/(.*//' | awk '{printf "%-10s %-30s %11s\n",$1,$2,$3}' >> $TMP_FILE.toptime
done
cat $TMP_FILE.toptime | sed 's/:/./g' | sort -k3 -r -b -n | sed 's/\./:/g' | head -n12 | tee -a $TMP_HTML_FILE >> $TMP_FILE
rm $TMP_FILE.toptime
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "az utolso 24 ora legnagyobb adatmennyiseget mento nodejai"
>$TMP_FILE.topsize
for TSM_SZERVER in $TSM_SZERVEREK; do
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "q ac msgno=4961 begint=-24" | sed "s/^.*$/${TSM_SZERVER} &/" | awk '{printf $1":"$7" "$13" "$14"\n"}' | sed -e 's/)//' -e 's/(.*//' | awk '{printf "%-40s %8s %2s\n",$1,$2,$3}' >> $TMP_FILE.topsize
done
awk '{print $1}' $TMP_FILE.topsize | sort | uniq | while read NODE; do awk -v n="$NODE" '{if ($1 == n) { if ($3 == "TB") szorzo=1024*1024; else if ($3 == "GB") szorzo=1024; else szorzo=1; sum = sum + $2*szorzo ; count++}} END {print n " has backed up " sum/1024 " GB total in " count " phases."}' < $TMP_FILE.topsize; done | sort -n -r -k5,5 | head -n 10 | tee -a $TMP_HTML_FILE >> $TMP_FILE
rm $TMP_FILE.topsize
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Deduplikacioval megsporolt hely" 
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        if [ `szerverver $TSM_SZERVER` -gt 5 ]; then
		dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "$SQL_DEDUP_SAVINGS" | egrep -v "(ANR|ANS)" | sort -n -t',' -k2 | awk -F',' '{printf "%-40s  %8d GB\n",$1,$2}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
	fi
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
if [ "$TSM_REPL_SZERVEREK" ]; then
fejlec "Node replikacios szinkron allapot"
for TSM_SZERVER in $TSM_REPL_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        if [ `szerverver $TSM_SZERVER` -gt 5 ]; then
		dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y 'q replnode *' | egrep -v "(ANR|ANS)" | sed 's/\([0-9]\),\([0-9]\)/\1\2/g' | awk '{if ( $5 != $7 ) print $0}' > $TMP_FILE.repl
		# Osszeadom egy node osszes filespace-enek objektumszam eltereset
		cat $TMP_FILE.repl | awk '{print $1}' | sort | uniq | while read NODE; do
        		grep "^$NODE[\t ]" $TMP_FILE.repl | awk 'BEGIN {SZUMMA=0} {SZUMMA=SZUMMA+$7-$5} END {printf "%-25s: %8s\n",$1,SZUMMA}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
		done
        fi
done
rm $TMP_FILE.repl
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
fi
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "$DEAD_NODE_AGE napnal regebb ota nem bejelentkezett, nem lockolt nodeok"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "$SQL_DEAD_NODES" | egrep -v "(ANR|ANS)" | sort -n -t',' -k2 | awk -F',' '{printf "%-40s  %4d napja\n",$1,$2}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "A TSM szerver altal visszautasitott node bejelentkezesek"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "$SQL_REFUSED_NODES" | egrep -v '(ANR2034|ANS8001)' | awk '{print $7" "$8}' | sed 's/([0-9]\+)//' | sort | uniq -c | awk '{printf "%4dx  %-30s %-17s\n",$1,$2,$3}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
 
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "$RECLAIM_TH% reclamation kuszoberteket elert volume-ok szama a storage poolokban"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "$SQL_RECLAIMABLE_VOL_NUM" | grep -v '^AN[RS][0-9][0-9][0-9][0-9][SEWID]' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Nem letezo stg poolra mutato copygroup-ok"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "$SQL_MISSING_COPYGROUP_DEST" | egrep -v '(ANR|ANS)' | awk -F',' '{printf "%-15s  %-15s  %-15s  %-15s  %-15s\n",$1,$2,$3,$4,$5}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "INCLEXCL modositasok CLIENTOPTIONSET-ekben"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "$SQL_CLIENTO_MESSAGES" | grep -i INCLEXCL | egrep -v '(ANR2034|ANS8001)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "nem hasznalt client optionsetek"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "$SQL_NEM_HASZNALT_OPTIONSETEK" | egrep -v '(ANR|ANS)' | sort | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Policy aktivalasok (elmult 24 oraban)"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=list "q ac msgno=1514 begint=-24" | tr '\n' ' ' | sed -e 's/Date.Time: /\n/g' | grep 'Message' | sed -e 's/  Message: //' -e 's/ *(SESSION: [0-9]*)//' | awk '{if ($NF > 0) {print $0}}' | egrep -v '(ANR2034|ANS8001)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
 
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Mentes soran rebound-olt objektumok (elmult 25 oraban)"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -displ=list "q ac msgno=4960 begint=-25" | tr '\n' ' ' | sed -e 's/Date.Time: /\n/g' | grep 'Message' | sed -e 's/  Message: //' -e 's/ *(SESSION: [0-9]*)//' | awk '{if ($NF > 0) {print $0}}' | egrep -v '(ANR2034|ANS8001)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
 
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Damaged objektumok"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        # NORMAL storage poolok
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "select stgpool_name from stgpools where pooltype='PRIMARY' and not stg_type='DIRECTORY'" | egrep -v 'AN[RS]' | while read POOL; do
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y show damaged $POOL > ${TMP_FILE}.damaged
        if [[ $(grep 'No damaged files found.' ${TMP_FILE}.damaged | wc -l) -eq 0 ]]; then
            cat ${TMP_FILE}.damaged | tee -a $TMP_HTML_FILE >> $TMP_FILE
        fi
        done
        # DIRECTORY CONTAINER poolok
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y "select stgpool_name from stgpools where pooltype='PRIMARY' and stg_type='DIRECTORY'" | egrep -v 'AN[RS]' | while read POOL; do
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y query damaged $POOL t=n> ${TMP_FILE}.damaged
        if [[ $(grep 'QUERY DAMAGED: No match found using this criteria' ${TMP_FILE}.damaged | wc -l) -eq 0 ]]; then
            cat ${TMP_FILE}.damaged | tee -a $TMP_HTML_FILE >> $TMP_FILE
        fi
        done
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
rm ${TMP_FILE}.damaged
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Adatbazis REORG uzenetek (utolso 24h)"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "$SQL_REORG_MESSAGES" | egrep -v '(ANR2034|ANS8001)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "Tape hiba uzenetek (utolso 24h)"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "$SQL_HWERR_MESSAGES" | egrep -v '(ANR2034|ANS8001)' | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "ANR9999D tipusu uzenetek (utolso 24h)" 
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
	dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "q ac s='ANR9999D_' begint=-24" | grep -v "Administrator `echo $TSM_FELH | tr '[:lower:]' '[:upper:]'` issued command" |  fold -w 800 -s | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#_________________________________________________________________________________________________________________________________________________________________
fejlec "ANR????E tipusu uzenetek, kiveve 2034,1930,1931,0944 (utolso 24h)"
for TSM_SZERVER in $TSM_SZERVEREK; do
        if [ $(echo $TSM_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${TSM_SZERVERNEV[$TSM_SZERVER]}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
        dsmadmc -id=$TSM_FELH -pa=$TSM_JELSZO -se=${TSM_SZERVER} -dataonly=y -commadel "$SQL_ACTLOG_ERRORS" | egrep -v '(ANR2034|ANS8001)' | uniq -c -s 19 | sed 's/\(^[\t ]*\)\([0-9]*\)\(.*$\)/\3 \2/' | awk '{if ($NF==1) NF--; else $(NF)="(x" $(NF) ")";print}' | fold -w 800 -s | tee -a $TMP_HTML_FILE >> $TMP_FILE
done
echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
 
# OS szintu ellenorzesek
if [[ ! -f $SSH_KEY_FILE ]]; then
	echo "<->" | tee -a $TMP_HTML_FILE >> $TMP_FILE
        echo "- Nincs kulcs az OS-es resz futtatasahoz, igy a riportnak itt vege." >>$TMP_FILE
else
	echo "$HTML_TABLA_LABLEC" >> $TMP_HTML_FILE
	echo "<br><table border=0 width=\"960\"><tr><td><pre style=\"text-align: left\">" >> $TMP_HTML_FILE
	echo "|                                                   _/_/        _/_/_/                                            |" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	echo "|                                                _/    _/     _/                                                  |" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	echo "|                          _/_/_/_/_/           _/    _/       _/_/             _/_/_/_/_/                        |" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	echo "|                                              _/    _/           _/                                              |" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	echo "|                                               _/_/        _/_/_/                                                |" | tee -a $TMP_HTML_FILE >> $TMP_FILE
	echo "</pre></td></tr></table><br>" >> $TMP_HTML_FILE
	echo "$HTML_TABLA_FEJLEC" >> $TMP_HTML_FILE
 
#	echo -e "\n_______________________________________ AIX errpt KIMENETEK TEGNAP ES MA __________________________________________" | tee -a $TMP_HTML_FILE >> $TMP_FILE
        if [ $OS_AIX_ERRPT -eq 1 ]; then
            fejlec "errpt uzenetek az elmult 24 oraban"
            DATUM=`date +%m%d`
            TEGNAP=`expr $DATUM - 1`
            if [ $TEGNAP -lt 1001 ]; then TEGNAP=0$TEGNAP; fi
            for SSH_SZERVER in $SSH_SZERVEREK; do
		if [ `ssh $SSH_OPT ${SSH_SZERVER} 'uname -s'` != 'AIX' ]; then continue; fi 
                if [ $(echo $SSH_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${SSH_SZERVER##*@}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
		ssh $SSH_OPT ${SSH_SZERVER} 'errpt' | grep " $DATUM" | uniq -c -s 19 | sed -e :a -e 's/\(.\{11\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \6.\2.\3. \4:\5/;ta' |  sed 's/\(^[\t ]*\)\([0-9]*\)\(.*$\)/\3 \2/' | awk '{if ($NF==1) NF--; else $(NF)="(x" $(NF) ")";print}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
		ssh $SSH_OPT ${SSH_SZERVER} 'errpt' | grep " $TEGNAP" | uniq -c -s 19 | sed -e :a -e 's/\(.\{11\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \6.\2.\3. \4:\5/;ta' |  sed 's/\(^[\t ]*\)\([0-9]*\)\(.*$\)/\3 \2/' | awk '{if ($NF==1) NF--; else $(NF)="(x" $(NF) ")";print}' | tee -a $TMP_HTML_FILE >> $TMP_FILE
	    done
	fi
	echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#	echo -e '\n______________________________________ FAJLRENDSZER TELITETTSEGEK ES HSM __________________________________________' | tee -a $TMP_HTML_FILE >> $TMP_FILE
        if [ $OS_DF -eq 1 ]; then
            fejlec "fajlrendszer telitettsegek"
            for SSH_SZERVER in $SSH_SZERVEREK; do
                if [ $(echo $SSH_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${SSH_SZERVER##*@}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
		if [ `ssh $SSH_OPT ${SSH_SZERVER} 'uname -s'` = 'AIX' ]; then ssh $SSH_OPT ${SSH_SZERVER} 'df -g'; fi | tee -a $TMP_HTML_FILE >> $TMP_FILE
		if [ `ssh $SSH_OPT ${SSH_SZERVER} 'uname -s'` = 'Linux' ]; then ssh $SSH_OPT ${SSH_SZERVER} 'df -Ph'; fi | tee -a $TMP_HTML_FILE >> $TMP_FILE
	    done
	fi
	echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#	echo -e '\n___________________________________ HSM FAJLRENDSZER TELITETTSEGEK ES HSM __________________________________________' | tee -a $TMP_HTML_FILE >> $TMP_FILE
        if [ $OS_DDF -eq 1 ]; then
            fejlec "hsm fajlrendszer allapotok"
            for SSH_SZERVER in $SSH_SZERVEREK; do
                if [ $(echo $SSH_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${SSH_SZERVER##*@}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
		if [ `ssh $SSH_OPT ${SSH_SZERVER} 'uname -s'` = 'AIX' ]; then ssh $SSH_OPT ${SSH_SZERVER} 'ddf'; fi | tee -a $TMP_HTML_FILE >> $TMP_FILE
		if [ `ssh $SSH_OPT ${SSH_SZERVER} 'uname -s'` = 'Linux' ]; then ssh $SSH_OPT ${SSH_SZERVER} 'ddf'; fi | tee -a $TMP_HTML_FILE >> $TMP_FILE
	    done
	fi
	echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
 
#	echo -e '\n_________________________________________ AIX PAGING SPACE HASZNALAT _____________________________________________' | tee -a $TMP_HTML_FILE >> $TMP_FILE
    	if [ $OS_AIX_LSPS -eq 1 ]; then
	    fejlec "aix paging space kihasznaltsag"
	    for SSH_SZERVER in $SSH_SZERVEREK; do
		if [ `ssh $SSH_OPT ${SSH_SZERVER} 'uname -s'` != 'AIX' ]; then continue; fi 
        	if [ $(echo $SSH_SZERVEREK | wc -w) -gt 1 ]; then echo "> @${SSH_SZERVER##*@}:" | tee -a $TMP_HTML_FILE >> $TMP_FILE; fi
		ssh $SSH_OPT ${SSH_SZERVER} 'lsps -s | head -n 1' | tee -a $TMP_HTML_FILE >> $TMP_FILE
		ssh $SSH_OPT ${SSH_SZERVER} 'lsps -s | grep "%"' | tee -a $TMP_HTML_FILE >> $TMP_FILE
	    done
	fi
	echo "$HTML_MODUL_LABLEC" >> $TMP_HTML_FILE
fi
ENDTIME=`date "+%s"`
echo "$HTML_TABLA_LABLEC" >> $TMP_HTML_FILE
echo "[A riport $((($ENDTIME-$STARTTIME)/60)) perc $((($ENDTIME-$STARTTIME)%60)) mp alatt keszult el - TSM riporter $SCRIPT_VER]" | tee -a $TMP_HTML_FILE >> $TMP_FILE
# Riport kuldese
DATUM=`date +"%F_%H-%M"`
mkdir -p $LOG_DIR >/dev/null
if [ $? -eq 0 ]; then
        cp $TMP_FILE $LOG_DIR/tsm_napi_riport_${DATUM}.log
	echo "<br>[A riport szoveges valtozata az alabbi utvonalon helyben is le lett tarolva: "`hostname`":$LOG_DIR/tsm_napi_riport_${DATUM}.log]" >> $TMP_HTML_FILE
        ERR=$?
fi
if [[ $ERR -ne 0 || ! $ERR ]]; then
        echo "HIBA: A riportot nem sikerult a $LOG_DIR mappaba menteni!" >>$TMP_HTML_FILE
fi
 
sed -i -e 's/^|//' -e 's/|$//' $TMP_HTML_FILE
sed -i 's/> @[0-9a-zA-Z_-.]*:/<div style="font-weight:bold; color: #800040; padding: 0px; margin-top: 10px">&<\/div>/' $TMP_HTML_FILE # TSM sztanza szinezes
sed -i -e "s/_-_*[^_]*_-_*/<div style=\"text-align: center; font-family: Verdana; font-weight:bold; font-size: 12px; color: #006DC7; margin-top: 10px; padding: 0px;\">&<\/div>$HTML_VONAL/" -e 's/_-_//g' $TMP_HTML_FILE # Szekcio fejlec szinezes
#sed -i -e 's/_-_*[^_]*_-_*/<div style="text-align: center; font-family: Verdana; font-weight:bold; font-size: 12px; color: #006DC7; margin-top: 10px; padding: 0px;">&<\/div><hr align=center width="50%" size="1" noshade style="color: #D2D2D2">/' -e 's/_-_//g' $TMP_HTML_FILE # Szekcio fejlec szinezes
 
sed -i 's/\\c/\\\\c/g' $TMP_HTML_FILE # \c karaktert ESCAPE-elni kell, mert lezarja az output csatornat
echo -e "<html>${JS_CODE}<body><center><div style=\"font-size: 14px; font-family: courier;\">\n$(cat ${TMP_HTML_FILE})</div></td></tr></body></html>" > $TMP_HTML_FILE
if [ `echo "$MAILTO" | grep "@.*\."` ]; then
        if [[ `which sendmail` && $HTML_EMAIL -eq 1 ]]; then
                echo -e "To: $MAILTO\nMIME-Version: 1.0\nContent-Type: text/html\nContent-Disposition: inline\nSubject: TSM napi riport ($TSM_SZERVERNEVEK)\n$(cat ${TMP_HTML_FILE})" > $TMP_HTML_FILE
                cat $TMP_HTML_FILE | sendmail -B 8BITMIME -t -F "TSM riporter"
        elif [[ ! $HTML_EMAIL -eq 1 && $HTML_EMAIL_CSAT -eq 1 ]]; then
                echo -e "To: $MAILTO\nSubject: TSM napi riport ($TSM_SZERVERNEVEK)\n$(cat $TMP_FILE)" > $TMP_FILE
                cp $TMP_HTML_FILE /tmp/tsm_napi_riport_${DATUM}.html
                cat $TMP_FILE | mailx -a /tmp/tsm_napi_riport_${DATUM}.html -t
        else
                echo -e "To: $MAILTO\nSubject: TSM napi riport ($TSM_SZERVERNEVEK)\n$(cat $TMP_FILE)" > $TMP_FILE
                cat $TMP_FILE | mailx -t
        fi
fi
# Takaritas
rm napi_ellenorzes.tmp
rm $TMP_FILE
rm $TMP_FILE.html
rm /tmp/tsm_napi_riport_${DATUM}.html 2>/dev/null