Combine PowerShell and SQL Diagnostic Manager to Automate SQL Server Monitoring

by Apr 26, 2017

Categories

Tags

Administration agent-based monitoring Agentless Monitoring alert responses alert thresholds alerting Alerts Amazon Aurora Amazon EC2 Amazon RDS Amazon RDS / Aurora Amazon RDS for SQL Server Amazon Redshift Amazon S3 Amazon Web Services (AWS) Analytics application monitoring Aqua Data Studio automation availability Azure Azure SQL Database azure sql managed instance Azure VM backup Backup and recovery backup and restore backup compression backup status Backup Strategy backups big data Blocking bug fixes business architecture business data objects business intelligence business process modeling business process models capacity planning change management cloud cloud database cloud database monitoring cloud infrastructure cloud migration cloud providers Cloud Readiness Cloud Services cloud storage cloud virtual machine cloud VM clusters code completion collaboration compliance compliance audit compliance audits compliance manager compliance reporting conference configuration connect to database cpu Cross Platform custom counters Custom Views customer survey customer testimonials Dark Theme dashboards data analysis Data Analytics data architect data architecture data breaches Data Collector data governance data lakes data lineage data management data model data modeler data modeling data models data privacy data protection data security data security measures data sources data visualization data warehouse database database administration database administrator database automation database backup database backups database capacity database changes database community database connection database design database developer database developers database development database diversity Database Engine Tuning Advisor database fragmentation database GUI database IDE database indexes database inventory management database locks database management database migration database monitoring database navigation database optimization database performance Database Permissions database platforms database profiling database queries database recovery database replication database restore database schema database security database support database synchronization database tools database transactions database tuning database-as-a-service databases DB Change Manager DB Optimizer DB PowerStudio DB2 DBA DBaaS DBArtisan dBase DBMS DDL Debugging defragmentation Demo diagnostic manager diagnostics dimensional modeling disaster recovery Download drills embedded database Encryption End-user Experience entity-relationship model ER/Studio ER/Studio Data Architect ER/Studio Enterprise Team Edition events execution plans free tools galera cluster GDPR Getting Started Git GitHub Google Cloud Hadoop Healthcare high availability HIPAA Hive hybrid clouds Hyper-V IDERA IDERA ACE Index Analyzer index optimization infrastructure as a service (IaaS) infrastructure monitoring installation Integrated Development Environment interbase Inventory Manager IT infrastructure Java JD Edwards JSON licensing load test load testing logical data model macOS macros managed cloud database managed cloud databases MariaDB memory memorystorage memoryusage metadata metric baselines metric thresholds Microsoft Azure Microsoft Azure SQL Database Microsoft PowerShell Microsoft SQL Server Microsoft Windows MongoDB monitoring Monitoring Tools Monyog multiple platforms MySQL news newsletter NoSQL Notifications odbc optimization Oracle PeopleSoft performance Performance Dashboards performance metrics performance monitoring performance schema performance tuning personally identifiable information physical data model Platform platform as a service (PaaS) PostgreSQL Precise Precise for Databases Precise for Oracle Precise for SQL Server Precise Management Database (PMDB) product updates Project Migration public clouds Query Analyzer query builder query monitor query optimization query performance Query Store query tool query tuning query-level waits Rapid SQL rdbms real time monitoring Real User Monitoring recovery regulations relational databases Releases Reporting Reports repository Restore reverse engineering Roadmap sample SAP Scalability Security Policy Security Practices server monitoring Server performance server-level waits Service Level Agreement SkySQL slow query SNMP snowflake source control SQL SQL Admin Toolset SQL CM SQL code SQL coding SQL Compliance Manager SQL Defrag Manager sql development SQL Diagnostic Manager SQL Diagnostic Manager for MySQL SQL Diagnostic Manager for SQL Server SQL Diagnostic Manager Pro SQL DM SQL Doctor SQL Enterprise Job Manager SQl IM SQL Inventory Manager SQL Management Suite SQL Monitoring SQL Performance SQL Quality SQL query SQL Query Tuner SQL Safe Backup SQL script SQL Secure SQL Security Suite SQL Server sql server alert SQL Server Migration SQL Server Performance SQL Server Recommendations SQL Server Security SQL statement history SQL tuning SQL Virtual Database sqlmemory sqlserver SQLyog Storage Storage Performance structured data Subversion Support tempdb tempdb data temporal data Tips and Tricks troubleshooting universal data models universal mapping unstructured data Uptime Infrastructure Monitor user experience user permissions Virtual Machine (VM) web services webinar What-if analysis WindowsPowerShell

Run new and existing PowerShell scripts with SQL Diagnostic Manager and utilize the vast power of PowerShell via the customizable monitoring environment. Run scripts to automatically react to problems detected by the monitoring environment, deploy and manage the monitoring environment via cmdlets, connect existing scripts to the monitoring environment to automate their execution, and avoid writing certain scripts in the flexible yet simple monitoring solution.

What Is PowerShell?

