Skip to content
Documentation
Updated 14 minutes to read
Markdown

Gain full control over your SQL Server monitoring with the Nodinite Database Monitoring Agent. This page shows you how to leverage custom TSQL scripts for proactive monitoring, instant alerts, and self-service management—empowering both integration experts and business users.

✅ Monitor SQL Server health and business data using your own TSQL logic
✅ Instantly receive alerts and automate remediation with Remote Actions
✅ Empower self-service for business users to execute pre-defined scripts
✅ Centralize monitoring and management for all your SQL Server resources

A SQL Statement in Error with its THROW message as Log Text, then Show Action Scripts runs a script and shows its result set, animated walkthrough (7.12)
Animated walkthrough: the statement 'Contoso: Orders awaiting confirmation' is Error, and its THROW message is the Log Text. Details, then Show Action Scripts: Execute 'Show the orders awaiting confirmation', confirm, and read the seven orders in the result.

Automate your database monitoring and get alerts using your custom coded TSQL statements! Gain actionable insights and perform administrative tasks by executing pre-defined TSQL scripts—all from a single platform.

The Nodinite Database Monitoring Agent provides two major features for SQL Server:

  1. Monitoring – Get alerts from logic in custom-built TSQL statements
  2. Management – Allow end-users to execute pre-defined TSQL statements from one or more TSQL Script collections
graph TD subgraph "fal:fa-traffic-light-stop Monitoring" roAH(fal:fa-code Text/AdHoc) roSP(fal:fa-function Stored Procedures) end subgraph "fal:fa-wrench Management" ro1(fal:fa-boxes Execute TSQL Scripts on demand) end

Here's a visual overview of how monitoring and management features are organized in Nodinite.

To use the Monitoring feature, provide either Stored Procedures or Text/AdHoc TSQL statements. Implement your business logic using the examples on this page.

  • Text/AdHoc
  • Stored Procedures

New 7.13
A SQL Statement in the Nodinite Database Monitoring Agent is a group: one authentication (the connection string, and optionally impersonation) and a list of monitoring statements. Each enabled monitoring statement of an enabled SQL Statement is one Resource to manage, named after the monitoring statement's Display Name; the SQL Statement itself is not a Resource. Assign these Resources to one or more Monitor Views to trigger alerts according to the evaluated monitor state. Use the Nodinite Alarm Plugins to push alerts.

In the Monitor Views, the monitoring statements of Microsoft SQL Server share the SQL Statements Category, and their Application is the name of the SQL Server configuration.
A Monitor View with two monitoring statements, Contoso Failed Orders and Contoso Open Orders, both OK in the SQL Statements Category, each with its own Log Text (7.13)
Two monitoring statements of one SQL Statement, each its own Resource with its own Log Text: Failed orders: 0 and Open orders: 3.

graph LR subgraph "Configuration" c["fal:fa-code 1 SQL Statement"] --> m1["fal:fa-traffic-light Monitoring statement 1"] c --> m2["fal:fa-traffic-light Monitoring statement 2"] end m1 --> r1[fal:fa-lightbulb-on Resource 1] m2 --> r2[fal:fa-lightbulb-on Resource 2]

One SQL Statement holds the connection for any number of monitoring statements; each enabled monitoring statement is one Resource to monitor.

What are the key features for Monitoring SQL Statements?

Section titled “ What are the key features for Monitoring SQL Statements?”
  • State Evaluation – Monitor and evaluate the state based on your custom TSQL logic. See the TSQL/Stored procedure code examples further down in this guide.
  • Actions – Support for the execution of Remote Actions

The following monitoring states exist:

State Status Description Actions
🚫 Unavailable Resource not available Evaluation of the 'SQL Statement' is not possible either due to network or security-related problems Review the prerequisites
❌ Error Error state raised The SQL Statement is raising an exception to report that one or more major problems/errors exist Edit
⚠️ Warning Warning state raised The SQL Statement is raising a warning to report that one or more minor problems/errors exist Edit
✅ OK Online The SQL Statement is valid and reports that no problems exist Edit

A statement raises a state with THROW: state 1 is Error, state 2 is Warning, and the exception message becomes the Log Text, for example ERROR: 7 orders have waited more than an hour for their confirmation (limit 3). A statement that ends without an exception is OK. See the Text Example.

