Presentation is loading. Please wait.

Presentation is loading. Please wait.

NTAUG Introduction in to use of SQL - Part 3 Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,

Similar presentations


Presentation on theme: "NTAUG Introduction in to use of SQL - Part 3 Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,"— Presentation transcript:

1 NTAUG Introduction in to use of SQL - Part 3 Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,

2 SQL Mutliple SQL qurries Mutliple SQL qurries Within a shell script Within a shell script Producing a report Producing a report Formatting the output Formatting the output

3 An Example shell script The script does a number of SQL qurries to build the information The script uses SQL to extract information in to temp files The script builds the information extracted to create a report

4 An Example shell script The script does a number of SQL qurries to build the information Defined as variables Each variable is then referenced as the report is built The script uses SQL to extract information in to temp files The script builds the information extracted, to create a report The script uses printf to format the output to the report file

5 An Example shell script The script does a number of SQL qurries to build the information Defined as variables: RUNNING=`xql -U${U} -P${P} -c "select count(*) JobRuns from job_runs where startime>${AUTOFROM} and startime<${AUTOTO} and status = 1"`

6 An Example shell script The script does a number of SQL qurries to build the information Defined as variables Each variable is then referenced as the report is built: printf "%-32s%6s%-15s%.2f\n" " Jobs Running:" ${RUNNING} " " ${PCRUNNING} >>${OUTPUT}

7 An Example shell script The script does a number of SQL qurries to build the information Defined as variables Each variable is then referenced as the report is built The script uses SQL to extract information in to temp files: xql -U${U} -P${P} -I -d'' -c "select job.job_name,job.machine from job, job_runs where job_runs.joid=job.joid and job_runs.startime>${AUTOFROM} and job_runs.startime ${TMPFILE1}

8 An Example shell script The script does a number of SQL qurries to build the information Defined as variables Each variable is then referenced as the report is built The script uses SQL to extract information in to temp files The script builds the information extracted, to create a report: for i in `xql -U${U} -P${P} -I -c "select job.job_name,job_runs.endtime from job, job_runs where job_runs.joid=job.joid and job_runs.startime>${AUTOFROM} and job_runs.startime<${AUTOTO} and job_runs.status=5 order by job.job_name" | awk -F"\|" '{print $2}'` do echo `time0 -A ${i} | awk -F"e:" '{print "\t", $2}'` >>${TMPFILE2} done

9 An Example shell script The script does a number of SQL qurries to build the information Defined as variables Each variable is then referenced as the report is built The script uses SQL to extract information in to temp files The script builds the information extracted, to create a report The script uses printf to format the output to the report file: log_msg "Putting Report Together" echo "\n${BOLD}Jobs Statistics Report for ${DAY} On ${INST} - (`hostname`)${OFF}" >>${OUTPUT} echo "---------------------------------------------------------------\n" >>${OUTPUT} printf "%40s%20s\n" "# of Jobs" "% of Total" >>${OUTPUT} printf "%-32s%6s%-15s%.2f\n" " Jobs Running:" ${RUNNING} " " ${PCRUNNING} >>${OUTPUT}

10 Final Report (partial): Jobs Statistics Report for 09122004 On DC1 - (tmrutdc1pr) --------------------------------------------------------------- # of Jobs % of Total # of Jobs % of Total Jobs Running: 2 0.05 Jobs Running: 2 0.05 Jobs in Starting State: 0 0.00 Jobs in Starting State: 0 0.00 Jobs in Success State: 3703 97.32 Jobs in Success State: 3703 97.32 Jobs in Failure State: 43 1.13 Jobs in Failure State: 43 1.13 Jobs Terminated: 57 1.50 Jobs Terminated: 57 1.50 Jobs On Ice: 0 0.00 Jobs On Ice: 0 0.00 Jobs in Inactive State: 0 0.00 Jobs in Inactive State: 0 0.00 Jobs in Activated State: 0 0.00 Jobs in Activated State: 0 0.00 Jobs in Restart State: 0 0.00 Jobs in Restart State: 0 0.00 Jobs On Hold: 0 0.00 Jobs On Hold: 0 0.00 Jobs in Que Wait State: 0 0.00 Jobs in Que Wait State: 0 0.00 Total Jobs: 3805 Total Jobs: 3805 Sumaary for OPERATIONS Daily Report Sumaary for OPERATIONS Daily Report+-----------------------------------------------------------------------+ | # Scheduled | # Successful | # Active | |-----------------------------------------------------------------------| | 3805 | 3703 | 2 | +-----------------------------------------------------------------------+ Jobs that Failed Ser Job Name Machine Date Time ------------------------------------------------------------------------------------------- 1 DCastAP_arch_cai_C astutdc1 09/12/2004 00:05:05 2 DCcowDB_COW2_cold_C aixdbdc1 09/12/2004 03:00:55 3 DCcowDB_COW2_exp_C aixdbdc1 09/12/2004 22:46:37 4 DCcowDB_COWD_cold_C aixdbdc1 09/12/2004 01:00:53 5 DCcowDB_COWD_exp_C aixdbdc1 09/12/2004 22:01:43 6 DCidfDB_dbcc_fragment_C idfdbdc1 09/12/2004 12:46:16 7 DCidfDB_sys_data_bcp_C idfdbdc1 09/12/2004 12:31:19 8 DCidfDB_sys_data_bcp_C idfdbdc1 09/12/2004 12:31:54

11 Fancying Up the Report Many untilities on UNIX to do this with Many untilities on UNIX to do this with

12 Fancying Up the Report Many untilities on UNIX to do this with Many untilities on UNIX to do this with Look at just two Look at just two enscript enscript ps2pdf ps2pdf

13 Fancying Up the Report ENSCRIPT ENSCRIPT Commonally available untility Commonally available untility

14 Fancying Up the Report ENSCRIPT ENSCRIPT Commonally available untility Commonally available untility Converts ASCII text to Postscript Converts ASCII text to Postscript

15 Fancying Up the Report ENSCRIPT ENSCRIPT Commonally available untility Commonally available untility Converts ASCII text to Postscript Converts ASCII text to Postscript Formats the output in the process Formats the output in the process

16 Fancying Up the Report ENSCRIPT ENSCRIPT Commonally available untility Commonally available untility Converts ASCII text to Postscript Converts ASCII text to Postscript Formats the output in the process Formats the output in the process For Eaxmple: For Eaxmple: Can put a board around page Can put a board around page Format the number of columns Format the number of columns Put on headers and footers Put on headers and footers And much, very much more And much, very much more

17 enscript enscript -1 -R -j -G -M Legal -u"Sample" - -margins=10:10 -p 09122004_DC1.rpt.ps 09122004_DC1.rpt enscript -1 -R -j -G -M Legal -u"Sample" - -margins=10:10 -p 09122004_DC1.rpt.ps 09122004_DC1.rpt

18 enscript man enscript | enscript -1 -R -j -G -M Legal -u"enscript" -p enscript.ps man enscript | enscript -1 -R -j -G -M Legal -u"enscript" -p enscript.ps

19 ps2pdf Converts Postscript to PDF Converts Postscript to PDF

20 ps2pdf E.g will convert the output from enscript to PDF format that could then be viewed using Adobe Reader E.g will convert the output from enscript to PDF format that could then be viewed using Adobe Reader

21 ps2pdf Converts Postscript to PDF Converts Postscript to PDF E.g will convert the output from enscript to PDF format that could then be viewed using Adobe Reader E.g will convert the output from enscript to PDF format that could then be viewed using Adobe Reader ps2pdf 09122004_DC1.rpt.ps 09122004_DC1.rpt.pdf ps2pdf 09122004_DC1.rpt.ps 09122004_DC1.rpt.pdf


Download ppt "NTAUG Introduction in to use of SQL - Part 3 Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,"

Similar presentations


Ads by Google