DatabaseProcApplicationCreatedLinks
sybsystemprocssp_sysmon_repagent  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** ===========================================================================
4     ** Generated by spgenmsgs.pl on Sun Jan 29 13:21:05 2006 
5     ** 
6     ** raiserror Messages for sysmon_repagent [Total 0]
7     ** 
8     ** sp_getmessage Messages for sysmon_repagent [Total 0]
9     ** 
10    ** End spgenmsgs.pl output.
11    */
12    create or replace procedure sp_sysmon_repagent
13    as
14        declare @dbid int /* dbid of the database 	 */
15        declare @dbname varchar(255) /* Database name 		 */
16        declare @group_name varchar(255) /* Counter group name		 */
17        declare @rptline varchar(305) /* Formatted info for print stmt */
18        declare @rptline1 varchar(305) /* Formatted info for print stmt */
19        declare @rptline2 varchar(305) /* Formatted info for print stmt */
20        declare @section char(80) /* String to delimit sections    */
21        declare @blankline char(1) /* To print blank line 		 */
22        declare @tmp_int int
23        declare @tmp_total int /* Used to calculate average     */
24        declare @tmp_cnt int /* Used to calculate average     */
25        declare @na_str char(3) /* 'n/a' for 'not applicable'    */
26        declare @tmp_avg varchar(10) /* Used to stored average 	 */
27        declare @tmp_size varchar(12) /* Used to calculate pool size   */
28        declare @runval_multithread varchar(5) /* Used for multithread property */
29        declare @packets_sent int /* Used to calculate avg packets sent */
30        declare @spid int /* Sender spid			*/
31        declare @SleepsOnEmptyQueue int /* Number of sender sleeps on empty queue */
32        declare @NumberOfQueueFlushes int /* Number of times queue is flushed */
33        declare @SleepTimeOnEmptyQueue int /* Total sleep time on empty queue */
34        declare @LongestSleepTimeOnEmptyQueue int
35        /* Longest sleep time on empty queue */
36        declare @MaxQueueSize int /* Max. queue size reached */
37    
38        set nocount on
39    
40        /* Check if ASE is configured to use Replication Agent threads */
41        if is_rep_agent_enabled() = 0
42        begin
43            /* There is nothing to print if Replication Agent is not enable */
44            return (0)
45        end
46    
47        select @blankline = " "
48        select @na_str = "n/a"
49        select @rptline = space(34) + "per sec      per xact       count  %% of total"
50        select @rptline1 = space(29) + "------------  ------------  ----------  ----------"
51    
52        print "==============================================================================="
53        print @blankline
54        print "Replication Agent"
55        print "-----------------"
56        print @blankline
57    
58        /*
59        ** Create a temp table of all databases.  Do not include databases that do
60        ** not support RepAgent Thread (i.e. 'tempdb' (2), 'model' (3),
61        ** 'sybsystemdb' (31513), 'sybsystemprocs' (31514)), local system tempdbs
62        ** (status3 & 536870912), and local user tempdbs (status3 & 256)
63        */
64        select dbid,
65            name,
66            "repagent_" + convert(char(3), dbid) as group_name
67        into #tempdatabases
68        from master.dbo.sysdatabases
69        where name not in ('tempdb', 'model', 'sybsystemdb', 'sybsystemprocs')
70            and (((status3 & 256) = 0)
71                and ((status3 & 536870912) = 0))
72            and is_rep_agent_enabled(dbid) = 1
73    
74        /* Start processing for each database stored in tempdatabases */
75        declare db_info cursor
76        for select dbid, name, group_name from #tempdatabases
77    
78        open db_info
79        fetch db_info into @dbid, @dbname, @group_name
80        while (@@sqlstatus = 0)
81        begin
82            /* make sure temp variables are initialized to 0 */
83            select @tmp_cnt = 0
84            select @tmp_int = 0
85            select @tmp_total = 0
86    
87            select @rptline2 = "Replication Agent:  " + @dbname
88            print @rptline2
89    
90            select @rptline2 = "Replication Server: " +
91                rep_agent_config(@dbid, "config", "rs servername")
92            print @rptline2
93            print @blankline
94            print @rptline
95            print @rptline1
96            print "Log Scan Summary"
97    
98            select @tmp_int = value
99            from #tempmonitors
100           where group_name = @group_name
101               and field_name = "ra_log_records_scanned"
102   
103           select @rptline2 = "    Log Records Scanned"
104           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
105               @na_str + space(11) + @na_str + space(2) +
106               str(@tmp_int, 10) + space(7) + @na_str
107           print @rptline2
108   
109           select @tmp_int = value
110           from #tempmonitors
111           where group_name = @group_name
112               and field_name = "ra_log_records_processed"
113   
114           select @rptline2 = "    Log Records Processed"
115           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
116               @na_str + space(11) + @na_str + space(2) +
117               str(@tmp_int, 10) + space(7) + @na_str
118           print @rptline2
119   
120           select @tmp_int = value
121           from #tempmonitors
122           where group_name = @group_name
123               and field_name = "ra_log_scans"
124   
125           select @rptline2 = "    Number of Log Scans"
126           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
127               @na_str + space(11) + @na_str + space(2) +
128               str(@tmp_int, 10) + space(7) + @na_str
129           print @rptline2
130           select @tmp_cnt = @tmp_int
131   
132           select @tmp_int = value
133           from #tempmonitors
134           where group_name = @group_name
135               and field_name = "ra_sum_log_scan"
136           select @rptline2 = "    Amount of Time for Log Scans (ms)"
137           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
138               @na_str + space(11) + @na_str + space(2) +
139               str(@tmp_int, 10) + space(7) + @na_str
140           print @rptline2
141           select @tmp_total = @tmp_int
142   
143           select @tmp_int = value
144           from #tempmonitors
145           where group_name = @group_name
146               and field_name = "ra_longest_log_scan"
147           select @rptline2 = "    Longest Time for Log Scan (ms)"
148           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
149               @na_str + space(11) + @na_str + space(2) +
150               str(@tmp_int, 10) + space(7) + @na_str
151           print @rptline2
152   
153           select @rptline2 = "    Average Time per Log Scan (ms)"
154           if (@tmp_cnt > 0)
155           begin
156               select @tmp_avg = str(1.0 * @tmp_total / @tmp_cnt, 10, 1)
157           end
158           else select @tmp_avg = str(1.0 * 0, 10, 1)
159           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
160               @na_str + space(11) + @na_str + space(2) + @tmp_avg +
161               space(7) + @na_str
162           print @rptline2
163   
164           print @blankline
165           print "Log Scan Activity"
166   
167           select @tmp_int = value
168           from #tempmonitors
169           where group_name = @group_name and field_name = "ra_xupdate_processed"
170   
171           select @rptline2 = "    Updates"
172           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
173               @na_str + space(11) + @na_str + space(2) +
174               str(@tmp_int, 10) + space(7) + @na_str
175           print @rptline2
176   
177           select @tmp_int = value
178           from #tempmonitors
179           where group_name = @group_name and field_name = "ra_xinsert_processed"
180           select @rptline2 = "    Inserts"
181           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
182               @na_str + space(11) + @na_str + space(2) +
183               str(@tmp_int, 10) + space(7) + @na_str
184           print @rptline2
185   
186           select @tmp_int = value
187           from #tempmonitors
188           where group_name = @group_name and field_name = "ra_xdelete_processed"
189           select @rptline2 = "    Deletes"
190           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
191               @na_str + space(11) + @na_str + space(2) +
192               str(@tmp_int, 10) + space(7) + @na_str
193           print @rptline2
194   
195           select @tmp_int = value
196           from #tempmonitors
197           where group_name = @group_name and field_name = "ra_xexec_processed"
198           select @rptline2 = "    Store Procedures"
199           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
200               @na_str + space(11) + @na_str + space(2) +
201               str(@tmp_int, 10) + space(7) + @na_str
202           print @rptline2
203   
204           select @tmp_int = value
205           from #tempmonitors
206           where group_name = @group_name and field_name = "ra_xcmdtext_processed"
207           select @rptline2 = "    DDL Log Records"
208           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
209               @na_str + space(11) + @na_str + space(2) +
210               str(@tmp_int, 10) + space(7) + @na_str
211           print @rptline2
212   
213           select @tmp_int = value
214           from #tempmonitors
215           where group_name = @group_name and field_name = "ra_xwrtext_processed"
216           select @rptline2 = "    Writetext Log Records"
217           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
218               @na_str + space(11) + @na_str + space(2) +
219               str(@tmp_int, 10) + space(7) + @na_str
220           print @rptline2
221   
222           select @tmp_int = value
223           from #tempmonitors
224           where group_name = @group_name and field_name = "ra_xrowimage_processed"
225           select @rptline2 = "    Text/Image Log Records"
226           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
227               @na_str + space(11) + @na_str + space(2) +
228               str(@tmp_int, 10) + space(7) + @na_str
229           print @rptline2
230   
231           select @tmp_int = value
232           from #tempmonitors
233           where group_name = @group_name and field_name = "ra_xclr_processed"
234           select @rptline2 = "    CLRs"
235           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
236               @na_str + space(11) + @na_str + space(2) +
237               str(@tmp_int, 10) + space(7) + @na_str
238           print @rptline2
239   
240           select @tmp_int = value
241           from #tempmonitors
242           where group_name = @group_name and field_name = "ra_xckpt_processed"
243           select @rptline2 = "    Checkpoints Processed"
244           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
245               @na_str + space(11) + @na_str + space(2) +
246               str(@tmp_int, 10) + space(7) + @na_str
247           print @rptline2
248   
249           select @tmp_int = value
250           from #tempmonitors
251           where group_name = @group_name and field_name = "ra_sqldml_processed"
252           select @rptline2 = "    SQL Statements Processed"
253           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
254               @na_str + space(11) + @na_str + space(2) +
255               str(@tmp_int, 10) + space(7) + @na_str
256           print @rptline2
257   
258   
259           print @blankline
260           print "Transaction Activity"
261   
262           select @tmp_int = value
263           from #tempmonitors
264           where group_name = @group_name and field_name = "ra_open_xact"
265           select @rptline2 = "    Opened"
266           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
267               @na_str + space(11) + @na_str + space(2) +
268               str(@tmp_int, 10) + space(7) + @na_str
269           print @rptline2
270   
271           select @tmp_int = value
272           from #tempmonitors
273           where group_name = @group_name and field_name = "ra_commit_xact"
274           select @rptline2 = "    Commited"
275           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
276               @na_str + space(11) + @na_str + space(2) +
277               str(@tmp_int, 10) + space(7) + @na_str
278           print @rptline2
279   
280           select @tmp_int = value
281           from #tempmonitors
282           where group_name = @group_name and field_name = "ra_abort_xact"
283           select @rptline2 = "    Aborted"
284           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
285               @na_str + space(11) + @na_str + space(2) +
286               str(@tmp_int, 10) + space(7) + @na_str
287           print @rptline2
288   
289           select @tmp_int = value
290           from #tempmonitors
291           where group_name = @group_name and field_name = "ra_prepared_xact"
292           select @rptline2 = "    Prepared"
293           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
294               @na_str + space(11) + @na_str + space(2) +
295               str(@tmp_int, 10) + space(7) + @na_str
296           print @rptline2
297   
298           select @rptline2 = "    Delayed Commit"
299           select @tmp_int = value
300           from #tempmonitors
301           where group_name = @group_name and field_name = "ra_delayed_commit_xact"
302           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
303               @na_str + space(11) + @na_str + space(2) +
304               str(@tmp_int, 10) + space(7) + @na_str
305           print @rptline2
306   
307           select @tmp_int = value
308           from #tempmonitors
309           where group_name = @group_name and field_name = "ra_maintuser_xact"
310           select @rptline2 = "    Maintenance User"
311           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
312               @na_str + space(11) + @na_str + space(2) +
313               str(@tmp_int, 10) + space(7) + @na_str
314           print @rptline2
315           print @blankline
316   
317           print "Log Extension Wait"
318           select @tmp_int = value
319           from #tempmonitors
320           where group_name = @group_name and field_name = "ra_log_waits"
321           select @rptline2 = "    Count"
322           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
323               @na_str + space(11) + @na_str + space(2) +
324               str(@tmp_int, 10) + space(7) + @na_str
325           print @rptline2
326           select @tmp_cnt = @tmp_int
327   
328           select @tmp_int = value
329           from #tempmonitors
330           where group_name = @group_name and field_name = "ra_sum_log_wait"
331           select @rptline2 = "    Amount of time (ms)"
332           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
333               @na_str + space(11) + @na_str + space(2) +
334               str(@tmp_int, 10) + space(7) + @na_str
335           print @rptline2
336           select @tmp_total = @tmp_int
337   
338           select @tmp_int = value
339           from #tempmonitors
340           where group_name = @group_name and field_name = "ra_longest_log_wait"
341           select @rptline2 = "    Longest Wait (ms)"
342           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
343               @na_str + space(11) + @na_str + space(2) +
344               str(@tmp_int, 10) + space(7) + @na_str
345           print @rptline2
346   
347           select @rptline2 = "    Average Time (ms)"
348           if (@tmp_cnt > 0)
349           begin
350               select @tmp_avg = str(1.0 * @tmp_total / @tmp_cnt, 10, 1)
351           end
352           else select @tmp_avg = str(1.0 * 0, 10, 1)
353           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
354               @na_str + space(11) + @na_str + space(2) + @tmp_avg +
355               space(7) + @na_str
356   
357           print @rptline2
358           print @blankline
359   
360           print "Schema Cache"
361           print " Usage"
362           select @rptline2 = "    Max Ever Used (bytes)"
363   
364           /*
365           ** Select the max. reached schema cache for this database.
366           */
367           select @tmp_int = value
368           from #tempmonitors
369           where group_name = @group_name and field_name = "ra_schema_max_used"
370           select @rptline2 = @rptline2 +
371               space(38 - datalength(@rptline2)) +
372               @na_str + space(11) + @na_str + space(2) +
373               str(@tmp_int, 10) + space(7) + @na_str
374           print @rptline2
375   
376           /*
377           ** Select the total number of schema flushes because
378           ** of the schema cache being too small.
379           */
380           select @tmp_int = value
381           from #tempmonitors
382           where group_name = @group_name and field_name = "ra_schema_reuse"
383           select @rptline2 = "    Schemas reused"
384           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
385               @na_str + space(11) + @na_str + space(2) +
386               str(@tmp_int, 10) + space(7) + @na_str
387           print @rptline2
388   
389           print " Forward Schema Lookups"
390           select @tmp_int = value
391           from #tempmonitors
392           where group_name = @group_name and field_name = "ra_forward_schema"
393           select @rptline2 = "    Count"
394           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
395               @na_str + space(11) + @na_str + space(2) +
396               str(@tmp_int, 10) + space(7) + @na_str
397           print @rptline2
398           select @tmp_cnt = @tmp_int
399   
400           select @tmp_int = value
401           from #tempmonitors
402           where group_name = @group_name and field_name = "ra_sum_forward_wait"
403           select @rptline2 = "    Total Wait (ms)"
404           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
405               @na_str + space(11) + @na_str + space(2) +
406               str(@tmp_int, 10) + space(7) + @na_str
407           print @rptline2
408           select @tmp_total = @tmp_int
409   
410           select @tmp_int = value
411           from #tempmonitors
412           where group_name = @group_name and field_name = "ra_longest_forward_wait"
413           select @rptline2 = "    Longest Wait (ms)"
414           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
415               @na_str + space(11) + @na_str + space(2) +
416               str(@tmp_int, 10) + space(7) + @na_str
417           print @rptline2
418   
419           select @rptline2 = "    Average Time (ms)"
420           if (@tmp_cnt > 0)
421           begin
422               select @tmp_avg = str(1.0 * @tmp_total / @tmp_cnt, 10, 1)
423           end
424           else select @tmp_avg = str(1.0 * 0, 10, 1)
425           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
426               @na_str + space(11) + @na_str + space(2) + @tmp_avg +
427               space(7) + @na_str
428           print @rptline2
429           print " Backward Schema Lookups"
430           select @tmp_int = value
431           from #tempmonitors
432           where group_name = @group_name and field_name = "ra_backward_schema"
433           select @rptline2 = "    Count"
434           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
435               @na_str + space(11) + @na_str + space(2) +
436               str(@tmp_int, 10) + space(7) + @na_str
437           print @rptline2
438           select @tmp_cnt = @tmp_int
439   
440           select @tmp_int = value
441           from #tempmonitors
442           where group_name = @group_name and field_name = "ra_sum_bckward_wait"
443           select @rptline2 = "    Total Wait (ms)"
444           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
445               @na_str + space(11) + @na_str + space(2) +
446               str(@tmp_int, 10) + space(7) + @na_str
447           print @rptline2
448           select @tmp_total = @tmp_int
449   
450           select @tmp_int = value
451           from #tempmonitors
452           where group_name = @group_name and field_name = "ra_longest_bckward_wait
453   "
454           select @rptline2 = "    Longest Wait (ms)"
455           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
456               @na_str + space(11) + @na_str + space(2) +
457               str(@tmp_int, 10) + space(7) + @na_str
458           print @rptline2
459   
460           select @rptline2 = "    Average Time (ms)"
461           if (@tmp_cnt > 0)
462           begin
463               select @tmp_avg = str(1.0 * @tmp_total / @tmp_cnt, 10, 1)
464           end
465           else select @tmp_avg = str(1.0 * 0, 10, 1)
466           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
467               @na_str + space(11) + @na_str + space(2) + @tmp_avg +
468               space(7) + @na_str
469           print @rptline2
470           print @blankline
471           print "Truncation Point Movement"
472   
473           select @tmp_int = value
474           from #tempmonitors
475           where group_name = @group_name and field_name = "ra_truncpt_moved"
476           select @rptline2 = "    Moved"
477           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
478               @na_str + space(11) + @na_str + space(2) +
479               str(@tmp_int, 10) + space(7) + @na_str
480           print @rptline2
481   
482           select @tmp_int = value
483           from #tempmonitors
484           where group_name = @group_name and field_name = "ra_truncpt_gotten"
485   
486           select @rptline2 = "    Gotten from RS"
487           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
488               @na_str + space(11) + @na_str + space(2) +
489               str(@tmp_int, 10) + space(7) + @na_str
490           print @rptline2
491           print @blankline
492           print "Connections to Replication Server"
493   
494           select @tmp_int = value
495           from #tempmonitors
496           where group_name = @group_name and field_name = "ra_rs_connect"
497           select @rptline2 = "    Success"
498           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
499               @na_str + space(11) + @na_str + space(2) +
500               str(@tmp_int, 10) + space(7) + @na_str
501           print @rptline2
502   
503           select @tmp_int = value
504           from #tempmonitors
505           where group_name = @group_name and field_name = "ra_fail_rs_connect"
506           select @rptline2 = "    Failed"
507           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
508               @na_str + space(11) + @na_str + space(2) +
509               str(@tmp_int, 10) + space(7) + @na_str
510           print @rptline2
511           print @blankline
512           print "Network Packet Information"
513   
514           select @tmp_int = value
515           from #tempmonitors
516           where group_name = @group_name and field_name = "ra_packets_sent"
517           select @rptline2 = "    Packets Sent"
518           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
519               @na_str + space(11) + @na_str + space(2) +
520               str(@tmp_int, 10) + space(7) + @na_str
521           print @rptline2
522           select @tmp_cnt = @tmp_int
523           select @packets_sent = @tmp_int
524   
525           select @tmp_int = value
526           from #tempmonitors
527           where group_name = @group_name and field_name = "ra_full_packets_sent"
528           select @rptline2 = "    Full Packets Sent"
529           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
530               @na_str + space(11) + @na_str + space(2) +
531               str(@tmp_int, 10) + space(7) + @na_str
532           print @rptline2
533   
534           select @tmp_int = value
535           from #tempmonitors
536           where group_name = @group_name and field_name = "ra_largest_packet"
537           select @rptline2 = "    Largest Packet"
538           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
539               @na_str + space(11) + @na_str + space(2) +
540               str(@tmp_int, 10) + space(7) + @na_str
541           print @rptline2
542   
543           select @tmp_int = value
544           from #tempmonitors
545           where group_name = @group_name and field_name = "ra_sum_packet"
546           select @rptline2 = "    Amount of Bytes Sent"
547           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
548               @na_str + space(11) + @na_str + space(2) +
549               str(@tmp_int, 10) + space(7) + @na_str
550           print @rptline2
551           select @tmp_total = @tmp_int
552   
553           select @rptline2 = "    Average Packet"
554           if (@tmp_cnt > 0)
555           begin
556               select @tmp_avg = str(1.0 * @tmp_total / @tmp_cnt, 10, 1)
557           end
558           else select @tmp_avg = str(1.0 * 0, 10, 1)
559           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
560               @na_str + space(11) + @na_str + space(2) + @tmp_avg +
561               space(7) + @na_str
562           print @rptline2
563           print @blankline
564           print "I/O Wait from RS"
565   
566           select @tmp_int = sum(value)
567           from #tempmonitors
568           where group_name = @group_name
569               and (field_name = "ra_io_send" or field_name = "ra_io_recv")
570           select @rptline2 = "    Count"
571           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
572               @na_str + space(11) + @na_str + space(2) +
573               str(@tmp_int, 10) + space(7) + @na_str
574           print @rptline2
575           select @tmp_cnt = @tmp_int
576   
577           select @tmp_int = sum(value)
578           from #tempmonitors
579           where group_name = @group_name
580               and (field_name = "ra_sum_io_send_wait"
581                   or field_name = "ra_sum_io_recv_wait")
582           select @rptline2 = "    Amount of Time (ms)"
583           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
584               @na_str + space(11) + @na_str + space(2) +
585               str(@tmp_int, 10) + space(7) + @na_str
586           print @rptline2
587           select @tmp_total = @tmp_int
588   
589           select @tmp_int = max(value)
590           from #tempmonitors
591           where group_name = @group_name
592               and (field_name = "ra_longest_io_send_wait"
593                   or field_name = "ra_longest_io_recv_wait")
594           select @rptline2 = "    Longest Wait (ms)"
595           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
596               @na_str + space(11) + @na_str + space(2) +
597               str(@tmp_int, 10) + space(7) + @na_str
598           print @rptline2
599   
600           select @rptline2 = "    Average Wait (ms)"
601           if (@tmp_cnt > 0)
602           begin
603               select @tmp_avg = str(1.0 * @tmp_total / @tmp_cnt, 10, 1)
604           end
605           else select @tmp_avg = str(1.0 * 0, 10, 1)
606           select @rptline2 = @rptline2 + space(38 - datalength(@rptline2)) +
607               @na_str + space(11) + @na_str + space(2) + @tmp_avg +
608               space(7) + @na_str
609           print @rptline2
610           print @blankline
611   
612           select @rptline2 = replicate('-', 80)
613           print @rptline2
614   
615           print @rptline2
616   
617           fetch db_info into @dbid, @dbname, @group_name
618   
619       end
620       close db_info
621       deallocate cursor db_info
622   
623       return 0
624   

