meta data for this page
  •  

TSM és OS adatgyűjtő TSM szerver felméréshez

TSM-es környezet OS konfigurációjának és TSM szerver állapotának felméréséhez gyűjt le néhány hasznos adatot.

tsm_gather_data.sh
#!/bin/sh
#************** konfig start ************************************#
OUTPUT_DIR="/tmp"
TSMUSER=report
TSMPASS=report
TSMSERVER=tsm  # dsm.sys servername XXX
INAKTIV_NODE_NAPSZAM=32
#************** konfig vege  ************************************#
 
HOST=$(hostname)
DSMADMCOPTS="-se=$TSMSERVER" # -dataonly=y"
 
# Az elmult 7 nap aktivitasa tipusonken:t
SQL1="SELECT substr(end_time,1,10), substr(activity,1,20), cast(float(sum(bytes))/1024/1024/1024 as dec(8,0)) as GB FROM summary WHERE end_time>current_timestamp-168 hours and activity<>'EXPIRATION' and bytes>0 GROUP BY activity, substr(end_time,1,10)"
# Az elmuĂlt 7 nap adatmozgasai
SQL2="select substr(end_time,1,10) as DATE, substr(nn.domain_name,1,15) as DOMAIN,substr(summary.activity,1,15) as 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 - 168 hours and current_timestamp) and (activity='BACKUP' or activity='RESTORE' or activity='ARCHIVE' or activity='RETRIEVE') and ((nn.node_name=summary.entity)) group by substr(end_time,1,10),domain_name,summary.activity order by date,activity,domain_name asc"
# Node-ok méretei
SQL3="select substr(ao.node_name,1,30) as node_name, ao.total_mb, sum(distinct oc.num_files) as NUM_FILES,count(distinct vu.volume_name) as tapes from auditocc ao JOIN occupancy oc ON ao.node_name=oc.node_name left JOIN volumeusage vu ON vu.node_name=ao.node_name group by ao.node_name,ao.total_mb order by 2 desc"
# Adatbazis mentesek futasi ideje elmult 30 napban:
SQL4="SELECT DATE(start_time) as DATE, TRANSLATE('a bc:de:fg', DIGITS(end_time-start_time), '_______abcdefgh_____',' ') as \"ELAPTIME (D HHMMSS)\", cast(bytes/1024/1024/1024 as DEC(8,2)) as GB FROM summary WHERE activity='FULL_DBBACKUP' AND current_timestamp - 30 days < start_time order by date"
# Expiration processzek futasi ideje elmult 30 napban:
SQL5="SELECT DATE(start_time) as DATE, TRANSLATE('a bc:de:fg', DIGITS(end_time-start_time), '_______abcdefgh_____',' ') as \"ELAPTIME (D HHMMSS)\", affected, number, successful FROM summary WHERE activity='EXPIRATION' AND entity IS NULL AND current_timestamp - 30 days < start_time order by date"
# Storage poolok meretei, tipusai, tarolt objektum szammal
SQL6="SELECT substr(occupancy.stgpool_name,1,20) as STGPOOL_NAME, substr(pooltype,1,15) as STGPOOL_TYPE, cast(SUM(logical_mb) as numeric (12,0)) AS Logical_MB,SUM(num_files)AS Num_Files FROM occupancy LEFT JOIN stgpools ON occupancy.stgpool_name=stgpools.stgpool_name GROUP BY occupancy.stgpool_name, pooltype"
# Teljes szerveren tarolt adatmennyisegek
SQL7="SELECT CAST(FLOAT(SUM(backup_mb))/1024 as DEC(8,0)) as BACKUP_GB, CAST(FLOAT(SUM(backup_copy_mb))/1024 as DEC(8,0)) as BACKUP_COPY_GB, CAST(FLOAT(SUM(archive_mb))/1024 as DEC(8,0)) as ARCHIVE_GB, CAST(FLOAT(SUM(archive_copy_mb))/1024 as DEC(8,0)) as ARCHIVE_COPY_GB, CAST(FLOAT(SUM(total_mb))/1024 as DEC(8,0)) as TOTAL_GB from auditocc"
# Kliensek darabszama platformonkent
SQL8="SELECT platform_name,COUNT(*) as COUNT FROM nodes where locked='NO' GROUP BY platform_name"
# Storage poolok devclass-sal, library-vel, merettel
SQL9="SELECT substr(o.stgpool_name,1,25) as STGPOOL_NAME,substr(case when s.devclass='DISK'  then s.devclass else s.devclass || ' (' || d.devtype || ')' end,1,25) as DEVCLASS ,substr(d.library_name,1,20) as LIBRARY_NAME,CAST(FLOAT(SUM(o.logical_mb))/1024/1024 AS DEC(6,2)) as TB FROM stgpools s, occupancy o, devclasses d where s.stgpool_name=o.stgpool_name and s.devclass=d.devclass_name GROUP BY o.stgpool_name,s.devclass,d.devtype,d.library_name ORDER BY o.stgpool_name"
# Inaktiv node-ok
SQL10="select substr(node_name,1,30) as node, (select domain_name from nodes no where no.node_name=oc.node_name),(select (days(current_timestamp)-days(lastacc_time)) as LAST_ACCESS  from nodes no where no.node_name=oc.node_name), sum(REPORTING_MB)/1024 as GB from occupancy oc where (select (days(current_timestamp)-days(lastacc_time)) as LAST_ACCESS  from nodes no where no.node_name=oc.node_name)>$INAKTIV_NODE_NAPSZAM GROUP BY oc.node_name order by last_access"
SQL11="select no.domain_name, count(no.node_name) as inactive_nodes,(select count(node_name) as ALL_NODES from nodes no2 where no2.domain_name=no.domain_name) from nodes no where (days(current_timestamp)-days(no.lastacc_time)) \> $INAKTIV_NODE_NAPSZAM group by no.domain_name"
# Direkt tape mountok
SQL12="select substr(message,instr(message,' ',1,6)+1,instr(message,' ',1,7)-instr(message,' ',1,6)-1) as NODE, count(*) as TAPE_MOUNTS from actlog where msgno in (0839,0406) and session in (select session from actlog where msgno=0511 and substr(message,instr(message,' ',1,6)+1,1)!='/') and current_timestamp < date_time + 7 days group by substr(message,instr(message,' ',1,6)+1,instr(message,' ',1,7)-instr(message,' ',1,6)-1)"
 
 
if [[ $1 != "-t" && $1 != "-o" ]]; then
	echo "Hasznalat:"
	echo "$0 [-t] [-o]"
	echo
	echo "  -t : TSM-es lekerdezesek futtatasa (allitsd be a szkript fejleceben a TSM-es hozzaferesi adatokat)"
	echo "  -o : OS lekerdezesek futtatasa"
	exit 1
