UTABLE LNTBL 300 LVTBL 2500 O MONDATA * Sirius Software / Janus Web demonstration program * This routine uses data collected by the SirMon background monitor to present * web-based reports in a variety of formats. Users may select from the * available sample sets, requesting reports in html, xls or graphical format. * The xls output is in a special version of XML, supported by Microsoft Excel * as a native spreadsheet format. The graphical presentation is in VML, which * is only supported by Internet Explorer 5.5 and above. * Note that this code is in mixed-case, which is made possible via the Sirius * mods, when the "BEGIN" statement is specified in mixed or lower-case. Begin %action Is String Len 10 %cr Is String Len 2 %interval Is String Len 20 %html Is String Len 255 %junk Is String Len 20 dp 0 %name Is String Len 32 %sample Is String Len 20 %stat is String Len 12 array(100) %start Is String Len 20 %tab Is String Len 2 %values Is String Len 20 %headstyle Is LongString %output Is LongString %u Is Float %q Is Float %x Is Float %y Is Float %z is Float Call $web_flush Call $web_expire($web_date - 1) Call $web_response('pragma', 'no-cache') Call $web_type('text/html') %html = '' %action = $upcase($Web_Parm('a')) %sample = $Web_Parm('s') %tab = $x2c('05') %cr = $x2c('25') If %action eq 'V' then Call ViewSample ElseIf %action eq 'XLS' Then Call ExcelExtract ElseIf %action eq 'XML' Then Call XMLExtract ElseIf %action eq 'G' Then if $Web_Parm('GO') eq 'Graph' then Call GraphIt else Call StatTable end if ElseIf %action eq 'D' Then Call DeleteSample Else Call ListSample End If Stop * End Mainline * * ------------------ * * Begin Subroutines * * ------------------------------------------------------------ * * List the samples currently in the database * ------------------------------------------------------------ * ListSample: Subroutine Call Header Html

 

End Html fdc: in file MONDATA fdwol TYPE = H frc: fr fdc ndd: note SAMPLE ndi: note INTERVAL fdd: in file MONDATA fdwol TYPE = S and SAMPLE = value in ndd ctc: count records in fdd HtmL * NB: 3/4 of these links are commented out because they're too * resource-intensive for us to risk users pounding on our system with them. End Html End For Html
Performance samples available in {$VIEW('JOBNM')}
Extract Analyze Maintain Sample Details
Excel XML Graphs Delete {$Sir_Ns2Date(SAMPLE,'MM/DD/YY HH:MI:SS')} @ {value in ndi} Secs. / ({count in ctc} records in set)

SirMon Capture Features

This page is a demonstration of how the historical data, captured by SirMon can be displayed and manipulated.

The graphs in this demo are generated using Vector Markup Language (VML), which is supported by Microsoft Internet Explorer, verion 5.5 and later. VML allows very precise line drawing and is an excellent, lightweight approach to client-side graphing, for shops that have standardized on IE.

To see the graphs, click on the "Graph" link for a particular SirMon sample, then select the statistics you'd like to see graphed.

The code for downloading the data into Excel and XML, and the code for deleting entries, has been disabled in this demo version. You can easily re-enable these features in the downloadable version.

SirMon stores the captured data in file MONDATA -- an optional file in version 6.2 and later (6.5 and later of the Sirius Mods). The command that initiates the capture is

SIRMON CAPTURE xxxx yyyy

Where xxxx is the number of seconds between sampling intervals, and yyyy is the number of intervals to capture. For instance,

SIRMON CAPTURE 120 300

Would capture a sample every 2 minutes (120 seconds) for 10 hours.

Note that the SIRMON CAPTURE command runs in the thread that executes it, so if it's run on a terminal it will lock up the terminal. The suggested method of running the CAPTURE utility is to submit it to a background sdaemon like this:

Begin %s is float %s = $ListNew Call $ListAdd( %s, 'SIRMON CAPTURE 60 600') Call $CommBG(%s) Call $ListDel(%s) End