DEFECTS
 CUNU 3 Cursor not updated: cursor should contain 'for read only' clause db_info 76
 MGTP 3 Grant to public master..sysdatabases  
 MLCH 3 Char type with length>30 char(80) 20
 MNER 3 No Error Check should check @@error after select into 64
 MUCO 3 Useless Code Useless Brackets 44
 MUCO 3 Useless Code Useless Brackets 80
 MUCO 3 Useless Code Useless Brackets 154
 MUCO 3 Useless Code Useless Brackets 348
 MUCO 3 Useless Code Useless Brackets 420
 MUCO 3 Useless Code Useless Brackets 461
 MUCO 3 Useless Code Useless Brackets 554
 MUCO 3 Useless Code Useless Brackets 601
 QAFM 3 Var Assignment from potentially many rows 98
 QAFM 3 Var Assignment from potentially many rows 109
 QAFM 3 Var Assignment from potentially many rows 120
 QAFM 3 Var Assignment from potentially many rows 132
 QAFM 3 Var Assignment from potentially many rows 143
 QAFM 3 Var Assignment from potentially many rows 167
 QAFM 3 Var Assignment from potentially many rows 177
 QAFM 3 Var Assignment from potentially many rows 186
 QAFM 3 Var Assignment from potentially many rows 195
 QAFM 3 Var Assignment from potentially many rows 204
 QAFM 3 Var Assignment from potentially many rows 213
 QAFM 3 Var Assignment from potentially many rows 222
 QAFM 3 Var Assignment from potentially many rows 231
 QAFM 3 Var Assignment from potentially many rows 240
 QAFM 3 Var Assignment from potentially many rows 249
 QAFM 3 Var Assignment from potentially many rows 262
 QAFM 3 Var Assignment from potentially many rows 271
 QAFM 3 Var Assignment from potentially many rows 280
 QAFM 3 Var Assignment from potentially many rows 289
 QAFM 3 Var Assignment from potentially many rows 299
 QAFM 3 Var Assignment from potentially many rows 307
 QAFM 3 Var Assignment from potentially many rows 318
 QAFM 3 Var Assignment from potentially many rows 328
 QAFM 3 Var Assignment from potentially many rows 338
 QAFM 3 Var Assignment from potentially many rows 367
 QAFM 3 Var Assignment from potentially many rows 380
 QAFM 3 Var Assignment from potentially many rows 390
 QAFM 3 Var Assignment from potentially many rows 400
 QAFM 3 Var Assignment from potentially many rows 410
 QAFM 3 Var Assignment from potentially many rows 430
 QAFM 3 Var Assignment from potentially many rows 440
 QAFM 3 Var Assignment from potentially many rows 450
 QAFM 3 Var Assignment from potentially many rows 473
 QAFM 3 Var Assignment from potentially many rows 482
 QAFM 3 Var Assignment from potentially many rows 494
 QAFM 3 Var Assignment from potentially many rows 503
 QAFM 3 Var Assignment from potentially many rows 514
 QAFM 3 Var Assignment from potentially many rows 525
 QAFM 3 Var Assignment from potentially many rows 534
 QAFM 3 Var Assignment from potentially many rows 543
 VUNU 3 Variable is not used @section 20
 VUNU 3 Variable is not used @tmp_size 27
 VUNU 3 Variable is not used @runval_multithread 28
 VUNU 3 Variable is not used @spid 30
 VUNU 3 Variable is not used @SleepsOnEmptyQueue 31
 VUNU 3 Variable is not used @NumberOfQueueFlushes 32
 VUNU 3 Variable is not used @SleepTimeOnEmptyQueue 33
 VUNU 3 Variable is not used @LongestSleepTimeOnEmptyQueue 34
 VUNU 3 Variable is not used @MaxQueueSize 36
 CUPD 2 Updatable Cursor Marker (updatable by default) 76
 MTR1 2 Metrics: Comments Ratio Comments: 6% 12
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 58 = 58dec - 2exi + 2 12
 MTR3 2 Metrics: Query Complexity Complexity: 446 12

DEPENDENCIES
PROCS AND TABLES USED
reads table tempdb..#tempmonitors (1) 
reads table master..sysdatabases (1)  
read_writes table tempdb..#tempdatabases (1) 

CALLERS
called by proc sybsystemprocs..sp_sysmon_analyze  
   called by proc sybsystemprocs..sp_sysmon