SelfRunner

SelfRunnerOdbc

TwoPanelQueryCollection

TwoPanelInlineQueries

TwoPanelTabIndSizeNumRows

TwoPanelTabIndLastAnalyzed

TwoPanelTableDataCompare

CreRunSchemaNumRows

CreRunNumRowsAllDbTab

MakeHtm

MakeHta

GetEnvVars

[Click on the image for a bigger view]

SelfRunner.gif

May not be a

pretty picture.

Run the script, press the button

and

you will know.

Self-Runner - Real-time Oracle-HTM Report.
Batch script to generate a htm page to display real-time Oracle data. Check out the sample output screen view above. Works great on IE8, Slim Browser and Avant browsers.
There was a time I dreamed I could make a one-page htm viewer that would give me real-time Oracle database information.
That dream is not a dream anymore.
It is real.
It is colorful.
And it is push-button easy.
The selfrunner.bat script, as it is written, needs an Oracle user account with DBA privs but it can easily be modified to generate a real-time report of any account if the connect string and the queries are customized.
And all you need is an IE8 browser or an IE clone and a connection to a database.
Let us start with IE8:
Step 1. Assign browser to ALWAYS open the htm file type
Right click on a htm type file, select "open with", then select IE8, and select the "always use the selected program  to open this kind of file" check box.
Step 2. Turn off Tabbed-browsing
Start IE8. Select "Internet Options" from  "Tools" menu. Click on "settings" to the right of "Tabs"  and uncheck the "enable tabbed browsing" check box.
Step 3. Turn on Activex
a)Select "Tools" menu. Select "Internet Options". Select "Custom Level" on the "security" tab and enable options to enable activex.
Step 4. Download the selfrunner.bat script

Step 5. Change the connect string in the c:\selfrunner.bat script

Step 6. Double-Click on the c:\Selfrunner.bat script
Select yes to "Allow blocked content" warning when you run the selfrunner.bat script and IE opens a window with the output.
Step 7. Change the command window size and position
If the command window is too big and comes in your way, you can reduce its size and position it where you want.
-Click on Start menu
-Select Run
-Type Cmd
-Right click on title bar
-Select properties
-Click on layout
-Change size as you wish
-Click on window position
-Change position as you need
-Press Okay
-Choose save position for future windows

Here is the script:

