Running Diagnostic TSQL scripts remotely within and without SCOM- 1

Requirement:
To be able to run a generic diagnostic information gathering script remotely via System Center Operations Manager on a SQL Server instance without having to start a separate session of SSMS and / or RDP and executing script.

There are quite a few well tested and trusted TSQL scripts available developed by MVPs and SQL experts like Glenn Berry, Brent Ozar and many others which helps in fixing problems with SQL Servers.

SQL Server Management Pack provides a fix number of tasks that can be performed against database instances and databases. While they are great you might want to be able to execute your own custom scripts or by the industry and community experts like the ones mentioned earlier.

So here is one of the ways to extend the SQL monitoring and diagnostics functionality within SCOM, the principals of which can be applied to non SCOM scenario which I will try cover in a separate post.

High level overview of the process:
Amend the script in a way that it can be run with a single execution attempt i.e. by pressing F5 if pasted in SSMS connected to an instance i.e. the script should have

  1. Create script steps for main stored procedure and / or dependencies
    • execution
    • cleanup (if required).
  2. Save the script in  .sql file
  3. Get some understanding and of SQLCMD the command line connection tool for SQL Server.
  4. Create a DOS batch file with command line parameter for full instance path
  5. Save the batch file .bat and .sql file in a read only shared for all network location that can be universally accessed.
  6. Create a SCOM Task in the context of the SQL Database engine and pass full instance path to the batch file.
  7. Test execution on least priority or own servers from SCOM.

Now lets take a deeper dive. For practical demonstration I will use the Sp_Blitz script by Brent Ozar

To be continued…

 

 

 

 

 

 

Advertisements
About

IT professional with wider interest in technology

Tagged with: , , , ,
Posted in Development, Monitoring, SCOM, sql, SQL Server, tsql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: