Quantcast
Viewing all articles
Browse latest Browse all 15889

Blocking Alert WMI Property Details

I have a created a blocking alert.  It works, but I'm very fuzzy about the WMI properties.  I use the (WMI(property)) token to get the property values, but I am unsure of what I'm getting.  I would appreciate any advice on any of these questions.  Sorry about being so verbose. 

1) Are the WMI tokens textual representations of the values?  For example, the SPID value is listed as Sint32 in the documentation.  Is it actually an INT that I can use in T-SQL?  Or is it a string representation of the INT that must be quoted and converted to the type listed? 

2) Should I be using N'$(ESCAPE_SQUOTE(WMI(property)))' for all WMI properties I use? 

http://msdn.microsoft.com/en-US/library/ms180522(v=sql.90).aspx lists the inherited and event properties.  It appears to me that the inherited properties can relate to the event, but some are for the process handling the event.  For example, the DatabaseId is that in which the blocking exists.  However, the SPID value is always 8 which appears to be the process handling the event.  

3) Is there any documentation with detail other than a type for these properties?  Which should be ignored in general? 

I noticed that the inherited values for LoginSid and SessionLoginName are blank.  I don't know if I am getting them incorrectly or if they don't have any values in this case. 

4) Quoting a Uint8[] array?  Does this convert?

I can get an object name for the ObjectId for the DatabaseId sometimes.  However, I have cases where the ObjectId is 1050 and the IndexId is 256.  

5) How does one use the ObjectId when the IndexId is non-zero? 

I use an alert with a WMI query.  The where clause on the duration prevents multiple alerts from the same blocked process.  The duration is limited to twice the blocking threshold.  However, once in a while, the alert is not detected within this duration.  I'm thinking I can set the query to allow durations several times the threshold value and then check for duplicates. 

6) Can the TransactionId value be used to detect prior alerts from the same blocked process?  (I have a separate process that handles blocking status and recovery notices.)

DECLARE @AlertId int;

INSERT INTO alert.BlockingEvents (
 [LoginSid], -- Uint8[]
 [PostTime], -- DateTime
 [SQLInstance], -- String
 [IsSystem], -- Sint32
 [DatabaseId], -- Sint32
 [ComputerName], -- String
 [SessionLoginName], -- String
 [SPID], -- Sint32
 [TransactionID], -- Sint64
 [EventSequence], -- Sint32
 [IndexID] , -- Sint32
 [ObjectID], -- Sint32
 [TextData], -- String
 [Endtime], -- DateTime
 [Duration], -- Sint64
 [Mode] -- Sint32
)
VALUES (
 N'$(ESCAPE_NONE(WMI(LoginSid)))',
 N'$(ESCAPE_NONE(WMI(PostTime)))',
 N'$(ESCAPE_NONE(WMI(SQLInstance)))',
 N'$(ESCAPE_NONE(WMI(IsSystem)))',
 N'$(ESCAPE_NONE(WMI(DatabaseId)))',
 N'$(ESCAPE_NONE(WMI(ComputerName)))',
 N'$(ESCAPE_NONE(WMI(SessionLoginName)))',
 N'$(ESCAPE_NONE(WMI(SPID)))',
 N'$(ESCAPE_NONE(WMI(TransactionID)))',
 N'$(ESCAPE_NONE(WMI(EventSequence)))',
 N'$(ESCAPE_NONE(WMI(IndexId)))',
 N'$(ESCAPE_NONE(WMI(ObjectId)))',
 N'$(ESCAPE_SQUOTE(WMI(TextData)))',
 N'$(ESCAPE_NONE(WMI(EndTime)))',
 N'$(ESCAPE_NONE(WMI(Duration)))',
 N'$(ESCAPE_NONE(WMI(Mode)))'
)

SET @AlertId = SCOPE_IDENTITY();

EXECUTE alert.prBlockingMail
 @AlertId=@AlertId,
 @emailTo='dbas@xxx.yyy',
 @verbose=1

Thanks


Randy in Marin


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>