Monitoring Application Health with WMI and .NET

xiaoxiao2021-03-06  55

Francis A. Shanahan

The Windows Management Instrumentation framework is one of the least publicized yet most useful tools in the .NET Framework. If your job is to create enterprise class software, you do not need to lie awake at night wondering whether your application is still running. In This Article, Francis Shanahan Shows You How To Build Enterprise Class Peace-of-Mind Into Your .NET Software and Finally Get The Sleep You Deserve!

I do not know much about cars. Some folks can tell the mileage just by listening to the engine. When I drive down the road, I look at the instruments on the dashboard to understand how the car's running. The oil, the temperature, THE GAS GAGES, AND SO FORTH All Provide Information on now. as The Administrator of That VEHICLE, I'M Clueless WITHOUT INSTRUMENTATION.

The computing industry has recognized this same need for instrumentation in enterprise software. In 1992 the Desktop Management Task Force (DMTF) consortium was formed by BMC, Cisco, Compaq, Intel, Microsoft, and a number of others to solve this need. The DMTF Published The Common Information Model (CIM), Which Provides A Standard Definition for Management Information Including Detailed Data Around Operating Systems, Processors, Disks, Networks, And So ON.

Most recently the DMTF issued the Web-Based Enterprise Management (WBEM), which is "a set of management and Internet standard technologies developed to unify the management of enterprise computing environments." The WBEM provides information or "management data" in a structured manner That Extends the Cim.

Windows Management Instrumentation (WMI) is Microsoft's implementation of WBEM. WMI is currently built into Windows 2000 and XP and will also be supported in the upcoming release of Longhorn. I'll show you how to use WMI to access management data and even enhance the CIM Schema to Support your OWN Applications.integrating WMI Support with Visual Studio

Before I dive into the WMI and what it can do, take from http://msdn.microsoft.com/library/default.asp?url=/downloads/list/ a second and grab the Management Extensions plug-in for Visual Studio wmi.asp. Installing this plug-in will add two nodes, Management Classes and Management Events, to the Server Explorer in Visual Studio. A version is also available for Studio 2002 if you've yet to upgrade. After you install the Management Extensions You Should Add your Machine to the Server Explorer (See Figure 1).

Right-click and select "Add Server ..." You can navigate to any machine within your network and add it to the Explorer. In some cases you may need to add machines using a username and password different from the user you're logged . in as in Figure 1, BULLDOG is my machine name and the Management classes node is expanded You'll notice there's nothing under Management Events yet;. more on that later I'll focus on management classes first..

USING Management Classes in .NET

The WMI Management Extensions allow you to literally drag and drop managed classes from the Server Explorer onto your forms. You can then use these classes to get information like disk space, available network bandwidth, memory usage, CPU utilization, and more. At this point I recommend you create a simple Web application if you'd like to follow along with the code. I'm using a Web application named "HardcoreWMI" but a Windows Forms application will work equally well.Once you have your basic application up and running , go ahead and drag a few management classes onto your Web form. When you drop classes onto your form, a wrapper class is generated that encapsulates all of the properties and methods within that management class. you'll need to add the System.Management .dll namespace to your project's references. Table 1 Describes the classes i Chose for this Example.

Table 1. Management classes along with their location and wrapper classes.