Microsoft’s Windows PowerShell is a task-based command-line shell and scripting language. PowerShell is designed especially for system administration. PowerShell is becoming increasingly common as an automation tool for database administrators. Built on the .NET Framework, PowerShell controls and automates the management of the Windows operating system and the applications that run on Windows.

PowerShell provides an operating environment for commands that include cmdlets, functions, filters, scripts, aliases, and executables. SQL Diagnostic Manager provides cmdlets via its PowerShell provider and executes scripts via its PowerShell alert action provider.

PowerShell operates within a hosting application that exposes a command line to the user. It uses a host interface to communicate with the commands invoked by the command line. Utilize a console application, a Windows application, or a web application as the hosting application.

For more information, refer to Microsoft’s Developer Network – Documentation “Getting Started with Windows PowerShell”, Microsoft’s TechNet Library “Scripting with Windows PowerShell”, and Microsoft’s Script Center – Learn “Windows PowerShell Scripting”.

Automate SQL Diagnostic Manager Functions with PowerShell

SQL Diagnostic Manager provides a PowerShell action provider to execute scripts as the result of alerts. SQL Diagnostic Manager also provides a PowerShell snap-in to allow scripting of everyday activities (such as listing servers, managing monitored servers, listing active alerts, and managing application security of SQL Diagnostic Manager). Respond to alerts on SQL Server metrics, automate the deployment of SQL Diagnostic Manager, and customize the properties of monitored instances of SQL Server. Real world examples include enabling maintenance mode for all instances, create and apply monitoring templates, intensify monitoring activity, and decrease monitoring activity.

Respond to Alerts on SQL Server Metrics with PowerShell

With SQL Diagnostic Manager, automatically respond to alerts on SQL Server metrics by executing PowerShell scripts. Manage alert response rules and criteria via the action provider for PowerShell.

The PowerShell Action Provider in the Action Providers tab of the Alert Actions and Responses window of SQL Diagnostic Manager. The PowerShell Command Action window accessed from the Alert Response window of SQL Diagnostic Manager.

For more information, refer to SQL Diagnostic Manager’s product documentation “Configure Automated Responses to Alerts – PowerShell Action Provider”.

Automate the Deployment of SQL Diagnostic Manager with PowerShell

Automate the administration of the implementation of SQL Diagnostic Manager with PowerShell cmdlets. For instances of SQL Server, retrieve a list of instances on the network, add and remove instances to monitor in SQL Diagnostic Manager, configure the options on monitored instances, and specify server names containing special characters. For SQL Diagnostic Manager, manage permissions of SQL Diagnostic Manager on a server, control users of SQL Diagnostic Manager, toggle application security for SQL Diagnostic Manager, set the logging level of the provider of SQL Diagnostic Manager, and create a drive for connecting to the repository of SQL Diagnostic Manager.

For more information, refer to SQL Diagnostic Manager’s product documentation “PowerShell Cmdlets for SQL Diagnostic Manager”.

The output from PowerShell’s ‘Get-Help Escape-SQLdmName’ cmdlet in the PowerShell console.

Customize Properties of Monitored SQL Server Instances with PowerShell

Use PowerShell cmdlets to customize the properties of instances of SQL Server that are monitored by SQL Diagnostic Manager: Edit the general settings; customize the settings for the monitoring of queries, query waits, and activity; exclude applications, databases, and SQL statements from the monitoring of queries customize the settings for disabling of the collection of statistics on replication; customize the collection of statistics on tables; and customize the settings for maintenance mode.

Edit the general settings: For the collection of data, toggle the extended collection of data, and specify the frequency of the scheduled collection of data and the collection of statistics on databases. Set and clear friendly names for monitored instances, enable, define a value for, and disable the limiter for the input buffer, associate and disassociate tags to a server. For security, set the credentials for SQL Authentication, toggle the encryption of connections, and toggle the certificates for trust servers.

Customize the settings for the monitoring of queries: Toggle the monitoring of queries, enable using SQL Trace and Extended Events, toggle the collection of actual and estimated query plans, set up the thresholds for duration, logical disk reads, CPU usage and physical disk writes, and enable the capturing of SQL batches, SQL statements, stored procedures, and triggers.

Customize the settings for the monitoring of query waits: Toggle the collection of statistics on query waits, toggle using Extended Events, and set the collection to a specified time and duration and indefinitely.

Customize the settings for the monitoring of activity: Enable using SQL Trace and Extended Events, toggle capturing database autogrow and blocking, and set the threshold for blocking processes.

Customize the collection of statistics on tables: For collection during quiet time, specify the time of day, the days of the week, the minimum table size to collect reorganization statistics, and the list of databases to exclude.

Customize the settings for maintenance mode: Toggle maintenance mode, and set maintenance mode to recurring and one-time. For recurring maintenance mode, set the days of the week, the start time, and the length of time. For one-time maintenance mode, set the start and end date and time.

 

Refer also to the video “Using the SQL Diagnostic Manager PowerShell Snap-In”:

www.idera.com:443/…/SQL DM – Using the Powershell snap-in.mp4

 

For more information, refer to SQL Diagnostic Manager’s product documentation “Customize your Monitored SQL Server Properties within PowerShell”.