How do I add my custom coded TSQL Statements?

Section titled “ How do I add my custom coded TSQL Statements?”

The Database Monitoring Agent automatically monitors each configured SQL Statement. The Nodinite Administrator can add new and modify existing SQL Statements using the Remote Configuration dialogue for the Database Monitoring Agent

In the Remote Configuration, open the SQL Servers tab and expand the SQL Server Instance accordion. Each instance has the tabs General, Advanced, Backups, Jobs, Size checks, SSIS, and SQL Statements. Click the SQL Statements tab.
The SQL Statements tab of SQL Server Instance localhost in the Remote Configuration, with three SQL Statement entries (7.12)
The SQL Statements tab of an instance: one accordion per SQL Statement; a crossed-out entry is disabled.

The Nodinite Administrator can add new SQL Statements from the Remote Configuration dialogue, detailed in Add or manage a Monitoring Agent.

From the SQL Statements tab in the SQL Connection configuration, click the Add button.

You can add any number of SQL Statements. Make sure that each one executes quickly, or you may end up hogging the agent, resulting in timeouts.

The Remote Configuration of the Database agent with the SQL Statements tab of instance localhost and its Add button (7.12)
Example to add a new configuration for SQL Statements using the Add button.

Then, expand the accordion.
A collapsed SQL Statement accordion, Contoso: Orders awaiting confirmation (7.12)

The following tabs exist:

To manage the essential configuration, click on the accordion to expand the details:
General tab of SQL Statement Contoso Orders DB with Enabled, Display Name, and Description, next to the tabs Monitoring Statements (2), User Action Scripts (1), and Authentication (7.13)
The General tab of a SQL Statement; the tab names count its monitoring statements and action scripts.

You can manage the following properties:

  • Enabled – When checked, the monitoring statements of this SQL Statement are monitored. Clearing it removes the Resources of all its monitoring statements from the Monitor Views.
  • Display Name – The name of the SQL Statement. It must be unique for each SQL Statement configuration. The SQL Statement isn't a Resource; its monitoring statements are.
  • Description

New 7.13
Click the Monitoring Statements (n) tab to manage the statements this SQL Statement runs. Each monitoring statement has its own accordion; click Add for another one. All of them use the connection of the Authentication tab.
The Monitoring Statements (2) tab of SQL Statement Contoso Orders DB with the monitoring statements Contoso Open Orders and Contoso Failed Orders and the Add button (7.13)
The Monitoring Statements tab: one accordion per monitoring statement, and one Resource for each in the Monitor Views.

Add two monitoring statements to a new SQL Statement, save, and reload the configuration, animated walkthrough (7.13)
Animated walkthrough: on the SQL Statements tab of a SQL Server instance, Add a SQL Statement, enter its connection string, add the monitoring statements Contoso Open Orders and Contoso Failed Orders, and Save. After a reload, both are kept.

  1. On the SQL Statements tab of the SQL Server instance, click Add and give the SQL Statement a Display Name.
  2. On the Authentication tab, enter the Connection String.
  3. On the Monitoring Statements (0) tab, click Add once per monitoring statement and fill in its fields.
  4. Click Save.

Expand a monitoring statement to edit it:
A monitoring statement, Contoso Failed Orders, with Enabled, Display Name, Description, Command Type Text, and a SELECT as Execute Command (7.13)
One monitoring statement. Its Display Name is the Resource name in the Monitor Views.

  • Enabled – When checked, this monitoring statement is monitored.
  • Display Name – The name of the Resource in the Monitor Views. Required while the monitoring statement is enabled, and unique within the configuration, also across its SQL Statements.
  • Description – The user-friendly description of the Resource.
  • Command Type – The Type of 'SQL Command', select one of the following:
    • Text – For AdHoc TSQL Statements
    • Stored Procedure – For existing parameterless stored procedures
  • Execute Command – The SQL command(s) to execute. Required for each enabled monitoring statement of an enabled SQL Statement.

An enabled monitoring statement without a Display Name is marked red with Display Name is required, and the configuration isn't saved.
An enabled monitoring statement with an empty Display Name, marked red with Display Name is required (7.13)
The Display Name is required while the monitoring statement is enabled.