fi 
 
while [ "$1" ]; do
if [ "$1" = "-t" ]; then
    VER=$((`dsmadmc -id=$TSMUSER -pa=$TSMPASS -se=$TSMSERVER q opt | sed -n -e 's/Server Version \([0-9]\),.*/\1/p' -e 's/\t\s//g'`))
    if [ "$VER" = "0" ]; then 	
	echo "A TSM szerverre nem tudtam bejelentkezni. Ellenorizd a konfigot a szkript fejleceben!"
	exit 1
    fi
    echo "TSM-es lekerdezeseket futtatok..."
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q system" > ${OUTPUT_DIR}/${HOST}_q_system.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q server" > ${OUTPUT_DIR}/${HOST}_q_server.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q subscription" > ${OUTPUT_DIR}/${HOST}_q_subscription.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q log" > ${OUTPUT_DIR}/${HOST}_q_log.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q dbs" > ${OUTPUT_DIR}/${HOST}_q_dbs.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q drive" > ${OUTPUT_DIR}/${HOST}_q_drive.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q drive f=d" > ${OUTPUT_DIR}/${HOST}_q_drive_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q fi" > ${OUTPUT_DIR}/${HOST}_q_fi.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q fi f=d" > ${OUTPUT_DIR}/${HOST}_q_fi_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q path" > ${OUTPUT_DIR}/${HOST}_q_path.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q path f=d" > ${OUTPUT_DIR}/${HOST}_q_path_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q auditocc" > ${OUTPUT_DIR}/${HOST}_q_auditocc.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q occ" > ${OUTPUT_DIR}/${HOST}_q_occ.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS -commadel "q occ" > ${OUTPUT_DIR}/${HOST}_q_occ_commadel.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q stg" > ${OUTPUT_DIR}/${HOST}_q_stg.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q stg f=d" > ${OUTPUT_DIR}/${HOST}_q_stg_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q stgpooldir f=d" > ${OUTPUT_DIR}/${HOST}_q_stgpooldir_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q sch" > ${OUTPUT_DIR}/${HOST}_q_sch.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q sch f=d" > ${OUTPUT_DIR}/${HOST}_q_sch_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q sch t=a" > ${OUTPUT_DIR}/${HOST}_q_sch_a.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q sch t=a f=d" > ${OUTPUT_DIR}/${HOST}_q_sch_t_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q scr f=l" > ${OUTPUT_DIR}/${HOST}_q_scr_fl.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q co t=b f=d" > ${OUTPUT_DIR}/${HOST}_q_co_b_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q co t=a f=d" > ${OUTPUT_DIR}/${HOST}_q_co_a_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q n" > ${OUTPUT_DIR}/${HOST}_q_node.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q n f=d" > ${OUTPUT_DIR}/${HOST}_q_node_fd.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS "q replnode *" > ${OUTPUT_DIR}/${HOST}_q_replnode_fd.out
 
    echo "TSM-es SELECT-eket futtatok..."
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL1 > ${OUTPUT_DIR}/${HOST}_Elmult_7_nap_aktivitasa.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL2 > ${OUTPUT_DIR}/${HOST}_Elmult_7_nap_adatmozgasai.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL3 > ${OUTPUT_DIR}/${HOST}_Node-ok_meretei.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL4 > ${OUTPUT_DIR}/${HOST}_DB_mentesek_futasi_idoi.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL5 > ${OUTPUT_DIR}/${HOST}_Expire_Invetory-k_futasi_idoi.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL6 > ${OUTPUT_DIR}/${HOST}_Storage_poolok_helyfoglalasa.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL7 > ${OUTPUT_DIR}/${HOST}_Teljes_szerveren_tarolt_adatmennyisegek.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL8 > ${OUTPUT_DIR}/${HOST}_Kliensek_szama_platformonkent.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL9 > ${OUTPUT_DIR}/${HOST}_Storage_poolok_parameterei.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL10 > ${OUTPUT_DIR}/${HOST}_Inaktiv_node-ok_listaja_merettel.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL11 > ${OUTPUT_DIR}/${HOST}_Inaktiv_node-ok_szama.out
    dsmadmc -id=$TSMUSER -pa=$TSMPASS $DSMADMCOPTS $SQL12 > ${OUTPUT_DIR}/${HOST}_Direkt_tape_mountok_szama.out
