340 likes | 476 Views
Creating and Printing Ad-Hoc Queries from the Tivoli Desktop. Martin Jones DFAS-ISO/Infrastructure Engineering. Our Environment. Hub TMR: 1 (Solaris). Spoke TMRs: 6 (Solaris). Gateways: 40 (NT). Inventory Databases: 1 (Oracle) Total workstations: 18,989 Tivoli Desktops: ~100. DFAS.
E N D
Creating and Printing Ad-Hoc Queries from the Tivoli Desktop Martin Jones DFAS-ISO/Infrastructure Engineering
Our Environment • Hub TMR: 1 (Solaris). • Spoke TMRs: 6 (Solaris). • Gateways: 40 (NT). • Inventory Databases: 1 (Oracle) • Total workstations: 18,989 • Tivoli Desktops: ~100
DFAS TMRs DFAS Infrastructure Database FSO CL CO DE IN KC ISO CL(3) CO(3) DE(3) IN(4) KC(1) OMD DCH DDY DGK EPET DJP DLI DLW HQ DNF DOM DLX Gateways FPE DOK DSA DOR SPR DPC DSB DRI DPE DRO DSD DSL DSS
How We Started • Focus on Inventory. • Periodic scans collect hardware and software (.exe only). • Standard queries created based on user requests. • Users access Inventory data via Tivoli desktop. • Users are not allowed to edit queries.
In the Beginning... • Users were given Tivoli desktops with standard queries already defined. • Users wanted to use the Inventory query output in reports. • The Tivoli desktop does NOT provide a way to view Inventory query output.
The First Solution • Allow the standard queries to be run as jobs. • Let the users run these jobs. • Produce output in a semicolon delimited format that can be copied to a spreadsheet.
Run a Query from a Perl Script #!/etc/Tivoli/bin/perl # This script takes a query name as input and runs it. # Read input $query=@ARGV[0]; chop($query); # Source the Tivoli Environment grep(do{chop;s/(.*)=(.*)/$ENV{$1}=$2/e;},`. /etc/Tivoli/setup_env.sh;env`); @Results=`wrunquery -d ";" "$query"`; print @Results;
Wrap the Perl Script into a Task TaskLibrary "FSO_Inventory_Tasks" { Distribute = "ALI"; Version = "1.0"; Requires = ">2.5"; Context = "*"; HelpMessage = "Inventory queries delimited with semicolons."; ArgLayout Query { Choice Program { Implementation ("default") .#/bin/sh .wlookup -Lar Query | grep fso-qry .exit 0 ; }; }; Task FSO_Inventory_Query { Description = "Displays inventory queries in semicolon delimited format."; HelpMessage = "Cut and paste output into Excel spreadsheet."; Roles = "user"; Uid = "$root_user"; Gid = "tivoli"; Argument ("_!_", "Query to run", 1) { Layout = "Query"; }; Implementation ("default") Binary "/var/spool/Tivoli/tasks/INVENTORY/db-query.pl"; }; }
Create Task Library, Task, and Job #!/bin/sh # the user will need the following rights to run this job # global user,Query_execute,RIM_view # fso-tmr-inventory-region Query_edit ALI_OID=`wlookup ServerManagedNode` eval SERVER=`idlcall $ALI_OID _get_label` POLICYREGION="fso-library-region" TL="FSO_Inventory_Tasks" wlookup -r PolicyRegion "$POLICYREGION" > /dev/null 2>&1 if [ $? != 0 ] then echo "The policy region $POLICYREGION does not exist" exit 1 fi echo "Creating TaskLibrary..." wtll -rp "$POLICYREGION" -P /usr/ccs/lib/cpp $TL.tll echo "Creating FSO_Inventory_Query_Job..." wcrtjob -j FSO_Inventory_Query_Job -l $TL -t FSO_Inventory_Query -M serial -m 600 -o 15 -D -h @ManagedNode:$SERVER exit 0
User Rights Required $ wgetadmin lmtduser@fso-ms-w-tmn1 Administrator: Limited User on fso-ms-w-tmn1 logins: lmtduser@fso-ms-w-tmn1 roles: security_group_any_admin user Limited User on fso-ms-w-tmn1 admin, user, rconnect global user, Query_execute, RIM_view notice groups:
The Next Opportunity... • Our security community requested scans for .jpg, .gif, .mov, and .mpg files.
Next Opportunity Issues • They do not have standard files to search for (ie. anna.jpg or winproj.exe), so no standard queries.
Run the Query from the Perl Script #!/etc/Tivoli/bin/perl if ($#ARGV == -1) { print "Search string required for processing.\n"; exit 1; } ($Name) = @ARGV; $Site = "FSC"; $Name =~ tr/a-z/A-Z/; $output1 = `wsetquery -w \"(TME_OBJECT_LABEL like '%"$Site"%' and FULL_FILE_NAME like '%$Name%')\" qry-fso-adhoc 2>&1`; if (!$?) { $output2 = `wrunquery -d \";\" qry-fso-adhoc 2>&1`; if (!$?) { print "$output2\n"; }else{ print "Error with query output : $?\n"; } }else{ print "Error with set query : $?\n"; }
TaskLibrary "FSO_Inventory_Tasks" { Distribute = "ALI"; Version = "1.0"; Requires = ">2.5"; Context = "*"; HelpMessage = "Inventory queries delimited with semicolons."; ArgLayout Query { Choice Program { Implementation ("default") .#/bin/sh .wlookup -Lar Query | grep fso-qry .exit 0 ; }; }; ArgLayout TextField { Text; }; Task FSO_Inventory_Query { Description = "Displays inventory queries in semicolon delimited format."; HelpMessage = "Cut and paste output into Excel spreadsheet."; Roles = "user"; Uid = "$root_user"; Gid = "tivoli"; Argument ("_!_", "Query to run", 1) { Layout = "Query"; }; Implementation ("default") Binary "/var/spool/Tivoli/tasks/INVENTORY/db-query.pl"; }; Task FSO_AdHoc_Query { Description = "Queries all software for FSO workstations."; HelpMessage = "Cut and paste output into Excel spreadsheet. Semicolon delimited."; Roles = "user"; Uid = "$root_user"; Gid = "tivoli"; Argument ("_!_", "String to search for:", 1) { Layout = "TextField"; }; Implementation ("default") Binary "/var/spool/Tivoli/tasks/INVENTORY/fso-qry-adhoc.pl"; }; } Wrap the Perl Script into a Task
User Rights Required $ wgetadmin lmtduser@fso-ms-w-tmn1 Administrator: Limited User on fso-ms-w-tmn1 logins: lmtduser@fso-ms-w-tmn1 roles: security_group_any_admin user Limited User on fso-ms-w-tmn1 admin, user, rconnect global user, Query_execute, RIM_view fso-tmr-inventory-region Query_edit notice groups:
What About the DB View INSTALLED_FILE_VIEW select C.TME_OBJECT_ID, C.TME_OBJECT_LABEL, I.* from INSTALLED_UNKNOWN_FILE I, COMPUTER_SYSTEM C where I.HARDWARE_SYSTEM_ID = (select HARDWARE_SYSTEM_ID from COMPUTER_SYSTEM where TME_OBJECT_LABEL = C.TME_OBJECT_LABEL)
Creating the Jobs from CLI #!/bin/sh # the user will need the following rights to run this job # global user,Query_execute,RIM_view # fso-tmr-inventory-region Query_edit ALI_OID=`wlookup ServerManagedNode` eval SERVER=`idlcall $ALI_OID _get_label` POLICYREGION="fso-library-region" TL="FSO_Inventory_Tasks" wlookup -r PolicyRegion "$POLICYREGION" > /dev/null 2>&1 if [ $? != 0 ] then echo "The policy region $POLICYREGION does not exist" exit 1 fi echo "Creating TaskLibrary..." wtll -rp "$POLICYREGION" -P /usr/ccs/lib/cpp $TL.tll echo "Creating FSO_Inventory_Query_Job..." wcrtjob -j FSO_Inventory_Query_Job -l $TL -t FSO_Inventory_Query -M serial -m 600 -o 15 -D -h @ManagedNode:$SERVER echo "Creating FSO_AdHoc_Query_Job..." wcrtjob -j FSO_AdHoc_Query_Job -l $TL -t FSO_AdHoc_Query -M serial -m 1200 -o 15 -D -h @ManagedNode:$SERVER exit 0
Issues and Concerns • This solution does not address all reporting needs. • Spreadsheet row limit ~ 65,500. • We have 13,524,855 .exe files (710 per workstation). • We have 3,657,066 .jpg files (191 per workstation). • We have 17,047,029 .gif files (894 per workstation ). • All queries flow through 1 RIM per TMR. • WAN affects query time. • Jobs may time-out before query returns.
Next Steps • Eliminate the RIM interface by using SQL*Plus. • Target specific directories during the software scans. • Reduce the query output by filtering on the endpoint’s label.
Summary • Small investment in time results in big user benefits. • Perl scripts and the Tivoli Task Library Language can be used to make standard queries printable. • Further Perl scripting can be used to modify a ‘where’ clause and give the illusion of an Ad-Hoc query that is printable.
References • Tivoli Task Library Language Developer’s Guide - Version 3.6.1, https://www.tivoli.com/secure/support/Prodman/html/framework.html • Advanced Task Management by Simon Barnes, OrbData, http://www.orb-data.co.uk/technical-layout.html