Two monitoring statements with the same Display Name in one configuration stop the save with 400 Configuration Error.
400 Configuration Error: Duplicate monitoring statement DisplayNames found for SQL Server localhost, make sure each monitoring statement DisplayName is unique within the configuration, also across its SQL Statements (7.13)
The error names the SQL Server configuration that holds the duplicate.

A SQL Statement from an earlier agent version, with its single command, is migrated once: the command becomes its first monitoring statement.

Execute one or more stored procedures in the SQL Server database provided by the connection string. For example, enter [YourCustomProcedure] or the full path.

[Database].[dbo].[YourCustomProcedure]

Here's an example of stored procedure call using a full path.

Add entries in the 'User Action Scripts' tab to allow your end-users to execute scripts on demand. The scripts belong to the SQL Statement: Show Action Scripts on any of its monitoring statements lists them, so a SQL Statement needs at least one enabled monitoring statement for its scripts to show in a Monitor View.
User Action Scripts (1) tab of SQL Statement Contoso Orders DB with the action script List open orders and the Add button (7.13)
Example of the User Action Scripts tab for on-demand script execution.

A SQL Statement may have any number of scripts.

Click the Add button to add a script.

Then, expand the accordion.
A collapsed action script accordion, Action: Show the orders awaiting confirmation (7.12)

You can then fill out the following properties:

  • Enabled – When checked, this SQL Action Script is visible in the end-user list of executable scripts
  • Display Name – The user-friendly name of this action script
  • Description – User-friendly description for this SQL Action Script
  • Command Type – The type of SQL command
    • Text
    • Stored Procedure
  • Execute Command – The SQL command to execute
    The action script List open orders with Enabled, Display Name, the Description The open orders per integration, Command Type Text, and a SELECT as Execute Command (7.13)
    Example of a script entry for on-demand execution.

New 6.2.0.0
Each SQL Statement runs with its own connection string, and can impersonate a domain user. All its monitoring statements and User Action Scripts use this one authentication.
Authentication tab of SQL Statement Contoso Orders DB with the masked Connection String, Use Impersonation checked, the Domain User CONTOSO svc-monitor, and the masked Password (7.13)
The Authentication tab: one connection for every monitoring statement of the SQL Statement.

  • Connection String – The connection string used by all monitoring statements of this SQL Statement. Required while the SQL Statement is enabled: the agent refuses to save an enabled SQL Statement without one (requires a connection string). A disabled SQL Statement can be saved without it.
    A disabled SQL Statement, marked with the ban icon, with an empty Connection String on its Authentication tab (7.13)
    A disabled SQL Statement (ban icon) may have an empty Connection String.
  • Use Impersonation – Run the statement as the domain user below. Required when the connection string uses Integrated Security; otherwise the agent refuses to save (uses Integrated Security in its connection string. Please enable 'Use Impersonation'...).
  • Domain User – The name of the Windows user account. Format: DOMAIN\User
  • Password – The password for the provided domain user

You must click 'Save' or 'Save and close' for changes to persist. The new settings/thresholds are evaluated on the next synchronization.
Save, Save and close, and Close buttons of the Remote Configuration dialog (7.12)
Here's an example of the Save options.

Save and close saves and closes the dialogue.
Close closes the dialogue without saving any changes.

The following Remote Actions are available in the Control Center part of the Action menu:

Action menu of the monitoring statement Contoso Open Orders with Details and Show Action Scripts under Control Center (7.13)
The Control Center part of the Action menu of a monitoring statement.

Click Details in the Action menu. The Details modal shows the Server, Database, and Application of the monitoring statement and an editable Description, with Save; it does not run the statement or show a result.
Details of the monitoring statement Contoso Open Orders with Server localhost, Database MSDB, Application localhost, and the saved Description Orders waiting for INT001: Orders (7.13)
The Details modal with a Description saved from the Monitor View.

You can execute pre-defined TSQL scripts and immediately see the result. The Nodinite Administrator manages the collection of scripts in the User Action Scripts tab.

Run the action script List open orders from the monitoring statement Contoso Open Orders: Action menu, Show Action Scripts, Execute and confirm, and the output table, animated walkthrough (7.13)
Animated walkthrough: open the Action menu of the monitoring statement Contoso Open Orders, click Show Action Scripts, Execute List open orders, confirm, and read the output table.