fi
 
if [ "$1" = "-o" ]; then
    echo "OS oldali lekerdezeseket futtatok..."
    if [ $(uname -s) = 'AIX' ]; then
	prtconf > ${OUTPUT_DIR}/${HOST}_prtconf.out
	ifconfig -a > ${OUTPUT_DIR}/${HOST}_ifconfig-a.out
	netstat -nr > ${OUTPUT_DIR}/${HOST}_netstat-nr.out
	lsdev -Cc disk > ${OUTPUT_DIR}/${HOST}_lsdev_disk.out
	lsdev -Cc tape > ${OUTPUT_DIR}/${HOST}_lsdev_tape.out
	lsdev -Cc adapter > ${OUTPUT_DIR}/${HOST}_lsdev_adapter.out
	lscfg > ${OUTPUT_DIR}/${HOST}_lscfg.out
	lsconf > ${OUTPUT_DIR}/${HOST}_lsconf.out
	lslpp -l > ${OUTPUT_DIR}/${HOST}_lslpp.out
	lsvg > ${OUTPUT_DIR}/${HOST}_lsvg.out
        lsvg | xargs lsvg > ${OUTPUT_DIR}/${HOST}_lsvg-all.out
        lsvg | xargs lsvg -l > ${OUTPUT_DIR}/${HOST}_lsvg-l.out
        lsvg | xargs lsvg -p > ${OUTPUT_DIR}/${HOST}_lsvg-p.out
	lsps -s > ${OUTPUT_DIR}/${HOST}_lsps.out
	oslevel -s > ${OUTPUT_DIR}/${HOST}_oslevel.out
	df -g > ${OUTPUT_DIR}/${HOST}_df.out
    fi
 
    if [ $(uname -s) = 'Linux' ]; then
	uname -a > ${OUTPUT_DIR}/${HOST}_uname-a.out
	cp /etc/udev/rules.d/99-lin_tape.rules > ${OUTPUT_DIR}/${HOST}_udev.out
	cat /proc/meminfo > ${OUTPUT_DIR}/${HOST}_meminfo.out
	cat /proc/cpuinfo > ${OUTPUT_DIR}/${HOST}_cpuinfo.out
	cat /proc/version > ${OUTPUT_DIR}/${HOST}_version.out
        ifconfig -a > ${OUTPUT_DIR}/${HOST}_ifconfig-a.out
	netstat -nr > ${OUTPUT_DIR}/${HOST}_netstat-nr.out
	lspci -vvknnqq > ${OUTPUT_DIR}/${HOST}_lspci.out
	lvs > ${OUTPUT_DIR}/${HOST}_lvs.out 
	pvs > ${OUTPUT_DIR}/${HOST}_pvs.out
        vgs > ${OUTPUT_DIR}/${HOST}_vgs.out
        cat /proc/scsi/IBMtape > ${OUTPUT_DIR}/${HOST}_IBMtape.out
        cat /proc/scsi/IBMchanger > ${OUTPUT_DIR}/${HOST}_IBMchanger.out
        df -h > ${OUTPUT_DIR}/${HOST}_df.out
    fi
fi
 
shift
done
 
echo "Elkeszitem a $OUTPUT_DIR/${HOST}_tsm_collect_data.tar.gz fajt..."
cd $OUTPUT_DIR
tar -cvf - ${HOST}_*.out | gzip > $OUTPUT_DIR/${HOST}_tsm_collect_data.tar.gz
#rm -f $OUTPUT_DIR/$HOST_*.out