Each captured sample saves the stats displayed on the SirMon System Overview Screen (SIRMON 1).

Each sample set is saved with a header record that shows the sample initiation time.

End Html Call Footer End Subroutine ListSample * ------------------------------------------------------------ * * Provide a detailed view of a particular sample, allowing * the user to select which fields they'd like displayed. * ------------------------------------------------------------ * ViewSample: Subroutine Call Header Html

 

End Html %x = 1 fdr: in file MONDATA fdwol TYPE = H and SAMPLE = %sample frr: fr fdr feor: feo STAT %y = occurrence in feor if %x eq 1 then print '' end if Html End Html if %x eq 4 then print '' %x = 1 else %x = %x + 1 end if end for end for Html
{$view('JOBNM')} Beginning: {$Sir_Ns2Date(%sample,'MM/DD/YY HH:MI:SS')} Performance stats available in this sample
Select stats to display
 {STAT(%y)}
Graph Settings: Type: {$WEB_SELS(' 200 250 300 350 400 450 500 550 600 650', ,'350')} Width: {$WEB_SELS(' red blue sage yellow darkgrey green lightgrey mediumgrey orange palegrey pink purple teal violet white black clear', ,'red')}
End Html Call Footer End Subroutine ViewSample * ------------------------------------------------------------ * * Extract a sample to tab-delimited .xls format (note that this * routine won't work for IE under an SSL connection because of * a Microsoft bug). * ------------------------------------------------------------ * ExcelExtract: Subroutine Call $web_flush Call $web_type('application/octet-stream') Call $web_response('Content-Disposition', 'attachment; filename=dataextract.xls') fds: in MONDATA fd TYPE = 'H' and SAMPLE = %sample frs: fr fds feoh: feo STAT %output = %output with %tab with STAT(occurrence in feoh) end for %output = %output with %cr print %output end for fdx: in MONDATA fd TYPE = 'S' and SAMPLE = %sample frx: fr fdx %output = '' feos: feo STAT %output = %output with %tab with STAT (occurrence in feos) end for %output = %output with %cr print %output end for stop End Subroutine ExcelExtract * ------------------------------------------------------------ * * Extract a sample to XML format. * ------------------------------------------------------------ * XMLExtract: Subroutine %doc is object xmlDoc %table is object xmlNode %workbook is object xmlNode %worksheet is object xmlNode %documentProperties is object xmlNode %column is object xmlNode %row is object xmlNode %cell is object xmlNode %data is object xmlNode %price is string len 32 %units is string len 32 %total is string len 32 dp 2 %time is float %timeString is string len 32 %version is string len 10 initial('1.0') %time = $web_date %timeString = $sir_ns2date(%time, 'YYYY-MM-DD') with 'T' with - $sir_ns2date(%time, 'HH:MI:SS') with 'Z' Call $web_flush * Collect the state names, start time & interval from header rec. %z = 0 fdcs: in MONDATA fd SAMPLE = %sample ctcs: count records in fdcs release records in fdcs fdy: in MONDATA fd TYPE = 'H' and SAMPLE = %sample fry: fr fdy %start = SAMPLE %interval = INTERVAL %z = 0 feoy: feo STAT %z = %z + 1 %stat(%z) = STAT(%z) end for end for %doc = new %workbook = %doc:addElement('Workbook', , - 'urn:schemas-microsoft-com:office:spreadsheet') %workbook:addNamespace('o', 'urn:schemas-microsoft-com:office:office') %workbook:addNamespace('x', 'urn:schemas-microsoft-com:office:excel') %workbook:addNamespace('ss', - 'urn:schemas-microsoft-com:office:spreadsheet') %documentProperties = %workbook:addElement('DocumentProperties', , - 'urn:schemas-microsoft-com:office:office') %documentProperties:addElement('Author', 'Model 204') %documentProperties:addElement('LastAuthor', 'Model 204') %documentProperties:addElement('LastAuthor', 'Model 204') %documentProperties:addElement('LastPrinted', %timeString) %documentProperties:addElement('Created', %timeString) %documentProperties:addElement('LastSaved', %timeString) %documentProperties:addElement('Version', %version) %worksheet = %workbook:addElement('Worksheet') %worksheet:addAttribute('ss:Name', $VIEW('JOBNM') with ' ' with %start - with ' interval: ' with %interval) %table = %worksheet:addElement('Table') %table:addAttribute('ss:ExpandedColumnCount', %z) %table:addAttribute('ss:ExpandedRowCount', count in ctcs) * Define columns. for %q from 1 to %z %column = %table:addElement('Column') %column:addAttribute('ss:index', %q) %column:addAttribute('ss:AutoFitWidth', 1) * %column:addAttribute('ss:Width', 110) end for * Add a header row. %row = %table:addElement('Row') for %q from 1 to %z %cell = %row:addElement('Cell') %cell:addAttribute('ss:index', %q) %data = %cell:addElement('Data', %stat(%q)) %data:addAttribute('ss:Type', 'String') end for * Add a row of info for each stat record. fdz: in MONDATA fd TYPE = 'S' and SAMPLE = %sample frz: fr fdz %row = %table:addElement('Row') %q = 0 feoz: feo STAT %q = %q + 1 %cell = %row:addElement('Cell') %cell:addAttribute('ss:index', 1) %data = %cell:addElement('Data', STAT(%q)) %data:addAttribute('ss:Type', 'String') end for end for Call $web_type('application/ms-excel') Call $web_response('Content-Disposition', 'attachment; filename=dataextract.xml') %doc:version = '1.0' %doc:webSend stop End Subroutine XMLExtract * ------------------------------------------------------------ * * Create a Line Graph of the selected data using VML * ------------------------------------------------------------ * GraphIt: Subroutine * Variables for coordinate space sizing. %csVS is Fixed dp 0 %csHS is Fixed dp 0 %csWidth is Fixed dp 0 %csHeight is Fixed dp 0 %rectWidth is Fixed dp 0 %rectHeight is Fixed dp 0 * line-start and line-end vars for drawing the graph. %lsX is Fixed dp 0 %lsY is Fixed dp 0 %leX is Fixed dp 0 %leY is Fixed dp 0 * variables to hold high and low vals for each chart. %max is Float %min is Float * Misc. graph settings. %graphType is String len 10 %lineColor is String len 12 %csVS = 0 %csHS = 0 * For the moment, the coordinate space and the actual drawing space * rectangle are being set to the same size. %csWidth = $Web_Parm('width') %csHeight = $Web_Parm('height') %rectWidth = $Web_Parm('width') %rectHeight = $Web_Parm('height') %graphType = $Web_Parm('graphtype') %lineColor = $Web_Parm('linecolor') %html = '' %headstyle = '' Call Header Html Data

 

* Loop through all the "stat" checkboxes and build a graph for each * one a user has selected. For %z from 1 to $Web_Num_Form('stat') If $len($Web_Parm('stat',%z)) then %name = $Web_Parm('stat',%z) * Post a bit of header info off the header record. fdfd: in MONDATA fd TYPE = 'H' and SAMPLE = %sample frfd: fr fdfd %interval = INTERVAL %start = SAMPLE * It's possible (depending on the browser) that the occurrence number * of the stat on the form won't match the occurrence of the stat on the record. * So, off we go to the record again to determine the right occurrence number. feofdfd: feo STAT if STAT(occurrence in feofdfd) eq %name then %y = occurrence in feofdfd end if end for Html End Html End For * Get the actual data. fdfx: in MONDATA fd TYPE = 'S' and SAMPLE = %sample ctofdfx: count records in fdfx %q = count in ctofdfx * Start the graph by building a box. Html End Html End If End For Html Data
{%name} on {$view('JOBNM')} From: {$Sir_Ns2Date(%start,'MM/DD/YY HH:MI:SS')} To: {$Sir_Ns2Date(%start+(%interval * %q),'MM/DD/YY HH:MI:SS')} at {INTERVAL} second intervals
{$Sir_Ns2Date(%start,'MM/DD/YY HH:MI:SS')}
{$Sir_Ns2Date(%start+(%interval * %q),'MM/DD/YY HH:MI:SS')}
End Html * Draw some vertical grid lines every 20 pixels. for %x from 1 to %rectWidth by 20 Html End Html end for * Draw some horizontal grid lines every 20 pixels. for %x from 1 to %rectHeight by 20 Html End Html end for * Collect max and min values. %max = 0 %min = 999999999999 frfx: fr fdfx if STAT(%y) lt %min then %min = STAT(%y) end if if STAT(%y) gt %max then %max = STAT(%y) end if End For * Avoid divide-by-zero problems. if not(%max - %min) then Html
No Variance
value={%max}
End Html jump to novar end if * Need a couple text rectangles for the min & max values. Html
{%max}
{%min}
End Html * Draw the jaggy line. Remember: %q holds the observation count. %x = 0 %lsX = fr fdfx %x = %x + 1 %u = STAT(%y) * Calculate the line-end coordinates. %leX = (%max - %u) * (%rectHeight / (%max - %min)) %leY = (%x / %q) * %rectWidth * skip first observation 'cause there's no starting point for line. if %lsX le 0 then jump to oldisnew end if Html End Html * The old end is the new start oldisnew: %lsX = %leX %lsY = %leY end for release records in fdfx novar: * Close out the vml group and table. Html

 

Call Footer End Subroutine GraphIt * ------------------------------------------------------------ * * Present the selected data in table format. * ------------------------------------------------------------ * StatTable: Subroutine Call Header Html Data

 

* Loop through all the "stat" checkboxes. %x = 0 For %z from 1 to $Web_Num_Form('stat') %x = %x + 1 If $len($Web_Parm('stat',%z)) then %name = $Web_Parm('stat',%z) * Post a bit of header info off the header record. fdft: in MONDATA fd TYPE = 'H' and SAMPLE = %sample frft: fr fdft ctostat: count occurrences of STAT %q = count in ctostat %interval = INTERVAL %start = SAMPLE * it's possible (depending on the browser) that the occurrence number * of the stat on the form won't match the occurrence of the stat on the record. feofdft: feo STAT if STAT(occurrence in feofdft) eq %name then %y = occurrence in feofdft jump to header end if end for header: if %x eq 1 then Html End Html end if End For Html Data fdfxtstat: in MONDATA fd TYPE = 'S' and SAMPLE = %sample end find fr fdfxtstat Html Data end for release records in fdfx Html Data End If End For Html Data
Start Time: {$Sir_Ns2Date(%start,'MM/DD/YY HH:MI:SS')} End Time: {$Sir_Ns2Date(%start+(%interval * %q),'MM/DD/YY HH:MI:SS')} Sample Interval: {INTERVAL} second
{%name}{STAT(%y)}
Call Footer End Subroutine StatTable * ------------------------------------------------------------ * * Delete a sample from the database. * ------------------------------------------------------------ * DeleteSample: Subroutine fdaa: in MONDATA fd TYPE = ('H' or 'S') and SAMPLE = %sample fraa: fr fdaa delete record end for Call $Web_Redirect('/demo/demo_sirmontor') End Subroutine DeleteSample * ------------------------------------------------------------ * * Send the page header. * ------------------------------------------------------------ * Header: Subroutine Html {%html} Sirius Performance Monitor {%headstyle} End Html End Subroutine Header * ------------------------------------------------------------ * * Send the page footer. * ------------------------------------------------------------ * Footer: Subroutine Html End Html End Subroutine Footer End