Click Show Action Scripts in the Action menu. The Action Scripts dialog lists the enabled scripts of the SQL Statement the monitoring statement belongs to, each with an Execute button; every monitoring statement of that SQL Statement offers the same scripts. A script runs with the SQL Statement's connection string.
Action Scripts dialog of Contoso Open Orders with the script List open orders and its Execute button (7.13)
The Action Scripts dialog of a monitoring statement.

Click Execute on a script and confirm the intent: Execute action? Are you sure you want to execute the SQL script '…'?
Execute action? confirmation for the SQL script Show the orders awaiting confirmation (7.12)
Confirmation dialog for script execution.

The result shows under Output from script name, with a Table and a Raw tab, a timestamp, the row count, and the duration.
Action Scripts dialog with Output from List open orders: a table with the row INT001: Orders and 3 open orders, the timestamp, the row count, and the duration (7.13)
The result of a script run on demand.


There are two ways to provide the outcome (Monitoring state of the Resource) based on the logic in your custom-built SQL Statements:

# Text/AdHoc Stored Procedure
1. Select + return code ❌ Not supported ✅ Supported
2. Select + throw (raiserror) ✅ Supported ✅ Supported

Use a supported implementation according to the use of either Text/AdHoc or Stored Procedures.

Internally, the Nodinite Database Monitoring Agent executes the Execute Scalar method. Nodinite picks up data from the first column from the first returned row. The extracted value is set as the Log Text unless you raised an exception.

The Log Text presented for the monitoring statement (the Resource) comes from your last SELECT statement (1st row, 1st column). If you do not select anything, the Log Text is empty.

Return Code Evaluated State LogText
= 0 OK From SELECT operation (1st column)
< 0 Error From SELECT operation (1st column)
> 0 Warning From SELECT operation (1st column)

The Log Text presented for the monitoring statement (the Resource) comes from your last SELECT statement (1st row, 1st column) or from the Exception. If you do not select anything, the Log Text is empty.

Return Code Evaluated State LogText
No exception raised OK From SELECT operation (1st column)
Throw exception with State = 1 Error From exception text
Throw exception with State > 1 Warning From exception text

Example of using the SQL Statement with Command Type set to Text. This example counts the rows in the actual table. Depending on your logic, different states can be returned.

DECLARE @rowCount INT,
@log VARCHAR(256),
@errorLimit INT = 3,
@warningLimit INT = 1
SELECT @rowCount = COUNT(1) FROM [ConnectionFailures]
IF (@rowCount > @errorLimit)
BEGIN
SET @log = 'ERROR Number of connection failures exceeded ' + CAST (@errorLimit AS VARCHAR(18));
THROW 51000, @log, 1;
END
ELSE IF (@rowCount > @warningLimit)
BEGIN
SET @log = 'WARNING number of connection failures exceeded ' + CAST (@warningLimit AS VARCHAR(18));
THROW 51000, @log, 2;
END
ELSE
BEGIN
SELECT 'OK'
END

Example of using the SQL Statement with Command Type set to Stored Procedure

[SP_CheckConnectionFailures]

Example of the Stored Procedure (existing in the actual database):

USE [MyDatabase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[SP_CheckConnectionFailures]
AS
BEGIN
SET NOCOUNT ON;
DECLARE @rowCount INT,
@errorLimit INT = 3,
@warningLimit INT = 1,
@ret INT = 0,
@log VARCHAR(256)
SELECT @rowCount = COUNT(1) from [dbo].[ConnectionFailures]
IF (@rowCount > @errorLimit)
BEGIN
SET @log = 'ERROR: The number of connection failures was exceeded: ' + CAST (@errorLimit AS VARCHAR(18));
SELECT @log
SET @ret = -10
END
ELSE IF (@rowCount> @warningLimit)
BEGIN
SET @log = 'WARNING: The number of connection failures was exceeded: ' + CAST (@warningLimit AS VARCHAR(18));
SELECT @log
SET @ret = 10
END
ELSE
BEGIN
SELECT 'OK'
END
RETURN @ret
END -- Procedure

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...