Using TSM Macros, Scripts and
SQL
(Implementation and Practical Use)
Laura Buckley
Automating Daily Tasks
Macros
Automate simple repetitive server operations
TSM SQL interface
Provides access to more database information than
QUERY
TSM server scripts
Provide a more robust method for automating
repetitive server operations
Creating Macros
Enter the administrative commands in a text file
- A hyphen or slash continues a line
- Blank lines are ignored
- 256 characters per line without continuation
- 1500 characters with continuation
Substitution variables are allowed
Substitution variables are represented by a % and a
number (i.e. %1, %2)
Comments are preceded and followed by /*
and */
Sample Macro
/*
/*
/*
/*
e x t e n d d b .m a c */
This macro will add a volume to and extend the - */
TSM server database. */
The variables are : %1 = new volume name */
/ * %2 = new volume size */
define dbvol % 1 formatsize=%2 wait=yes
extend db %2
Executing Macros
At the Admin Command Line
macro filename variable
tsm > macro extendb
extendb..mac f:\db3.
f:\db3.dsm
dsm 2000
In batch mode, at the OS prompt
dsmadmc id=admin password=pwd
password=pwd macro
filename variables
dsmadmc id=
id=laura
laura password=snail macro
extenddb..mac f:\db3.
extenddb
f:\db3.dsm
dsm 2000
Commit and Rollback
COMMIT command controls when items
are committed to the db
If an error while processing a macro, the
server rolls back uncommitted changes
Run admin client (dsmadmc
(dsmadmc)) with
ITEMCOMMIT option to commit all changes
Use ROLLBACK as last command to test
macro (with no COMMITs
COMMITs))
Using the TSM SQL Interface
Three system catalog tables
SYSCAT.TABLES = tables that are available
for queries
SYSCAT.COLUMNS = columns that reside in
each table
SYSCAT.ENUM = legal values for
enumerated data types and orders of types
Displaying the System
Catalogs
TSM> select tabschema
tabschema,, tabname
tabname,,
unique_index from syscat
syscat_tables
_tables
TSM>select tabname
tabname,, colname
colname,, typename
from syscat
syscat.columns
.columns
TSM>select typename
typename,, values from
syscat..enumtypes
syscat
Using the TSM SQL Interface
Basic SQL Select structure
SELECT field FROM column
i.e SELECT NODE FROM SESSIONS
Use WHERE clause to specify only
specific criteria to be met
select node_name from nodes where
locked='YES'
Configuring and Using the
ODBC Driver
Works with WinX Operating Systems
Use a spreadsheet or database app to access
information
Select ODBC driver during setup
Update or copy the default TSM ODBC Data Source
Select Data source administrator from control panel
Click once on TSM ODBC Sample User DSN
Click on Configure button
Change name of DSN to the name of the TSM Server
Change server address to your TSM Server IP address
Click OK
Using the ODBC Driver with
MS Query and MS Excel
Open an MS Excel Window
Pull down the Data menu
Select Get external data
Select the TSM Server data source you created or
modified earlier
Click OK
Enter a TSM Administrator/Password combination
The Query Wizard will now be open
Select the tables you want to query
Creating TSM Server Scripts
TSM Server scipts are stored in the TSM
Server database (not text files)
Can be processed interactively or in
batch
Good examples are in the scripts.smp
scripts.smp file
(older versions of TSM)
Creating TSM Server Scripts
Continued
TSM Scripts can include:
Command parameter substitution
SQL SELECT statements
Conditional logical flow statements using the IF
clause and return code values
The EXIT statement to end processing
The GOTO statement to direct logic flow to continue
with the line starting with the specified
Comment lines
Defining and Executing Server
Scripts CLI and File
TSM>define script q_admin_owner select
schedule_name,chg_admin from
admin_schedules description=Display Admin
schedule current owners
TSM>updated script q_admin_owner q event * *
type=admin
Or From a File
TSM>define script q_admin_owner ile
ile=
= qadmin
qadmin.txt
.txt
Defining a Server Script Using
the Web Interface
Expand Object View and Automation
Click Server Command Scripts
Pull Down Operation Define a new command
script
Enter the Script Name
Enter a description
Enter the command lines for the script
Substitution & Logic Flow in
Scripts
Substitution Variables
Represented with $ followed by number
Select $1 from nodes where platform_name=$2
Logic Flow Statements
Test for return code values (rc
(rc_ok,
_ok, warning, error)
See other return code values in Appendix C of
Administrators Reference
Example Script (from
scripts. smp)
'/* ---------------------------------------------*/'
'/* Script Name: Q_NO_ASSOC
*/'
'/* Description: Display nodes in a policy
*/'
'/*
domain that are not associated */'
'/*
with a specific schedule.
*/'
'/* Parameter 1: domain name
*/'
'/* Parameter 2: schedule name
*/'
'/* Example:
run q_no_assoc POLICY SCHEDULE */'
'/* ---------------------------------------------*/'
"select node_name from nodes where -"
" domain_name=upper('$1') and node_name not in -"
" (select node_name from associations where -"
" domain_name=upper('$1') and -"
" schedule_name=upper('$2')) "
Getting Started
Be sure to check out scripts.smp
scripts.smp (server
directory in older versions)
Ask for help from the listserv
Check SQL reference materials
Dig in!