1. Warning: This is not a support forum. Please do not post any questions here !!
    This forum is for your publishing HOWTOs or sharing unofficial documentation for various parts of TSM. Please do not post questions here - All question posting will be deleted.
    Repeated violators of forum rules will be banned.

  2. Forum Rules (PLEASE CLICK HERE TO READ BEFORE POSTING) Click the link to access ADSM.ORG Acceptable Use Policy and forum rules which should be observed when using this website. Violators may be banned from this website. This message will disappear after you have made at least 12 posts. Thank you for your cooperation.

Helpfull TSM Select Statements

Discussion in 'TSM Documentation,Tips and Tricks' started by athos154, Jun 15, 2011.

  1. athos154

    athos154 New Member

    Joined:
    Jun 15, 2011
    Messages:
    1
    Likes Received:
    4
    Hopefully others will find these select statements as helpfull as I have over the years:
    (Some of these can run very long, and can be resource intensive. Use at your own risk.)
    (The description follows the select statement.)

    select distinct node_name,volume_name,stgpool_name from volumeusage where node_name='xxxxx'
    * To find what tapes are used by a node (needed for restore)

    select node_name, sum(logical_mb) as Data_In_MB, sum(num_files) as Num_of_files from occupancy group by node_name order by node_name
    * To identify # and space of data files on all node

    select node_name,sum(logical_mb) as Logical_MB,sum(physical_mb) as Physical_MB, sum(num_files) as Num_of_files from occupancy where node_name='xxxxxxxxxxxxxx' group by node_name
    * To identify # and space of data files on a single node

    select node_name,count(ll_name) as Num_Active_files from backups where node_name='xxxxxxxxxxxxx' and STATE='ACTIVE_VERSION' group by node_name
    * To identify # of ACTIVE data files on a node (for restore) (This query can take a very
    long time.)

    select client_name,input_vol_access,output_vol_access from sessions where (input_vol_access is not NULL) or (output_vol_access is not NULL)
    * To identify clients reading from or writing to tape.

    select domain_name,tcp_name,nodes.node_name,filespace_name,stgpool_name,logical_mb from nodes,occupancy where nodes.node_name=occupancy.node_name
    * Billing Information (Occupancy by node)

    all:select server_name,count(volume_name) as "# of Pending Vols" from volumes,status where status like '%%PEND%%' group by server_name
    * To identify # of volumes in "pending" status per server

    all:select count(volume_name) as "# of vols" from volumes where status='PENDING' and pending_date between '2009-10-26 00:00:00.000000' and '2009-10-27 00:00:00.000000'
    * To identify total # of tapes in pending status for date (forcast tapes going scratch)

    all:select stgpool_name,count(volume_name) as "# of vols" from volumes where status='PENDING' and stgpool_name='OFFSITE' and pending_date between '2010-01-27 00:00:00.000000' and '2010-01-28 00:00:00.000000' group by stgpool_name
    * To identify # of tapes in pending status for date in the offsite pool (forcast tapes returning from Iron Mountain)

    select node_name from nodes where substr(char(reg_time), 1, 10) >='2009-12-01' and node_name not like '%%_LT%%'and node_name not like '%%EXP20%%'
    * To identify nodes registered since date

    all:select server_name,node_name,reg_time from nodes,status where reg_time>'2009-08-15 00:00:00.000000'
    * To identify nodes registered since date

    select node_name,sum(capacity) as MB_Capacity,sum(capacity*(pct_util/100)) as MB_Used_Space from filespaces group by node_name order by MB_Used_Space
    * To identify FS space and used capacity on all clients (not TSM occupancy)

    select node_name,sum(capacity) as MB_Capacity,sum(capacity*(pct_util/100)) as MB_Used_Space from filespaces where node_name='xxxxxxxxxxx' group by node_name
    * To identify FS space and used capacity on the client for a specific node (not TSM occupancy)

    all:select server_name,volume_name,type,date_time from volhistory,status where volume_name='xxxxxx'
    * To find volume history for a tape (V5)

    all:select volume_name,type,date_time from volhistory where volume_name='xxxxxx'
    * To find volume history for a tape (V6)

    select node_name,substr(char(LASTACC_TIME), 1, 10) as LASTACC_DATE from nodes where node_name not like '%%EXP20%%' and substr(char(LASTACC_TIME), 1, 10) <='2010-01-01'
    * To list nodes with last access date less than/greater than date (change date and lt/gt symbol)

    select count(node_name) from nodes where node_name not like '%%EXP20%%' and substr(char(LASTACC_TIME), 1, 10) <='2010-01-20'
    * To count # of nodes with last access date less than/greater than date (change date and lt/gt symbol)

    select count(ll_name) from backups where STATE<>'ACTIVE_VERSION' and substr(char(BACKUP_DATE), 1, 10)<substr(char(current_date - interval '45' day), 1, 10)
    * To identify # of files expired if retention policy is changed (change interval day)

    select date_time,volume_name,location from volhistory where date_time between '2010-03-16 14:00:00.000000' and '2010-03-16 23:00:00.000000'
    * Search for volumes on library manager created today

    select assoc_object,object_name from prof_associations where profile_name='xxxxxxxxx'
    * Show profile associations for profiles

    Select admin_name,client_access from admins where CLIENT_ACCESS like '%%node_name%%' group by client_access,admin_name
    * show admins who have client access on these nodes (change node_name)

    Select distinct nodename,count(nodename) from actlog where msgno=0480 group by nodename
    * Show severed sessions by nodename

    select date_time,server_name,message from actlog,status where msgno=0314 and date_time>(current_timestamp - interval '6' minute)
    * Show ANR0314W errors within the last 6 minutes.

    select entity,activity,sum(bytes),sum(end_time-start_time),sum(affected),sum(failed),sum(mediaw) from summary where entity in (select node_name from filespaces where filespace_type like '%API%' group by node_name) and start_time between '2010-06-01 17:00:00' and '2010-06-09 17:00:00' group by entity,activity
    * show TDP backup activity

    select entity,activity,sum(bytes)as sum_bytes,start_time,end_time,sum(affected)as sum_affected,sum(failed)as sum_failed,sum(mediaw) as sum_mediaw from summary where entity in (select node_name from filespaces where filespace_type like '%API%' and node_name='xxxxxxxxxxxxxxxxxxxxxxx' group by node_name) and start_time between '2010-06-08 17:00:00' and '2010-06-10 17:00:00' group by entity,activity,start_time,end_time
    * show detailed TDP backup activity for a specific node

    select node_name,domain_name from nodes where domain_name in (select domain_name from domains where activestgpools is not null)
    * show all nodes in an active data pool

    select schedule_name,command from admin_schedules where schedule_name like 'MOVE_NODEDATA_DR%%'
    * Show nodes being moved via move_nodedata_dr schedules

    select distinct node_name,volume_name from volumeusage where stgpool_name='ACTIVE_DATA_DR'
    * Show nodes on volumes in the ACTIVE_DATA_DR stg pool

    select distinct node_name,volume_name from volumeusage where volume_name in (select volume_name from volumes where stgpool_name='ACTIVE_DATA_DR' and access='READWRITE')
    * Show nodes on volumes in the ACTIVE_DATA_DR stg pool that are access=readwrite

    select msgno,nodename,sessid,message from actlog where msgno in (4952,4953,4954,4955,4956,4957,4958,4959,4960,4961,4964,4966,4967,4968,4970) and date_time between '2010-07-25 17:00:00' and '2010-07-30 17:00:00' and nodename='NODENAME' order by sessid
    * show BACKUP results for a specific node (change NODENAME)

    select msgno,nodename,sessid,message from actlog where msgno in (4955,4959,4961,4964,4966,4967) and date_time between '2011-04-15 17:00:00' and '2011-04-18 17:00:00' and nodename='NODENAME' order by sessid,msgno
    * show RESTORE results for a specific node (change NODENAME)

    select msgno,nodename,sessid,message from actlog where msgno in (4955,4959,4961,4964,4966,4967) and date_time between '2011-04-15 17:00:00' and '2011-04-18 17:00:00' order by sessid,msgno
    * show restore results for all nodes

    select activity,cast ((end_time) as date) as "Date",(examined/cast ((end_time-start_time) seconds as decimal (18,13))*3600) "Obj/Hr" from summary where activity='EXPIRATION' and days (end_time) - days (start_time) = 0
    * show Expiration Rate for servers (IBM recommendS that the Expiration Rate be greater than 3800000 objects per hour)
     
  2.  
  3. unpaired

    unpaired New Member

    Joined:
    Jun 17, 2010
    Messages:
    84
    Likes Received:
    1
    it is great :) thank you
     
  4. unpaired

    unpaired New Member

    Joined:
    Jun 17, 2010
    Messages:
    84
    Likes Received:
    1
    SELECT start_time,END_TIME,activity,entity FROM summary WHERE activity='BACKUP' AND (start_time <= '2012-05-23 08:00:00' and end_time >= '2012-05-23 06:00:00')

    between 06:00-08:00 hour backup activity
     
  5. maktsm

    maktsm New Member

    Joined:
    Jun 13, 2012
    Messages:
    7
    Likes Received:
    0
    Occupation:
    TSM Administrator
    Thanks for such useful commands athos154.
    Wanted to know if there is any such statement which can be used to track location for a file belonging to a particular node that has to be restored.

    Thanks.
     
  6. shcart

    shcart New Member

    Joined:
    Jan 6, 2003
    Messages:
    72
    Likes Received:
    0
    Location:
    Monroe, NC
    maktsm this is a two or three step job. First you use a select to find the object_id followed by a show bfo to find where the file is and if it is part of an aggregate another show bfo command to show the bitfile aggregate object. Be very careful abuse of the select ... from backups ... can run for many hours if you get it wrong you need to soecify as much detail as possible as follows

    PLEASE REMEMBER ALWAYS SPECIFY AT LEAST NODE_NAME AND FILESPACE_NAME these are index fields and prevent a complete table scan of probably the biggest table in a TSM instance.

    Using unix Syntax

    Note Like most of TSM NODE_NAME is uppercase, unlike most of TSM Filespace_name, Hl_name and ll_name are case sensitive.

    select * from backups where node_name='YOURNODENAME' AND filespace_name='/YourFileSystem' and HL_NAME='/Your/path/herE/' and LL_NAME='YourFILEName'

    once you get the details of the object from the field OBJECT_ID (shown below) move to the next step

    NODE_NAME: YOURNODENAME
    FILESPACE_NAME: /YourFileSystem
    FILESPACE_ID: 1
    STATE: ACTIVE_VERSION
    TYPE: FILE
    HL_NAME: /Your/path/herE/
    LL_NAME: YourFILEName
    OBJECT_ID: 201461790
    BACKUP_DATE: 2013-05-23 14:43:27.000000
    DEACTIVATE_DATE:
    OWNER: itsyou
    CLASS_NAME: DEFAULT

    Example: based on above Object ID

    show bfo 0 201461790
    ?Bitfile Object: 0.201461790?**Sub-bitfile 0.511049 is stored in the following
    aggregate(s)
    Super-bitfile: 0.201461483, Offset: 0.1028530, Length 0.13784

    NOTE: This output displays that file represented by this object id (bitfile) is stored in a Super-bitfile: 0.201461483 so we need to do the show bfo again for the Super-bitfile to get the name of the volume:

    show bfo 0 201461483

    Bitfile Object: 0.201461483
    **Archival Bitfile Entry
    Bitfile Type: PRIMARY Storage Format: 9
    Bitfile Size: 0.5504831 Number of Segments: 1
    Storage Pool ID: 10 Volume ID: 409631 Volume Name: A00115L1

    **Archival Bitfile Entry
    Bitfile Type: COPY Storage Format: 9
    Bitfile Size: 0.5504831 Number of Segments: 1
    Storage Pool ID: -2 Volume ID: 409666 Volume Name: A00073L1

    From the above you can determmine the file is located on Primary Tape A00115L1 and Copy Tape A00073L1
     
    Last edited: Jun 12, 2013
  7. seayl

    seayl New Member

    Joined:
    Jun 29, 2007
    Messages:
    1
    Likes Received:
    0
    Very helpful!!!

    Thanks for these select statements!!

    Can you help me with this one, please?

    In v5 I had a very simple select statement that gave me detailed information about my storage pools. It no longer works in v6.3.4. STGPOOL_DETAIL

    SELECT STGPOOL_NAME AS STGPOOL, VOLUME_name AS VOLUME, STATUS, CAST(MEAN(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES

    I did know to change MEAN to AVG, so that works, but now I get this error.

    SELECT STGPOOL_NAME AS STGPOOL, VOLUME_name AS VOLUME, STATUS, CAST(AVG(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES
    ANR0162W Supplemental database diagnostic information: -1:42803:-119 ([IBM][CLI Driver][DB2/AIX64] SQL0119N An expression starting with "STATUS" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified. SQLSTATE=42803
    ).
    ANR0516E SQL processing for statement SELECT STGPOOL_NAME AS STGPOOL , VOLUME_name AS VOLUME , STATUS , CAST ( AVG ( EST_CAPACITY_MB/1024 ) AS DECIMAL ( 5 , 2 ) ) AS GB_PER_VOL FROM VOLUMES failed.

    So, I added the GROUP BY clause (No luck with many iterations unless I leave bits that I need out) and the GROUP BY clause target just seems to keep moving.:confused:

    SELECT STGPOOL_NAME AS STGPOOL, VOLUME_name AS VOLUME, STATUS, CAST(AVG(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME, VOLUME_NAME
    ANR0162W Supplemental database diagnostic information: -1:42803:-119 ([IBM][CLI Driver][DB2/AIX64] SQL0119N An expression starting with "STATUS" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified. SQLSTATE=42803
    ).
    ANR0516E SQL processing for statement SELECT STGPOOL_NAME AS STGPOOL , VOLUME_name AS VOLUME , STATUS , CAST ( AVG ( EST_CAPACITY_MB/1024 ) AS DECIMAL ( 5 , 2 ) ) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME , VOLUME_NAME failed.

    Below are other attempts/results:
    SELECT STGPOOL_NAME AS STGPOOL, VOLUME_name AS VOLUME, STATUS, CAST(AVG(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME,STATUS
    ANR0162W Supplemental database diagnostic information: -1:42803:-119 ([IBM][CLI Driver][DB2/AIX64] SQL0119N An expression starting with "VOLUME_NAME" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified. SQLSTATE=42803
    ).
    ANR0516E SQL processing for statement SELECT STGPOOL_NAME AS STGPOOL , VOLUME_name AS VOLUME , STATUS , CAST ( AVG ( EST_CAPACITY_MB/1024 ) AS DECIMAL ( 5 , 2 ) ) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME , STATUS failed.

    SELECT STGPOOL_NAME AS STGPOOL, VOLUME_name AS VOLUME, STATUS, CAST(AVG(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES GROUP BY VOLUME_NAME,STATUS
    ANR0162W Supplemental database diagnostic information: -1:42803:-119 ([IBM][CLI Driver][DB2/AIX64] SQL0119N An expression starting with "STGPOOL_NAME" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified. SQLSTATE=42803
    ).
    ANR0516E SQL processing for statement SELECT STGPOOL_NAME AS STGPOOL , VOLUME_name AS VOLUME , STATUS , CAST ( AVG ( EST_CAPACITY_MB/1024 ) AS DECIMAL ( 5 , 2 ) ) AS GB_PER_VOL FROM VOLUMES GROUP BY VOLUME_NAME , STATUS failed.

    SELECT STGPOOL_NAME AS STGPOOL, VOLUME_name AS VOLUME, STATUS, CAST(AVG(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME, VOLUME_NAME,STATUS
    ANRW0091E The following command generates a syntax error: " {0} ". See the activity log for more information. To view the activity log, use the Activity Log tab in this server's properties notebook.
    SELECT STGPOOL_NAME AS STGPOOL, VOLUME_name AS VOLUME, STATUS, CAST(AVG(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME, VOLUME_NAME
    ANR0162W Supplemental database diagnostic information: -1:42803:-119 ([IBM][CLI Driver][DB2/AIX64] SQL0119N An expression starting with "STATUS" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified. SQLSTATE=42803
    ).
    ANR0516E SQL processing for statement SELECT STGPOOL_NAME AS STGPOOL , VOLUME_name AS VOLUME , STATUS , CAST ( AVG ( EST_CAPACITY_MB/1024 ) AS DECIMAL ( 5 , 2 ) ) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME , VOLUME_NAME failed.

    SELECT STGPOOL_NAME AS STGPOOL, CAST(AVG(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME
    STGPOOL GB_PER_VOL
    ARCHIVETAPEPOOL 400.00
    DISKPOOL 68.47
    ICS_ARCHIVE_POOL 200.00
    LOCAL2COPYPOOL 331.75
    LOCALCOPYPOOL 192.03
    LOCALTAPEPOOL 339.79
    NT2BKSETCOPYPOOL 317.02
    NTBKSETCOPYPOOL 178.98
    NTLTO2TAPEPOOL 317.44
    NT_BACKUPSET_DISKPOOL 79.98
    OFFSITE2COPYPOOL 340.00
    OFFSITECOPYPOOL 194.18
    ORADISKPOOL 78.98
    ORALTO2COPYPOOL 512.48
    ORALTO2TAPEPOOL 661.17
    TEMPCOPYPOOL 200.00

    SELECT STGPOOL_NAME AS STGPOOL, STATUS, CAST(AVG(EST_CAPACITY_MB/1024) AS DECIMAL(5,2)) AS GB_PER_VOL FROM VOLUMES GROUP BY STGPOOL_NAME,STATUS
    STGPOOL STATUS GB_PER_VOL
    ARCHIVETAPEPOOL FILLING 400.00
    DISKPOOL ONLINE 68.47
    ICS_ARCHIVE_POOL FILLING 200.00
    LOCAL2COPYPOOL FILLING 400.00
    LOCAL2COPYPOOL FULL 334.10
    LOCAL2COPYPOOL PENDING 0.00
    LOCALCOPYPOOL FILLING 200.00
    LOCALCOPYPOOL FULL 190.44
    LOCALTAPEPOOL FILLING 418.59
    LOCALTAPEPOOL FULL 311.79
    LOCALTAPEPOOL PENDING 0.00
    NT2BKSETCOPYPOOL FILLING 400.00
    NT2BKSETCOPYPOOL FULL 321.08
    NT2BKSETCOPYPOOL PENDING 0.00
    NTBKSETCOPYPOOL FILLING 200.00
    NTBKSETCOPYPOOL FULL 157.97
    NTLTO2TAPEPOOL FILLING 400.00
    NTLTO2TAPEPOOL FULL 321.29
    NTLTO2TAPEPOOL PENDING 0.00
    NT_BACKUPSET_DISKPOOL ONLINE 79.98
    OFFSITE2COPYPOOL EMPTY 0.00
    OFFSITE2COPYPOOL FILLING 400.00
    OFFSITE2COPYPOOL FULL 351.36
    OFFSITE2COPYPOOL PENDING 0.00
    OFFSITECOPYPOOL FILLING 200.00
    OFFSITECOPYPOOL FULL 191.76
    ORADISKPOOL ONLINE 78.98
    ORALTO2COPYPOOL FILLING 435.32
    ORALTO2COPYPOOL FULL 530.02
    ORALTO2TAPEPOOL FILLING 441.38
    ORALTO2TAPEPOOL FULL 698.82
    ORALTO2TAPEPOOL PENDING 0.00
    TEMPCOPYPOOL FILLING 200.00
     
    Last edited: May 6, 2014
: db2, reports, select, sql, tsm

Share This Page