NT Performance Monitor Customizable COM Alerter


Home Page: http://www.OrbitDevelopment.com

Environment: Windows NT Server and Workstation 4.0

Problem

Companies do not have NT Monitorig systems to be able to determine, and notify engineering, when an NT Server resource gradually degrades, or become non-existing. There are tools available to do so, but they can become quite expensive.

If you are tired of your current monitoring system, like a phone call at 3:00am from your boss saying, "The server is down!", this tool is for you.

Goal

Find an easy low cost solution to resolve the problem. The solution must be cheap and effective, at the same time very customizable.

Solution

NT currently includes "NT Performance Monitor" (PerfMon). PerfMon allows users to see performance graphs on certain NT resources. It also allows users to set "Alerts" for the same NT resources that you can graphically monitor.

Adding an "Alert" allows you to "Run a Program on Alert". This is the basis for our solution. I have created a program called "PerfMonitorAlerter.exe". When setting an alert, you would use PerfMonitorAlerter as the program to run on any alert you set, for example:

PerfMonitorAlerter "Memory is running over 90 megabytes"

PerfMonitorAlerter process uses COM objects to process the alert message specified in its parameter text: "Memory is running over 90 megabytes".

Technology

When PerfMon triggers the alert, it will start PerfMonitorAlerter.exe program with the message ("Memory is running over 90 megabytes") as it fisrt parameter.

PerfMonitorAlerter.exe will check registry path store at

       HKEY_LOCAL_MACHINE\\SOFTWARE\\www.OrbitDevelopment.com\\PerfMonitorAlerter


for any COM CLSIDs that implement a common interface, IAlertInterface:

    import "oaidl.idl";
    import "ocidl.idl";
	[
		object,
		uuid(B6C11879-3003-11D3-9257-00104BF7F161),
	
		helpstring("IAlertInterface Interface"),
		pointer_default(unique)
	]
	interface IAlertInterface : IUnknown
	{
		[helpstring("method EmergencyAlert")] HRESULT EmergencyAlert([in] BSTR bAlertName);
	};

In this code example case, PerfMonitorAlerter.exe will:

  • Create an instance of object "{B6C1187A-3003-11D3-9257-00104BF7F161}".
  • Query Interface IAlertInterface
  • Call method pIAlertInterface ->EmergencyAlert("Memory is running over 90 megabytes" )
  • Release the object

        : : : : : : : : : : : : 
        : : : : : : : : : : : : 
		
        // Registry COM Iterator

        while ( TRUE )    
        {
            char  szSubkey[ 64 ];
            DWORD cbSubkeySize = 64;
            CLSID clsidAlerter;
            BSTR  bstrCLSIDFromReg = NULL;

            if ( ERROR_NO_MORE_ITEMS == ::RegEnumKeyEx( regKey, regEnumIndex++, szSubkey, &cbSubkeySize, 0, 0, 0, 0 ) )            
                break;

            // Convert to BSTR, the convert it CLSID
            bstrCLSIDFromReg = charToBstr(szSubkey);
            ::CLSIDFromString(bstrCLSIDFromReg, &clsidAlerter); 
            if (bstrCLSIDFromReg) ::SysFreeString(bstrCLSIDFromReg);

            // Create object to notify
            if ( (bstrServiceName != NULL) && S_OK == ::CoCreateInstance( clsidAlerter, NULL, CLSCTX_INPROC_SERVER, IID_IAlertInterface, (void**) &pIAlertInterface )) 
            {
                // Send Alert
                pIAlertInterface->EmergencyAlert(bstrServiceName);
            }

            // Cleanup/Release the object
            if (pIAlertInterface) pIAlertInterface->Release();
        }

        : : : : : : : : : : : : 
This architecture will allow create one, or many, COM object to be notified, without concern for implementation details. The COM objects implementing IAlertInterface may send emails, log entries, call a pager, etc..

Although this is not the answer to all NT monitoring problems, it is an easy, customizable and powerful approach using COM communication technology.

Documentation Note

For detailed documentation (Word document), please feel free to contact me

Downloads

Download PerfMonitorAlerter application - 14 kb
Download source - 8 Kb


Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

  • Download the Information Governance Survey Benchmark Report to gain insights that can help you further establish business value in your Records and Information Management (RIM) program and across your entire organization. Discover how your peers in the industry are dealing with this evolving information lifecycle management environment and uncover key insights such as: 87% of organizations surveyed have a RIM program in place 8% measure compliance 64% cannot get employees to "let go" of information for …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds