|
A Sample To Watch How The Data Value Is Changed
A Sample To Watch How The Data Value Is Changed
/*Scenario 1 common usage in Sybase Agent*/
dbcc monitor("sample","all","on")
dbcc monitor("select","all","on")
dbcc monitor("clear","all","on")
dbcc traceon(8399)
/*wait for interval*/
select GROUPNAME = group_name,
FLDNAME = field_name,
FLDVALUE = value
from master..sysmonitors
/*clear the value for next time*/
dbcc monitor("clear","all","on");
/*****************************************************************************/
/*Scenario 2 for manually watching the metric change */
dbcc monitor("clear", "all", "on")
[wait]
dbcc monitor("sample", "all", "on")
dbcc monitor("select", "all", "on")
dbcc traceon(8399) -- to populate sysmonitors with the monitor counters, may not be needed in most recent versions
select * from sysmonitors
dbcc traceoff(8399)
/*Scenario 2 repeat the following the number in buffer_0 will be changed */
select GROUPNAME = group_name,
FLDNAME = field_name,
FLDVALUE = value
from master..sysmonitors
where group_name = 'buffer_0'
order by 1, 3 desc, 2
dbcc monitor("sample","all","off")
dbcc monitor("select","all","off")
dbcc monitor("clear","all","off")
/*Scenario 2 the following statement returns nothing, since it has been turned off*/
select GROUPNAME = group_name,
FLDNAME = field_name,
FLDVALUE = value
from master..sysmonitors
where group_name = 'buffer_0'
order by 1, 3 desc, 2
select count(*) from sysmonitors
No data return
dbcc monitor("sample","all","on")
No data return
dbcc monitor("select","all","on")
The data return
dbcc monitor("clear","all","on")
The data is return
dbcc monitor("select","all","off")
No data return
Use the following you get an clear result
dbcc monitor("sample","all","on")
dbcc monitor("select","all","on")
dbcc monitor("clear","all","on")
select GROUPNAME = group_name,
FLDNAME = field_name,
FLDVALUE = value
from master..sysmonitors holdlock
where group_name = 'buffer_0'
order by 1, 3 desc, 2
Use the following, you get an un-clear result.
dbcc monitor("sample","all","on")
dbcc monitor("select","all","on")
//dbcc monitor("clear","all","on")
select GROUPNAME = group_name,
FLDNAME = field_name,
FLDVALUE = value
from master..sysmonitors holdlock
where group_name = 'buffer_0'
order by 1, 3 desc, 2
When there is a dbcc monitor("clear","all","on") statement, the counter number is clear.
and this will affect the number in sysmonitors. |
|