WhatsUp Professional - How to add a new diagnostic to the System Diagnostic Report

Product: Version: Platform:
WhatsUp Professional 2006 Win2000,Win2003,XP SP1+

Question/Problem: I want to add custom diagnostic tests to the "System Diagnostic" report (SystemDiagnostic.asp).

Answer/Solution: Adding a custom Diagnostic is a three-step process. First, you determine which type of Diagnostic you want. Second, you create an XML text representing your diagnostic test. Third, you insert a row containing that XML text into a database table.

Step 1 - Determining the Diagnostic type

WhatsUp Professional 2006 supports several types of Diagnostics, as represented by the value in the 'nDiagnosticType' column of the 'Diagnostic' table. However, you can add custom diagnostics only for the following types:

nDiagnosticType

Name

Description

1

WUP-DB

These are SQL "SELECT" statements made against tables in the WhatsUp Pro database. This type of Diagnostic can check the number of Devices you are monitoring, for example, or the number of rows in a log table.

 

2

Registry

These read values from specific keys in the Registry. This type of Diagnostic can determine if a WhatsUp Pro setting is in the correct range; for example, that you are keeping PassiveMonitorActivityLog rows for a very long time.

 

3

Spdboption

Executes options using the sp_dboption SQL Server stored procedure.

 

4

Spconfigure

Executes options using the sp_configure SQL Server stored procedure.

 

6

RegFileExists

Reads a value from a specified location in the Registry, and checks that the value, which must be a fully-qualified pathname, actually exists.

 

7

WmiRaw

Executes 'raw' WMI performance counter checks.

 

8

WmiCooked

Executes 'formatted' WMI performance counter checks.

 

Step 2 - Creating the XML text

Although helpful, no knowledge of XML is necessary to complete this step. The XML text required is very simple, consisting of one element, which can have two or more attributes. Which attributes are used depending on the type of the Diagnostic. For example:

WUP-DB - The 'sSelect' attribute is required, and at least one of the 'Comparison' attributes.

 

Registry - The 'sHive', 'sKey', and 'sValue' attributes are required, and at least one of the 'Comparison ' attributes.

 

Comparison - At least one of these must be specified for any Diagnostic: 'sMin' is the minimum desired value; 'sMax' is the maximum desired value; 'sNE' is the value it cannot be; and 'sEQ' is the value it must be.

The format of the WUP-DB type XML text is:

<Diagnostic

sSelect="SELECT COUNT(*) AS sData FROM {YOUR CODE HERE}"

{sAttr}="{YOUR VALUE HERE}"

/>

 

 

So, for example, this represents a Diagnostic that will fail if more than 50 Devices are being monitored:

<Diagnostic sSelect="SELECT COUNT(*) AS sData FROM Device WHERE ISNULL(bRemoved,0) = 0" sMax="50" />

 

 

The format of the Registry type XML text is:

<Diagnostic

sHive="{YOUR HIVE HERE}"

sKey="{YOUR KEY HERE}

sValue="{YOUR VALUE HERE}"

{sAttr}={YOUR COMPARISON VALUE HERE}"

/>

 

 

So, for example, this represents a Diagnostic that will fail if the specified Registry key is equal to zero:

<Diagnostic sHive="HKLM" sKey="SOFTWARE\\Ipswitch\\Network Monitor\\WhatsUp Engine\\2005\\Database Settings\\Log Expiration Settings" sValue="General Error Log Expiration Time Limit (Hours)" sNE="0" />

 

 

XML for the other Diagnostic types can be easily copied from existing rows, and then modified to fit your purposes.

 

Step 3 - Inserting a row to the database

To create the Diagnostic, you must now insert a row into the 'Diagnostic' table. The columns you will have to provide values for are:

 

        sDisplayName - The visible name for this Diagnostic.

        nDiagnosticType - For example, '1' for WUP-DB, or '2' for Registry, etc.

        bEnabled - Either '1' to enable this Diagnostic, or '0' to disable it.

        sCommandXml - The XML text you created in Step 2, above.

        sInformation - Details of how the user should address a failure of this Diagnostic.

 

 

Here are the values that could be used for our WUP-DB example:

 

        sDisplayName - 'My Custom Diagnostic'

 

        nDiagnosticType - 1

 

        bEnabled - 1

 

        sCommandXml - <Diagnostic sSelect="SELECT COUNT(*) AS sData FROM Device WHERE ISNULL(bRemoved,0) = 0" sMax="50" />

 

        sInformation - 'You have too many Devices. Consider deleting a few.'

 

 

And here are the values that could be used for our Registry example:

 

        sDisplayName - 'My Other Custom Diagnostic'

 

        nDiagnosticType - 2

 

        bEnabled - 1

 

        sCommandXml - <Diagnostic sHive="HKLM" sKey="SOFTWARE\\Ipswitch\\Network Monitor\\WhatsUp Engine\\2005\\Database Settings\\Log Expiration Settings" sValue="General Error Log Expiration Time Limit (Hours)" sNE="0" />

 

        sInformation - 'This Registry setting is wrong. Use RegEdit to fix it.'

 

 

Given the values to be used, there are several ways to add a row to the Diagnostic table. For example, Microsoft Access or SQL Query Analyzer allow you to enter the data directly into the table using a 'grid' format. Or, you can create a SQL script in Notepad, and then run the script from the DOS command line. Here is the SQL script that could be used for our WUP-DB example (saved to a file name, in this example, "Diag.sql":

 

INSERT INTO Diagnostic

(sDisplayName,

nDiagnosticType,

bEnabled,

sCommandXml,

sInformation)

VALUES

('My Custom Diagnostic',

1,

1,

'<Diagnostic sSelect="SELECT COUNT(*) AS sData FROM Device WHERE ISNULL(bRemoved,0) = 0" sMax="50" />',

'You have too many Devices. Consider deleting a few.')

 

 

And here is the SQL script that could be used for our Registry example (saved to a file name, in this example, "Diag.sql":

 

INSERT INTO Diagnostic

(sDisplayName,

nDiagnosticType,

bEnabled,

sCommandXml,

sInformation)

VALUES

('My Other Custom Diagnostic',

2,

1,

'<Diagnostic sHive="HKLM" sKey="SOFTWARE\\Ipswitch\\Network Monitor\\WhatsUp Engine\\2005\\Database Settings\\Log Expiration Settings" sValue="General Error Log Expiration Time Limit (Hours)" sNE="0" />',

'This Registry setting is wrong. Use RegEdit to fix it.')

 

 

To execute either of these scripts from a DOS prompt, simply say:

 

osql -E -D WhatsUp -i diag.sql

 

 

 

Notes

 

Note that the 'sInformation' column can contain HTML code. This can be useful to create links to, for example, a company intranet page. For example:

 

'You have too many Devices. Consider deleting a few.<br><br><a href="http://www.ipswitch.com">Ipswitch Web Site</a>'

 

 

To set up the System Diagnostic report as a "Recurring Report", use this URL in the WhatsUp Pro Console application:

 

http://localhost/NmConsole/Reports/SystemDiagnostic.asp?Execute=true

 

 

To disable a given Diagnostic, simply set its 'bEnabled' flag to zero. In SQL, for example:

 

UPDATE Diagnostic

SET bEnabled = 0

WHERE sDisplayName = 'Device Table Count'

Document #:   Revision Date:
WP-20051108-DM03   11/08/05

Return To KnowledgeBase Search Page