:: =========================================================================================
:: SelfRunner.bat   Real-time Oracle-Htm Report 
:: =========================================================================================
:: Generate and run a self-running sql-htm page from a windows batch file.
:: 1.Tabbed Browsing: Tested on IE. Please turn off tabbed browsing to refresh on same page.
:: 2.Activex Control: Please choose yes to allow blocked content message when IE opens.
::                    Works fine with default IE activex security setting. 
::                    Annoyance: Extra click to allow activex control that runs the script.
:: 3.Command Window : Position the Command Window away from the top left of the page.
::                    Start-Run-Cmd-RightClickOnTitleBar-Properties-WindowPosition-
::                    Left-750;Top-350-PressOkay-Choose SavePositionForFutureWindows...
:: 4.Meta Character Mess-up : Meta characters in echo statements that need to be escaped by
::                            a ^ are, acc to docs, in this list [ & && | || ( ) < > << >> ].
:: ========================================================================================
:: Jerome Christopher. [Jerome_christopher@yahoo.com]
:: http://htmsql.blogspot.com/
:: http://www.sqlhtm.com/sqlhtm/selfrunner
:: ========================================================================================
(
echo set pages 200 
echo set lines 180
echo set feedback off 
echo set termout off  
echo set HEADING OFF
echo --------------------------------------------------------------------------------------
echo alter session set nls^_date^_format^='dd-mon-yyyy hh24:mi:ss';
echo SELECT ^'^<^'^|^|^'style type^=^'^|^|^'^'^'^'^|^|^'text^'^|^|^'^/^'^|^|^'css^'^|^|^'^'^'^'^|^|^'^>^'^|^| chr^(10^)^|^|chr^(13^)^|^|
echo ^'body   {font:7pt Arial^,Helvetica^,sans^-serif; color:black; background:#535300;padding:0px 0px 0px 0px;background-image:url^(^"^"^)}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'p      {font:bold 8pt Arial^,Helvetica,sans^-serif; color:red; background:lightaqua;padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'table  {font:7pt Arial^,Helvetica^,sans-serif; color:Black; background:green; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;vertical^-align:top}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'tr     {font:7pt Arial^,Helvetica^,sans-serif; color:Black; background:; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'td     {font:bold 8pt Arial^,Helvetica^,sans-serif; color:black; background:cyan; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'th     {font:bold 6pt Arial^,Helvetica^,sans-serif; color:yellow; background:darkgreen; padding:0px 0px 0px 0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'h1     {font:bold 15pt Arial^,Helvetica^,Geneva^,sans-serif; color:black; background:silver; }^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'h2     {font:bold 9pt Arial^,Helvetica^,Geneva^,sans-serif; color:black; background:magneta; margin^-top:0px; margin^-bottom:0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'a      {font:bold 8pt Arial^,Helvetica^,sans-serif; color:black; background:darkkhaki;padding:0px 0px 0px 0px; margin^-top:0pt; margin^-bottom:0pt; vertical^-align:top;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'^<^'^|^|^'^/^'^|^|^'style^>^' FROM dual;
echo --------------------------------------------------------------------------------------
echo SET MARKUP HTML ON TABLE ^"^" ENTMAP OFF
echo SET HEADING ON
)>c:\srss.out
:: ======================================================================================

@echo off 
del c:\sr1.tmp c:\sr2.tmp c:\sr3.tmp 
echo spool c:^\SelfRunner.htm                                                >c:\sr1.tmp
echo set termout off                                                         >>c:\sr1.tmp
echo prompt ^<html^>^<head^>                                                 >>c:\sr1.tmp
echo prompt ^<script type^=^"text^/javascript^"^>                            >>c:\sr1.tmp
echo prompt function runApp^(which^)                                         >>c:\sr1.tmp
echo prompt {  WshShell ^= new ActiveXObject^(^"WScript.Shell^"^);           >>c:\sr1.tmp
echo prompt    WshShell.Run ^(which^,1^,false^);                             >>c:\sr1.tmp
echo prompt    var win ^= window.open^(^"c:^/SelfRunner.htm^"^,^"^_self^"^)>>c:\sr1.tmp 
echo prompt    if ^(win^) win.onload ^= runApp                               >>c:\sr1.tmp
echo prompt }                                                                >>c:\sr1.tmp
echo prompt ^<^/script^>                                                     >>c:\sr1.tmp
:: ======================================================================================
type c:\srss.out                                                             >c:\sr2.tmp
copy c:\sr1.tmp+c:\sr2.tmp c:\sr3.tmp                                        >NUL
:: ======================================================================================
echo prompt ^<^/head^>                                                       >>c:\sr3.tmp
echo prompt ^<body^>                                                         >>c:\sr3.tmp
echo prompt ^<table border^=5 title^=SelfRunner-Real-TimeOracleDataRefresh   ^> ^<tr^>^<td valign^=^"top^"^>  >>c:\sr3.tmp
echo select name DbName^,to^_char^(sysdate^,^'dd^-mon^-yy hh:mi:ss pm Dy^'^) Today from v^$database;    >>c:\sr3.tmp
echo prompt ^<INPUT TYPE^=button VALUE^=^"SelfRunner - Press To Refresh - See The Values Change In Real Time !!!^" TITLE^=^"ClickHere^" STYLE^=^"color:yellow; background^-color:darkgreen^" onClick^=^"runApp^(^'file:^/^/c:^/SelfRunner.bat^'^)^"^>    >>c:\sr3.tmp
rem echo prompt ^<^/td^>^<td valign^=^"top^"^>                                                    >>c:\sr3.tmp
echo prompt ^<^/td^>^<^/tr^>^<tr^>^<td valign^=^"top^"^>                                          >>c:\sr3.tmp
echo prompt ^<a^>1.Some sysstat parameters to watch:^<^/a^>                                       >>c:\sr3.tmp
echo select *  from v$sysstat where value^>0 and name in                                          >>c:\sr3.tmp
echo ^(                                                                                           >>c:\sr3.tmp
echo 'recursive calls'                                                                            >>c:\sr3.tmp
echo ,'recursive cpu usage'                                                                       >>c:\sr3.tmp
echo ,'DB time'                                                                                   >>c:\sr3.tmp
:: echo ,'cluster wait time'                                                                      >>c:\sr3.tmp
:: echo ,'sorts ^(rows^)'                                                                         >>c:\sr3.tmp
echo ,'sorts ^(memory^)'                                                                          >>c:\sr3.tmp
echo ,'sorts ^(disk^)'                                                                            >>c:\sr3.tmp
echo ,'physical reads'                                                                            >>c:\sr3.tmp
echo ,'redo size'                                                                                 >>c:\sr3.tmp
echo ,'redo wastage'                                                                              >>c:\sr3.tmp
echo ,'table scans ^(short tables^)'                                                              >>c:\sr3.tmp
echo ,'table scans ^(long tables^)'                                                               >>c:\sr3.tmp
echo ,'table fetch continued row'                                                                 >>c:\sr3.tmp
echo ,'user I^/O wait time'                                                                       >>c:\sr3.tmp
echo ^)                                                                                           >>c:\sr3.tmp
echo order by name ;                                                                              >>c:\sr3.tmp
rem echo prompt ^<^/td^>^<table^>^<tr^>^<td valign^=^"top^"^>                                     >>c:\sr3.tmp
echo prompt ^<^/td^><td valign^=^"top^"^>                                                         >>c:\sr3.tmp
echo prompt ^<a^>2.Top 4 users - ordered by seconds_in_wait:^<^/a^>                               >>c:\sr3.tmp
echo select * from ^(select sid,serial#,username,status,program,type,user,module,logon^_time,wait^_time,seconds^_in^_wait from v$session where type^<^>'BACKGROUND' order by seconds^_in^_wait desc^) where rownum^<5;        >>c:\sr3.tmp
echo prompt ^<^/td^><td valign^=^"top^"^>                                                         >>c:\sr3.tmp
echo prompt ^<a^>3.Top 4 Filestat info - ordered by physical reads:^<^/a^>                        >>c:\sr3.tmp
echo select * from ^(select * from v$filestat order by phyrds desc ^) where rownum ^< 5;          >>c:\sr3.tmp
rem echo prompt ^<^/td^>^<^/tr^>^<^/table^>^<hr^>                                                 >>c:\sr3.tmp
echo prompt ^<^/td^><td valign^=^"top^"^>                                                         >>c:\sr3.tmp
echo prompt ^<a^>4.Top 4 waits from system_event - ordered by time_waited: ^<^/a^>                >>c:\sr3.tmp
echo select * from ^(select * from  v$system_event order by time_waited desc^) where rownum ^< 5; >>c:\sr3.tmp
echo prompt ^<^/td^>^<^/tr^>^<^/table^>                                                           >>c:\sr3.tmp
echo spool off                                                                                    >>c:\sr3.tmp
echo exit                                                                                         >>c:\sr3.tmp
sqlplus -s "dbuser/password@db" "@c:\sr3.tmp"                                                       >>c:\sr3.tmp
echo ^<^/body^>^<^/html^>                                                                         >>c:\SelfRunner.htm  
:: ======================================================================================

start "C:\Program Files\Internet Explorer\iexplore.exe" c:\SelfRunner.htm
exit

   

Home

Scripts

Tips

Misc

Resume

Tamil

JobSearch

www.sqlhtm.com   Copyright. Jerome S. Christopher 2010