Management classLocated underResulting wrapper classComputerSystemMy ComputerRoot.CIMV2.Win32_ComputerSystem.VBLogicalDiskDisk VolumesRoot.CIMV2.Win32_LogicalDisk.VBProcessorProcessorsRoot.CIMV2.Win32_Processor.VBService Services (I chose the SQL Server process, but you can pick any service you're interested in managing) Root.CIMV2 .Win32_service.vb

Along with the wrapper classes, an instance of the wrapper is created, so, for example, your form will now have a ComputerSystem1 local variable that's an instance of root.Cimv2.Win32_ComputerSystem. IntelliSense will give you an idea what methods and properties are available See Listing 1).

The wrapper classes created make it really easy to query the various WMI enabled objects. You'll notice the name of the classes follows a pattern, too. Root / Cimv2 / Win32_ComputerSystem is the name of the class in the CIM schema.Listing 1. Reading the size and available space in gb from the logicaldisk1 Object.

DIM Disksize as double = _

Convert.TOINT64 (LogicalDisk1.size) / _ _

(1024 * 1024 * 1024)

DIM FREESPACE As Double = _

Convert.TOINT64 (LogicalDisk1.Freespace) / _ _

(1024 * 1024 * 1024)

The schema and wql

In the case of properties on a management class, the information is fairly standard. What about cases where you want specific information that is not readily available in the properties? This is a situation for an explicit WBEM Query Language (WQL) statement. WQL works just like SQL but for WBEM data. The syntax is very similar to SQL in that it uses SELECT statements to define the objective of the query and WHERE clauses to limit the query results. WMI provides a built-in utility called WBEMTest.exe, Which you can use to try out some wql for yourself.

Click Start | Run and type WBEMTest to launch the utility Before you can use WBEMTest, you must connect to a schema Click Connect, type root / cimv2 in the Namespace dialog, and click Connect This connects you to the main node for the... CIM Schema (Version 2) on Your Local Machine (See Figure 2). You Could Also Connect To Another Machine's Schema with // / Root / Cimv2 To Access That Machine's Data Remotely.

If you do try this, you'll, ask disable any firewalls you have running on source and target, as this Tool Uses a Random Port to Communicate Across The Network.

You do not have to connect to the cimv2 node necessarily. As you'll see later on in this article, you can add your own branches to the schema and publish data to those nodes.You can query just about any element of the schema . SO What Are Those Elements? Click Enum Classes and the Hit Ok To Enumerate All Classes from / root / cimv2 down. To try out a wql query WQL (see Table 2).

Table 2. Example WQL Queries.

WQL statementDescriptionSELECT * FROM win32_NTLogEvent WHERE logfile = '. System'Lists all contents of the System Event log SELECT * FROM win32_PerfRawData_PerfProc_Process WHERE name =' Idle'Retrieves information on the system idle process.SELECT freespace, size FROM win32_LogicalDisk WHERE caption = 'c: 'Gets The Total Disk Space and The Amount of Free Space on The C: Volume.Select Name, Description from Win32_Service Where State = "Stopped" lists All Services That Are Currently Stopped On The Machine.

You'll notice you can use single quotes or double quotes in your WQL statements A note of caution:.. Some of these queries can return a lot of data if not restricted by a WHERE clause Be careful not to send your machine into a death Spiral.

Invoking WQL from Code

Getting back to the demo application, I want to invoke a WQL statement from within .NET code. To make things interesting, I'll add a textbox to my form to allow the user to enter the WQL statement and a button to execute that statement ................... ..

Listing 2. How to Run An Arbitrary WQL Statement Using System.Management Classes.

SUB EXECUTEWQLQUERY (Byval Strwql As String "Create a Query

DIM MySelect As New SelectQuery (Strwql)

'Initialize an Object Searcher W / this Query

DIM MyResults as new managementObjectsearchSearcher (MySELECT)

DIM MyProperty As PropertyData

'Itereate Through The Resulting COLLECTION

For Each WMIObject in MyResults.get ()

'Print Out Each Name / Value PAIR

For Each MyProperty in WmiObject.properties

lblinfo.text & = "
" & myProperty.Name _

& "=" & Convert.toString (MyProperty.Value)

NEXT

Next WMIOBJECT

End Sub

In Listing 2, I've added some code to iterate through the resulting collection and display the results. It's important to note that the WBEM and WMI is an object-oriented approach to management data. APIs return objects, not flat non-hierarchical information . These WMI objects can be used to affect the underlying managed entities as well as monitor them. In this manner you can programmatically control your software and hardware devices. In a real-world situation, you could restart a machine, launch a service, schedule a check-disk, or even remove a Machine from a domain.

In Listing 3, I invoke the startservice method. I Could Have Used a generated class Similar to the earlier examples, but the purpose of the article is to show you the possibilities!

Listing 3. Invoking a Method on a managed object.

'Create a new path to the window

Dim mypath as managementpath = new managementPath

mypath.server = system.environment.machinename

mypath.namespacepath = "root / cimv2"

'Set the service name from the user's input box

mypath.relativePath = "Win32_Service.Name = '" _ _

TXTSERVICENAME.TEXT "'"' Create a New Management Object

'That Reresents the service

DIM myservice as managementObject = _

New ManagementObject (MyPath)

'Invoke the startservice method

DIM RETURNOBJECT As ManagementBaseObject = _

MyService.invokeMethod ("StartService", Nothing, _

Nothing)

You've seen how to examine the schema and also how to remotely execute methods on a managed class using WMI. In the next section, I describe how to add or extend the schema for your own applications and how to publish information to that schema extension .

INSTRUMENTINGY

Earlier you saw that the Management Extensions plug-in adds a Management Events node to the Server Explorer. Right now that node is empty, but I'm going to show you how to create your own custom WMI events and fire them from within your code . This process is known as Instrumenting and is fairly simple regardless of whether your application is ASP.NET-based or Windows Forms-based. An understanding of attributes is useful for this discussion but not essential. Attributes deserve their own article, but if you 'Ve Never Seen An Attribute Before, you can one.

In the COM days, it was necessary to create an entire extra class known as a WMI Provider to provide information to WMI. In the .NET world, we can achieve the same effect with much less effort. The first thing to do is tag your Assembly with the instructed attribute. i Typically Put this attribute in the assemblyinfo.vb file, but you can put it anywhere in the assembly's code.

This attribute will be read during installation, and the machine's schema will be modified to include the namespace from the instrumented tag-in this case, the root / HardcoreWMI namespace If your application doesn. 'T Already Have An Installer Class, IT Will Be Necessary To Add One. If you don't want a ful-blown customized installation, The Following Snippet Is All That's needed:

_

Public Class SimpleInstaller

Inherits DefaultManagementProjectInstaller

END CLASS

To fire a custom event, you need a custom event class. All that's required to turn a class into a WMI event class is the InstrumentationType.Event Attribute. This attribute-driven approach makes it extremely simple to instrument your application.

_

Public Class HardcoreEvent

Public HardcoreMessage As String

Public MethodName As String

END CLASS

To Fire this Event, I use the folowing:

System.Management.instrumentation. _

Instrumentation.fire (MyEvent)

The demo code associated with this article provides a button that fires this event. In production code, you might consider firing the event from within your exception handler. Once the application is built, it's necessary to register that assembly's namespace within the schema. You do this by installing the assembly using the installUtil.exe provided with the .NET Framework. In a command window, navigate to your built assembly's folder and type installUtil to register your application with the schema.

Once an event is fired, it's available to any WMI capable application, including Microsoft Operations Manager or the Management Event node of Visual Studio. To capture these events in Studio, right-click on Management Events, click Add Event Query ..., and select Custom from the Event Type radio buttons. If you've run the installUtil as described earlier, you should see your application's node in the schema. If you expand the node, you'll see the custom event in the tree (see Figure 3 ) .Clicking OK will add an Event Query to your Visual Studio Server Explorer. When you run the demo and click Fire Custom Event, the Event Query will be triggered and print the event details to the output window.

The Event model in .NET uses delegates to allow multiple consumers for a single event. Your .NET code can consume these events synchronously by blocking until the event is fired, or asynchronously by using a ManagementEventWatcher (see Listing 4). You'll notice that since this is an asynchronous listener, I need to set up a delegate function to handle the event when it fires. in Listing 4, that function is called HandleEvent. The demo code for this article implements Listing 4 in a Windows Forms application.

Listing 4. Asynchronously Listen for Custom WMI Events.

Dim Wmilistener As New ManagementEventWatcher

'MyQuery Listens for HardcoreEvents to

'Fire Every 5 Seconds

DIM MyQuery As New WqleventQuery (_

"HardcoreEelent", New System.TimeSpan (5))

Wmilistener.Query = myQuery

'Set up a delegate to fire when the

'Event Arrives

AddHandler Wmilistener.eventarrived, _

Addressof Handleevent

Wmilistener.scope.path.server = "bulldog"

Wmilistener.scope.path.namespacepath = _ "root / hardcorewmi"

'Start listening

Wmilistener.start ()

The final piece of the puzzle is to publish entire classes to the schema. I've already shown how events can be published through the use of attributes. Entire classes can be published in the same manner.

_

Public Class HardcorebusinessObject

Private _firstname as string

In this Snippet I've Tagged My Class, HardcorebusinessObject, with the .instance attribute. You Can Now Publish This Class with:

Instrumentation.publish (Myentity)

myEntity is an instance of HardcoreBusinessObject You can test this mechanism through Visual Studio:. Right-click Management Classes and select Add Classes ..., and then choose your applications' node and expand it until you come to the instrumented class Click Add and. Ok. Now when the class is published to WMI, That Instances Available To The Server Explorer (See Figure 4).

The Sample Applications

The provided solution contains two projects, a Web application and a Windows Forms application. In each case you need to update the machine name to the machine you're monitoring. Do a search and replace to replace "BULLDOG" with your own machine name. From The Web Application You Can Do The Following:

. Execute a WQL query View statistics on the local machine through a generic dial type user control that indicates min, max, and current values ​​for a particular data point Publish an instance of a dummy business object-in this case, "HardcoreBusinessObject". - and view the published instance in Server Explorer. Start a service. The sample defaults to the SQLSERVER service, but you can enter any service name you'd like. Fire a custom event. you can verify the event has fired by building an Event Query as described earlier in this article.The Windows Forms application will listen asynchronously for the custom event to fire. Once it fires, the event data is retrieved from WMI and added to the list box on the form.

What this Article Hasn't Covered

This Article Has Only Scratched The Surface In Terms of What's Possible with WMI. Other AREAS of Interest Not Covered Here Are:

Integration with other WMI consumers, such as Microsoft Operations Manager. Using WMI will allow your application to integrate with Microsoft Operations Manager out of the box. Security and access to data, all of which is accounted for in the current WMI spec. Windows 2000 and above actually ship with an MMC snap-in to allow management of security privileges, logging, and backup of WMI data. Consumption of SNMP traps. SNMP traps can be consumed through the WMI interfaces in a similar manner to the mechanism shown here. See the "References" Sidebar for a Link That Provides More Detail About SNMP. EXPOSure of Management Data Through Web SERVICES.

Table 1. Management classes along with their location and wrapper classes.

Management classLocated underResulting wrapper classComputerSystemMy ComputerRoot.CIMV2.Win32_ComputerSystem.VBLogicalDiskDisk VolumesRoot.CIMV2.Win32_LogicalDisk.VBProcessorProcessorsRoot.CIMV2.Win32_Processor.VBService Services (I chose the SQL Server process, but you can pick any service you're interested in managing) Root.CIMV2 .Win32_Service.VBAlong with the wrapper classes, an instance of the wrapper is created, so, for example, your form will now have a ComputerSystem1 local variable that's an instance of root.Cimv2.Win32_ComputerSystem. IntelliSense will give you an idea what methods and Properties Are Available (See Listing 1).

The wrapper classes created make it really easy to query the various WMI enabled objects. You'll notice the name of the classes follows a pattern, too. Root / Cimv2 / Win32_ComputerSystem is the name of the class in the CIM schema.

Listing 1. Reading The size and available space in gb from the logicaldisk1 object.

DIM Disksize as double = _

Convert.TOINT64 (LogicalDisk1.size) / _ _

(1024 * 1024 * 1024)

DIM FREESPACE As Double = _

Convert.TOINT64 (LogicalDisk1.Freespace) / _ _

(1024 * 1024 * 1024)

The schema and wql

In the case of properties on a management class, the information is fairly standard. What about cases where you want specific information that is not readily available in the properties? This is a situation for an explicit WBEM Query Language (WQL) statement. WQL works just like SQL but for WBEM data. The syntax is very similar to SQL in that it uses SELECT statements to define the objective of the query and WHERE clauses to limit the query results. WMI provides a built-in utility called WBEMTest.exe, Which you can use to try out some wql for yourself.

Click Start | Run and type WBEMTest to launch the utility Before you can use WBEMTest, you must connect to a schema Click Connect, type root / cimv2 in the Namespace dialog, and click Connect This connects you to the main node for the... CIM schema (version 2) on your local machine (see Figure 2). you could also connect to another machine's schema with // / root / Cimv2 to access that machine's data remotely.If you do try this, you'll Need to disable anyfirewalls you have running on source and target, as this Tool Uses a Random Port to Communicate Across the network.

You don't have to connect t 's.

You can query just about any element of the schema. So what are those elements? Click Enum Classes and then hit OK to enumerate all classes from / root / cimv2 down. To try out a WQL query, click Query and enter some WQL (see Table 2).

Table 2. Example WQL Queries.

WQL statementDescriptionSELECT * FROM win32_NTLogEvent WHERE logfile = '. System'Lists all contents of the System Event log SELECT * FROM win32_PerfRawData_PerfProc_Process WHERE name =' Idle'Retrieves information on the system idle process.SELECT freespace, size FROM win32_LogicalDisk WHERE caption = 'c: 'Gets The Total Disk Space and The Amount of Free Space on The C: Volume.Select Name, Description from Win32_Service Where State = "Stopped" lists All Services That Are Currently Stopped On The Machine.

You'll notice you can use single quotes or double quotes in your WQL statements A note of caution:.. Some of these queries can return a lot of data if not restricted by a WHERE clause Be careful not to send your machine into a death Spiral.Invoking WQL from Code

Getting back to the demo application, I want to invoke a WQL statement from within .NET code. To make things interesting, I'll add a textbox to my form to allow the user to enter the WQL statement and a button to execute that statement ................... ..

Listing 2. How to Run An Arbitrary WQL Statement Using System.Management Classes.

SUB EXECUTEWQLQUERY (Byval Strwql As String)

'Create a Query

DIM MySelect As New SelectQuery (Strwql)

'Initialize an Object Searcher W / this Query

DIM MyResults as new managementObjectsearchSearcher (MySELECT)

DIM MyProperty As PropertyData

'Itereate Through The Resulting COLLECTION

For Each WMIObject in MyResults.get ()

'Print Out Each Name / Value PAIR

For Each MyProperty in WmiObject.properties

lblinfo.text & = "
" & myProperty.Name _

& "=" & Convert.toString (MyProperty.Value)

NEXT

Next WMIOBJECT

End Sub

In Listing 2, I've added some code to iterate through the resulting collection and display the results. It's important to note that the WBEM and WMI is an object-oriented approach to management data. APIs return objects, not flat non-hierarchical information . These WMI objects can be used to affect the underlying managed entities as well as monitor them. In this manner you can programmatically control your software and hardware devices. In a real-world situation, you could restart a machine, launch a service, schedule a check-disk, or even remove a machine from a domain.In Listing 3, I invoke the StartService method. I could have used a generated class similar to the earlier examples, but the purpose of the article is to show you the possibilities!

Listing 3. Invoking a Method on a managed object.

'Create a new path to the window

Dim mypath as managementpath = new managementPath

mypath.server = system.environment.machinename

mypath.namespacepath = "root / cimv2"

'Set the service name from the user's input box

mypath.relativePath = "Win32_Service.Name = '" _ _

TXTSERVICENAME.TEXT "'"

'Create a New Management Object

'That Reresents the service

DIM myservice as managementObject = _

New ManagementObject (MyPath)

'Invoke the startservice method

DIM RETURNOBJECT As ManagementBaseObject = _

MyService.invokeMethod ("StartService", Nothing, _

Nothing)

You've seen how to examine the schema and also how to remotely execute methods on a managed class using WMI. In the next section, I describe how to add or extend the schema for your own applications and how to publish information to that schema extension .Instrumenting your application

Earlier you saw that the Management Extensions plug-in adds a Management Events node to the Server Explorer. Right now that node is empty, but I'm going to show you how to create your own custom WMI events and fire them from within your code . This process is known as Instrumenting and is fairly simple regardless of whether your application is ASP.NET-based or Windows Forms-based. An understanding of attributes is useful for this discussion but not essential. Attributes deserve their own article, but if you 'Ve Never Seen An Attribute Before, you can one.

In the COM days, it was necessary to create an entire extra class known as a WMI Provider to provide information to WMI. In the .NET world, we can achieve the same effect with much less effort. The first thing to do is tag your Assembly with the instructed attribute. i Typically Put this attribute in the assemblyinfo.vb file, but you can put it anywhere in the assembly's code.

This attribute will be read during installation, and the machine's schema will be modified to include the namespace from the instrumented tag-in this case, the root / HardcoreWMI namespace. If your application does not already have an installer class, it will be necessary To add one. if you don't want a ful-blown customized installation, the folload spnippet is all what's needed: _

Public Class SimpleInstaller

Inherits DefaultManagementProjectInstaller

END CLASS

To fire a custom event, you need a custom event class. All that's required to turn a class into a WMI event class is the InstrumentationType.Event Attribute. This attribute-driven approach makes it extremely simple to instrument your application.

_

Public Class HardcoreEvent

Public HardcoreMessage As String

Public MethodName As String

END CLASS

To Fire this Event, I use the folowing:

System.Management.instrumentation. _

Instrumentation.fire (MyEvent)

The demo code associated with this article provides a button that fires this event. In production code, you might consider firing the event from within your exception handler. Once the application is built, it's necessary to register that assembly's namespace within the schema. You do this by installing the assembly using the installUtil.exe provided with the .NET Framework. In a command window, navigate to your built assembly's folder and type installUtil to register your application with the schema.

Once an event is fired, it's available to any WMI capable application, including Microsoft Operations Manager or the Management Event node of Visual Studio. To capture these events in Studio, right-click on Management Events, click Add Event Query ..., and select Custom from the Event Type radio buttons. If you've run the installUtil as described earlier, you should see your application's node in the schema. If you expand the node, you'll see the custom event in the tree (see Figure 3 ) .Clicking OK will add an Event Query to your Visual Studio Server Explorer. When you run the demo and click Fire Custom Event, the Event Query will be triggered and print the event details to the output window.

The Event model in .NET uses delegates to allow multiple consumers for a single event. Your .NET code can consume these events synchronously by blocking until the event is fired, or asynchronously by using a ManagementEventWatcher (see Listing 4). You'll notice that since this is an asynchronous listener, I need to set up a delegate function to handle the event when it fires. in Listing 4, that function is called HandleEvent. The demo code for this article implements Listing 4 in a Windows Forms application.

Listing 4. Asynchronously Listen for Custom WMI Events.

Dim Wmilistener As New ManagementEventWatcher

'MyQuery Listens for HardcoreEvents to

'Fire Every 5 Seconds

DIM MyQuery As New WqleventQuery (_

"HardcoreEelent", New System.TimeSpan (5))

Wmilistener.Query = myQuery

'Set up a delegate to fire when the

'Event Arrives

AddHandler Wmilistener.eventarrived, _

Addressof Handleevent

Wmilistener.scope.path.server = "bulldog"

Wmilistener.scope.path.namespacepath = _ "root / hardcorewmi"

'Start listening

Wmilistener.start ()

The final piece of the puzzle is to publish entire classes to the schema. I've already shown how events can be published through the use of attributes. Entire classes can be published in the same manner.

_

Public Class HardcorebusinessObject

Private _firstname as string

In this Snippet I've Tagged My Class, HardcorebusinessObject, with the .instance attribute. You Can Now Publish This Class with:

Instrumentation.publish (Myentity)

myEntity is an instance of HardcoreBusinessObject You can test this mechanism through Visual Studio:. Right-click Management Classes and select Add Classes ..., and then choose your applications' node and expand it until you come to the instrumented class Click Add and. Ok. Now when the class is published to WMI, That Instances Available To The Server Explorer (See Figure 4).

The Sample Applications

The provided solution contains two projects, a Web application and a Windows Forms application. In each case you need to update the machine name to the machine you're monitoring. Do a search and replace to replace "BULLDOG" with your own machine name. From The Web Application You Can Do The Following:

. Execute a WQL query View statistics on the local machine through a generic dial type user control that indicates min, max, and current values ​​for a particular data point Publish an instance of a dummy business object-in this case, "HardcoreBusinessObject". - and view the published instance in Server Explorer. Start a service. The sample defaults to the SQLSERVER service, but you can enter any service name you'd like. Fire a custom event. you can verify the event has fired by building an Event Query as described earlier in this article.The Windows Forms application will listen asynchronously for the custom event to fire. Once it fires, the event data is retrieved from WMI and added to the list box on the form.

What this Article Hasn't Covered

This Article Has Only Scratched The Surface In Terms of What's Possible with WMI. Other AREAS of Interest Not Covered Here Are:

Integration with other WMI consumers, such as Microsoft Operations Manager. Using WMI will allow your application to integrate with Microsoft Operations Manager out of the box. Security and access to data, all of which is accounted for in the current WMI spec. Windows 2000 and above actually ship with an MMC snap-in to allow management of security privileges, logging, and backup of WMI data. Consumption of SNMP traps. SNMP traps can be consumed through the WMI interfaces in a similar manner to the mechanism shown here. See the "References" sidebar for a link that provides more detail about SNMP. Exposure of management data through Web Services. • The Enterprise Instrumentation Framework (EIF) from Microsoft. This framework is built on top of things like WMI, the Event Log, and Tracing TO Unify All of these Management Tools Into A Common Framework.conClusion

Hopefully this article has opened your eyes to the wealth of information that WMI provides. You've seen how to integrate WMI with Visual Studio and how to drag and drop management classes into your applications. Most importantly, I've shown you how to create your own WMI provider with management events and classes. with a little creativity you should be able to fully instrument your applications, thus allowing your administrator to stop and refuel next time before the server runs out of gas.

Download 404Shanahan.zip

Sidebar: References

The Microsoft Home Page of WMI-http: //msdn.microsoft.com/library/default.asp? URL = / library / en-us / dnanchor / html / anch_wmi.asp Diagnosis of "RPC Server IS Unavailable" ERRORS, WHICH you may encounter when connecting to other machines in Visual Studio .NET-http: //support.microsoft.com/default.aspx scid = kb; en-us; Q224370 Full list of operating system and WMI component availability-http:? / /msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/operating_system_availability_of_wmi_components.asp SNMP events-http: //msdn.microsoft.com/library/default.asp url =? /library/en-us/wmisdk/wmi/receiving_snmp_events.asp For more information on the DMTF and its direction-www.dmtf.orgTo find out more about Hardcore Visual Studio and Pinnacle Publishing, visit their Web site at http: // www .pinpub.com /

Note: this is not a Microsoft Corporation Web Site. Microsoft Is Not Responsible for ITS Content.

This article is reproduced from the April 2004 issue of Hardcore Visual Studio. Copyright 2004, by Pinnacle Publishing, Inc., unless otherwise noted. All rights are reserved. Hardcore Visual Studio is an independently produced publication of Pinnacle Publishing, Inc. No part of this article may be used or reproduced in any fashion (except in brief quotations used in critical articles and reviews) without prior consent of Pinnacle Publishing, Inc. To contact Pinnacle Publishing, Inc., please call 1-800-788-1900.

转载请注明原文地址:https://www.9cbs.com/read-114287.html

New Post(0)