move server report ext to extensions (#14087)
* move server report ext to extensions * limit the size of data * comments
1
extensions/server-report/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.vsix
|
||||
6
extensions/server-report/.vscodeignore
Normal file
@@ -0,0 +1,6 @@
|
||||
*.vsix
|
||||
src/**
|
||||
.gitignore
|
||||
**/*.ts
|
||||
**/*.map
|
||||
.gitignore
|
||||
17
extensions/server-report/CHANGELOG.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Change Log
|
||||
|
||||
## v1.5?
|
||||
* Add VDI_CLIENT_OTHER to the ignore list in the script used by the wait counts widget
|
||||
|
||||
## v1.4?
|
||||
* Add PREEMPTIVE_OS_FLUSHFILEBUFFERS to the ignore list in the script used by the wait counts widget
|
||||
|
||||
## v1.3?
|
||||
* Changed the stored procedure call to work on case sensitive instances
|
||||
|
||||
## v1.2?
|
||||
* Created left nav bar and added 2 categories for insight widgets: monitor and performance
|
||||
|
||||
## v1.1?
|
||||
* Fixed DB Space Usage where it threw an error when database names contain special characters
|
||||
* Changed DB Space Usage and DB Buffer Usage to show only top 10 data
|
||||
62
extensions/server-report/README.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# Server Reports for Azure Data Studio
|
||||
|
||||
Welcome to **Server Reports** for Azure Data Studio! Server Reports give useful insights about the server related to performance. These can be used to see current activity as well as historical activity. Here is a list of some of the available reports.
|
||||
|
||||
* DB Space Usage
|
||||
* DB Buffer Usage
|
||||
* CPU Utilization
|
||||
* Backup Growth Trend
|
||||
* Wait counts
|
||||
|
||||
<img src="https://github.com/Microsoft/azuredatastudio/raw/main/samples/serverReports/images/server_reports.png" alt="Server Reports" style="width:480px;"/>
|
||||
|
||||
This extension is inspired by SQL Server Management Studio (SSMS)'s reports. We will continually add more useful server insights and tasks.
|
||||
|
||||
## Building your own reports
|
||||
This extension is also useful as a sample dashboard extension. It demonstrates building a dedicated dashboard extension with a set of insights built in. You can get started building your own reports by following the [extension authoring guide].
|
||||
|
||||
See the [Server Reports Extension Project] in the Azure Data Studio repository on Github for the extension source code.
|
||||
|
||||
[Server Reports Extension Project]:https://github.com/Microsoft/azuredatastudio/tree/main/samples/serverReports
|
||||
[extension authoring guide]:https://github.com/Microsoft/azuredatastudio/wiki/Getting-started-with-Extensibility
|
||||
|
||||
|
||||
## Contributions and "thank you"
|
||||
Special thanks to our Microsoft MVPs for providing useful queries.
|
||||
* Paul Randal:
|
||||
https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/
|
||||
|
||||
See [Paul Randal's wait types library] for more information about each wait type in the Wait Counts widget.
|
||||
|
||||
[Paul Randal's wait types library]:https://www.sqlskills.com/help/waits
|
||||
|
||||
* Glenn Berry: https://gallery.technet.microsoft.com/scriptcenter/All-Databases-Data-log-a36da95d
|
||||
|
||||
* Aaron Bertrand: https://www.mssqltips.com/sqlservertip/2393/determine-sql-server-memory-use-by-database-and-object/
|
||||
|
||||
|
||||
We would like to thank all our users who raised issues, and in particular the following users who helped contribute fixes:
|
||||
* flyfishingdba for Add square brackets for ms_foreachdb call (#1023)
|
||||
* Peter-Schneider for Changed the stored procedure call to work on case sensitive instances (#1809)
|
||||
|
||||
## What's new in Server Reports v1.5?
|
||||
* Add VDI_CLIENT_OTHER to the ignore list in the script used by the wait counts widget
|
||||
|
||||
## What's new in Server Reports v1.4?
|
||||
* Add PREEMPTIVE_OS_FLUSHFILEBUFFERS to the ignore list in the script used by the wait counts widget
|
||||
|
||||
## What's new in Server Reports v1.3?
|
||||
* Changed the stored procedure call to work on case sensitive instances
|
||||
|
||||
## What's new in Server Reports v1.2?
|
||||
* Created left nav bar and added 2 categories for insight widgets: monitor and performance
|
||||
|
||||
## What's new in Server Reports v1.1?
|
||||
* Fixed DB Space Usage where it threw an error when database names contain special characters
|
||||
* Changed DB Space Usage and DB Buffer Usage to show only top 10 data
|
||||
|
||||
## How to produce an extension installation package
|
||||
Run the following commands sequentially in the context of this directory:
|
||||
- `yarn install` - to install the dependencies
|
||||
- `yarn build` - to build the code
|
||||
- `vsce package` - to produce an extension installation package
|
||||
BIN
extensions/server-report/images/extension.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
extensions/server-report/images/server_reports.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
1
extensions/server-report/images/server_reports.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 18 18"><defs><style>.cls-1{fill:url(#linear-gradient);}.cls-2{fill:url(#linear-gradient-2);}.cls-3{fill:#fff;}.cls-4{fill:#c3f1ff;}.cls-5{fill:#50e6ff;}.cls-6{fill:#9cebff;}</style><linearGradient id="linear-gradient" x1="12.282" y1="11.436" x2="12.282" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#005ba1"/><stop offset="0.525" stop-color="#0074cd"/><stop offset="1" stop-color="#0078d4"/></linearGradient><linearGradient id="linear-gradient-2" x1="7.923" y1="18" x2="7.923" y2="3.129" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0078d4"/><stop offset="0.16" stop-color="#1380da"/><stop offset="0.53" stop-color="#3c91e5"/><stop offset="0.82" stop-color="#559cec"/><stop offset="1" stop-color="#5ea0ef"/></linearGradient></defs><rect class="cls-1" x="6.564" width="11.436" height="11.436" rx="1"/><rect class="cls-2" y="3.129" width="15.846" height="14.871" rx="1"/><path class="cls-3" d="M9.31,7.449V4.311H8.48V8.123h2.27V7.449ZM2.72,5.908a1.722,1.722,0,0,1-.471-.286.405.405,0,0,1-.11-.3.313.313,0,0,1,.138-.277.63.63,0,0,1,.388-.11,1.5,1.5,0,0,1,.923.267V4.413a2.382,2.382,0,0,0-.923-.148,1.514,1.514,0,0,0-1.006.314,1,1,0,0,0-.388.821c0,.471.3.84.923,1.117a2.634,2.634,0,0,1,.572.332.39.39,0,0,1,.139.3.351.351,0,0,1-.148.286.747.747,0,0,1-.415.1,1.533,1.533,0,0,1-1.006-.387V8a2.01,2.01,0,0,0,.987.222,1.735,1.735,0,0,0,1.089-.3.994.994,0,0,0,.305-.84.972.972,0,0,0-.231-.646A2.227,2.227,0,0,0,2.72,5.908ZM7.557,7.375a2.16,2.16,0,0,0,.3-1.163,2.145,2.145,0,0,0-.3-.978,1.671,1.671,0,0,0-.646-.692,1.846,1.846,0,0,0-.923-.24,1.942,1.942,0,0,0-1,.249,1.717,1.717,0,0,0-.674.683,2.27,2.27,0,0,0-.24,1.052,2.094,2.094,0,0,0,.221.923,1.627,1.627,0,0,0,.637.683,1.9,1.9,0,0,0,.923.277l.794.923H7.769L6.634,8.077A1.654,1.654,0,0,0,7.557,7.375Zm-.923-.23a.871.871,0,0,1-.7.323.846.846,0,0,1-.7-.333,1.4,1.4,0,0,1-.268-.923,1.412,1.412,0,0,1,.268-.923.921.921,0,0,1,.72-.341.8.8,0,0,1,.692.341,1.5,1.5,0,0,1,.249.923A1.353,1.353,0,0,1,6.634,7.145Z"/><rect class="cls-4" x="10.218" y="11.745" width="1.729" height="5.088" rx="0.278"/><rect class="cls-5" x="12.677" y="9.248" width="1.729" height="7.584" rx="0.278"/><rect class="cls-6" x="7.758" y="10.374" width="1.729" height="6.458" rx="0.278"/></svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
395
extensions/server-report/package.json
Normal file
@@ -0,0 +1,395 @@
|
||||
{
|
||||
"name": "server-report",
|
||||
"displayName": "Server Reports",
|
||||
"description": "Server Reports",
|
||||
"version": "0.2.3",
|
||||
"publisher": "Microsoft",
|
||||
"preview": true,
|
||||
"engines": {
|
||||
"vscode": "^1.26.0",
|
||||
"azdata": "*"
|
||||
},
|
||||
"icon": "images/extension.png",
|
||||
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
|
||||
"repository": "https://github.com/Microsoft/azuredatastudio",
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"*"
|
||||
],
|
||||
"main": "./out/extension",
|
||||
"forceReload": true,
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "tempdb.startEvent",
|
||||
"title": "Start",
|
||||
"icon": {
|
||||
"light": "./out/media/launch.svg",
|
||||
"dark": "./out/media/launch_inverse.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "tempdb.stopEvent",
|
||||
"title": "Stop",
|
||||
"icon": {
|
||||
"light": "./out/media/blocker.svg",
|
||||
"dark": "./out/media/blocker_inverse.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "tempdb.contention",
|
||||
"title": "Contention Help for Tempdb",
|
||||
"icon": {
|
||||
"light": "./out/media/documentation.svg",
|
||||
"dark": "./out/media/documentation_inverse.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "tempdb.pauseEvent",
|
||||
"title": "Toggle Auto Refresh",
|
||||
"icon": {
|
||||
"light": "./out/media/insights.svg",
|
||||
"dark": "./out/media/insights_inverse.svg"
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration": [],
|
||||
"views": {},
|
||||
"menus": {},
|
||||
"dashboard.tabs": [
|
||||
{
|
||||
"id": "Server-Reports",
|
||||
"title": "Server Reports",
|
||||
"description": "This extension shows useful reports for a server.",
|
||||
"icon": "images/server_reports.svg",
|
||||
"group": "monitoring",
|
||||
"container": {
|
||||
"nav-section": [
|
||||
{
|
||||
"id": "server-reports-monitoring",
|
||||
"title": "Monitor",
|
||||
"icon": {
|
||||
"light": "./out/media/monitor.svg",
|
||||
"dark": "./out/media/monitor_inverse.svg"
|
||||
},
|
||||
"container": {
|
||||
"server-reports-monitoring-container": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "server-reports-performance",
|
||||
"title": "Performance",
|
||||
"icon": {
|
||||
"light": "./out/media/performance.svg",
|
||||
"dark": "./out/media/performance_inverse.svg"
|
||||
},
|
||||
"container": {
|
||||
"server-reports-performance-container": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "server-reports-tempdb-tab",
|
||||
"title": "TempDB",
|
||||
"group": "monitoring",
|
||||
"description": "TempDB reports",
|
||||
"icon": {
|
||||
"light": "./out/media/tempdb.svg",
|
||||
"dark": "./out/media/tempdb_inverse.svg"
|
||||
},
|
||||
"container": {
|
||||
"server-reports-tempdb-container": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"dashboard.insights": [
|
||||
{
|
||||
"id": "extension-dbspace-usage",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"horizontalBar": {
|
||||
"dataDirection": "vertical",
|
||||
"dataType": "number",
|
||||
"legendPosition": "top",
|
||||
"labelFirstColumn": false,
|
||||
"columnsAsLabels": true
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/all_db_space_used.sql"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "extension-cpu-utilization",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"timeSeries": {
|
||||
"dataDirection": "horizontal",
|
||||
"dataType": "point",
|
||||
"legendPosition": "top",
|
||||
"labelFirstColumn": false,
|
||||
"columnsAsLabels": false
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/cpumetric.sql"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "extension-backup-growth-trend",
|
||||
"details": "Abbie wants it",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"timeSeries": {
|
||||
"dataDirection": "horizontal",
|
||||
"dataType": "point",
|
||||
"legendPosition": "none",
|
||||
"labelFirstColumn": false,
|
||||
"columnsAsLabels": false
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/backup_size_trend.sql"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "extension-wait-counts-by-Paul-Randal",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"horizontalBar": {
|
||||
"dataDirection": "vertical",
|
||||
"dataType": "number",
|
||||
"legendPosition": "none",
|
||||
"labelFirstColumn": false,
|
||||
"columnsAsLabels": true
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/waits_paul_randal.sql",
|
||||
"details": {
|
||||
"queryFile": "./out/sql/waits_detail_paul_randal.sql",
|
||||
"label": {
|
||||
"column": "WaitType",
|
||||
"state": []
|
||||
},
|
||||
"value": "Percentage"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "extension-wait-resource-statistics",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"bar": {
|
||||
"dataDirection": "horizontal",
|
||||
"dataType": "number",
|
||||
"legendPosition": "none",
|
||||
"labelFirstColumn": false,
|
||||
"columnsAsLabels": true
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/wait_resources.sql",
|
||||
"details": {
|
||||
"queryFile": "./out/sql/wait_resources.sql",
|
||||
"label": {
|
||||
"column": "WaitType",
|
||||
"state": []
|
||||
},
|
||||
"value": "Percentage"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "extension-dbbuffer-usage",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"horizontalBar": {
|
||||
"dataDirection": "vertical",
|
||||
"dataType": "number",
|
||||
"legendPosition": "top",
|
||||
"labelFirstColumn": false,
|
||||
"columnsAsLabels": true
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/memorybydb.sql"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "type-of-contention",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"bar": {
|
||||
"dataDirection": "vertical",
|
||||
"columnsAsLabels": true,
|
||||
"labelFirstColumn": false,
|
||||
"legendPosition": "none"
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/typeofContentions.sql",
|
||||
"autoRefreshInterval": 0.05
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "metadata-contention",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"bar": {
|
||||
"dataDirection": "vertical",
|
||||
"columnsAsLabels": true,
|
||||
"labelFirstColumn": false,
|
||||
"legendPosition": "none",
|
||||
"xAxisLabel": "Object Ids for System Tables"
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/metadataContention.sql",
|
||||
"autoRefreshInterval": 0.05
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "allocation-contention",
|
||||
"contrib": {
|
||||
"type": {
|
||||
"bar": {
|
||||
"dataDirection": "vertical",
|
||||
"columnsAsLabels": true,
|
||||
"labelFirstColumn": false,
|
||||
"legendPosition": "none",
|
||||
"xAxisLabel": "Page Types"
|
||||
}
|
||||
},
|
||||
"queryFile": "./out/sql/allocationContention.sql",
|
||||
"autoRefreshInterval": 0.05
|
||||
}
|
||||
}
|
||||
],
|
||||
"dashboard.containers": [
|
||||
{
|
||||
"id": "server-reports-monitoring-container",
|
||||
"container": {
|
||||
"widgets-container": [
|
||||
{
|
||||
"name": "Top 10 DB Space Usage",
|
||||
"gridItemConfig": {
|
||||
"sizex": 2,
|
||||
"sizey": 2
|
||||
},
|
||||
"widget": {
|
||||
"extension-dbspace-usage": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Top 10 DB Buffer Usage",
|
||||
"gridItemConfig": {
|
||||
"sizex": 2,
|
||||
"sizey": 2
|
||||
},
|
||||
"widget": {
|
||||
"extension-dbbuffer-usage": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "CPU Utilization",
|
||||
"gridItemConfig": {
|
||||
"sizex": 2,
|
||||
"sizey": 1
|
||||
},
|
||||
"widget": {
|
||||
"extension-cpu-utilization": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Backup Growth Trend",
|
||||
"gridItemConfig": {
|
||||
"sizex": 2,
|
||||
"sizey": 1
|
||||
},
|
||||
"widget": {
|
||||
"extension-backup-growth-trend": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "server-reports-performance-container",
|
||||
"container": {
|
||||
"widgets-container": [
|
||||
{
|
||||
"name": "Wait Counts by Paul Randal",
|
||||
"gridItemConfig": {
|
||||
"sizex": 2,
|
||||
"sizey": 2
|
||||
},
|
||||
"widget": {
|
||||
"extension-wait-counts-by-Paul-Randal": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "server-reports-tempdb-container",
|
||||
"container": {
|
||||
"widgets-container": [
|
||||
{
|
||||
"name": "Tasks",
|
||||
"widget": {
|
||||
"tasks-widget": [
|
||||
"tempdb.startEvent",
|
||||
"tempdb.contention",
|
||||
"tempdb.pauseEvent",
|
||||
"tempdb.stopEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Overall Contention",
|
||||
"gridItemConfig": {
|
||||
"sizex": 2,
|
||||
"sizey": 1
|
||||
},
|
||||
"widget": {
|
||||
"type-of-contention": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Metadata Contention",
|
||||
"gridItemConfig": {
|
||||
"sizex": 2,
|
||||
"sizey": 1
|
||||
},
|
||||
"widget": {
|
||||
"metadata-contention": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Allocation Contention",
|
||||
"gridItemConfig": {
|
||||
"sizex": 2,
|
||||
"sizey": 1
|
||||
},
|
||||
"widget": {
|
||||
"allocation-contention": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"snippets": []
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^8.1.0",
|
||||
"handlebars": "^4.5.3",
|
||||
"openurl": "^1.1.1",
|
||||
"vscode-nls": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "8.1.0"
|
||||
},
|
||||
"__metadata": {
|
||||
"id": "12",
|
||||
"publisherDisplayName": "Microsoft",
|
||||
"publisherId": "Microsoft"
|
||||
}
|
||||
}
|
||||
17
extensions/server-report/src/constants.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
// TempDB Messages
|
||||
export const XEventsFailed = localize('XEventsFailed', 'XEvents operation failed.');
|
||||
export const XEventsStarted = localize('XEventsStarted', 'XEvents sessions started for PageContention and ObjectContention.');
|
||||
export const XEventsNotSupported = localize('XEventsNotSupported', 'XEvents sessions not supported.');
|
||||
export const XEventsStopped = localize('XEventsStopped', 'XEvents sessions PageContention and ObjectContention removed.');
|
||||
// CONFIG VALUES ///////////////////////////////////////////////////////////
|
||||
export const extensionConfigSectionName = 'server-reports';
|
||||
export const configLogDebugInfo = 'logDebugInfo';
|
||||
25
extensions/server-report/src/controllers/controllerBase.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export default abstract class ControllerBase implements vscode.Disposable {
|
||||
protected _context: vscode.ExtensionContext;
|
||||
|
||||
public constructor(context: vscode.ExtensionContext) {
|
||||
this._context = context;
|
||||
}
|
||||
|
||||
abstract activate(): Promise<boolean>;
|
||||
|
||||
abstract deactivate(): void;
|
||||
|
||||
public dispose(): void {
|
||||
this.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
70
extensions/server-report/src/controllers/mainController.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as Utils from '../utils';
|
||||
import ControllerBase from './controllerBase';
|
||||
import { promises } from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as constants from '../constants';
|
||||
|
||||
/**
|
||||
* The main controller class that initializes the extension
|
||||
*/
|
||||
export default class MainController extends ControllerBase {
|
||||
private autoRefreshState: boolean = false;
|
||||
|
||||
// PUBLIC METHODS //////////////////////////////////////////////////////
|
||||
/**
|
||||
* Deactivates the extension
|
||||
*/
|
||||
public deactivate(): void {
|
||||
Utils.logDebug('Main controller deactivated');
|
||||
}
|
||||
|
||||
public activate(): Promise<boolean> {
|
||||
azdata.tasks.registerTask('tempdb.startEvent', e => this.onExecute(e, 'startEvent.sql'));
|
||||
azdata.tasks.registerTask('tempdb.stopEvent', e => this.onExecute(e, 'stopEvent.sql'));
|
||||
azdata.tasks.registerTask('tempdb.contention', () => this.openurl('https://aka.ms/tempdbblog'));
|
||||
azdata.tasks.registerTask('tempdb.pauseEvent', e => this.stopAutoRefresh(e));
|
||||
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
private openurl(link: string): void {
|
||||
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(link));
|
||||
}
|
||||
|
||||
private async onExecute(connection: azdata.IConnectionProfile, fileName: string): Promise<void> {
|
||||
// Command to start/stop autorefresh and run the query
|
||||
let connectionUri = await azdata.connection.getUriForConnection(connection.id);
|
||||
let connectionProvider = azdata.dataprotocol.getProvider<azdata.ConnectionProvider>(connection.providerName, azdata.DataProviderType.ConnectionProvider);
|
||||
connectionProvider.changeDatabase(connectionUri, 'tempdb');
|
||||
let queryProvider = azdata.dataprotocol.getProvider<azdata.QueryProvider>(connection.providerName, azdata.DataProviderType.QueryProvider);
|
||||
let sqlContent: string = await promises.readFile(path.join(__dirname, '..', 'sql', fileName), { encoding: 'utf8' });
|
||||
let seResult = await queryProvider.runQueryAndReturn(connectionUri, sqlContent);
|
||||
if (seResult.rowCount > 0 && seResult.rows[0][0].displayValue === '0') {
|
||||
vscode.window.showInformationMessage((fileName === 'startEvent.sql') ? constants.XEventsStarted : constants.XEventsStopped);
|
||||
this.autoRefreshState = (fileName === 'startEvent.sql') ? true : false;
|
||||
vscode.commands.executeCommand('azdata.widget.setAutoRefreshState', 'type-of-contention', connection.id, this.autoRefreshState);
|
||||
vscode.commands.executeCommand('azdata.widget.setAutoRefreshState', 'metadata-contention', connection.id, this.autoRefreshState);
|
||||
vscode.commands.executeCommand('azdata.widget.setAutoRefreshState', 'allocation-contention', connection.id, this.autoRefreshState);
|
||||
} else if (seResult.rowCount > 0 && seResult.rows[0][0].displayValue === '1') {
|
||||
vscode.window.showErrorMessage(constants.XEventsNotSupported);
|
||||
} else {
|
||||
vscode.window.showErrorMessage(constants.XEventsFailed);
|
||||
}
|
||||
}
|
||||
|
||||
private stopAutoRefresh(connection: azdata.IConnectionProfile): void {
|
||||
this.autoRefreshState = !this.autoRefreshState === true;
|
||||
vscode.commands.executeCommand('azdata.widget.setAutoRefreshState', 'type-of-contention', connection.id, this.autoRefreshState);
|
||||
vscode.commands.executeCommand('azdata.widget.setAutoRefreshState', 'metadata-contention', connection.id, this.autoRefreshState);
|
||||
vscode.commands.executeCommand('azdata.widget.setAutoRefreshState', 'allocation-contention', connection.id, this.autoRefreshState);
|
||||
}
|
||||
}
|
||||
39
extensions/server-report/src/extension.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import ControllerBase from './controllers/controllerBase';
|
||||
import MainController from './controllers/mainController';
|
||||
|
||||
let controllers: ControllerBase[] = [];
|
||||
|
||||
export function activate(context: vscode.ExtensionContext): Promise<boolean> {
|
||||
let activations: Promise<boolean>[] = [];
|
||||
|
||||
// Start the main controller
|
||||
let mainController = new MainController(context);
|
||||
controllers.push(mainController);
|
||||
context.subscriptions.push(mainController);
|
||||
activations.push(mainController.activate());
|
||||
|
||||
return Promise.all(activations)
|
||||
.then((results: boolean[]) => {
|
||||
for (let result of results) {
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
export function deactivate(): void {
|
||||
for (let controller of controllers) {
|
||||
controller.deactivate();
|
||||
}
|
||||
}
|
||||
7
extensions/server-report/src/localizedConstants.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
export const msgErrorLoadingTab = 'An error occurred while loading the tab.';
|
||||
1
extensions/server-report/src/media/blocker.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#212121;}</style></defs><title>blocker</title><polygon class="cls-1" points="0.99 3.99 -0.01 3.99 -0.01 0.03 3.98 0.03 3.98 1.03 0.99 1.03 0.99 3.99"/><polygon class="cls-1" points="16.01 3.99 15.01 3.99 15.01 1.03 12.02 1.03 12.02 0.03 16.01 0.03 16.01 3.99"/><polygon class="cls-1" points="16.01 15.97 12.02 15.97 12.02 14.97 15.01 14.97 15.01 12.01 16.01 12.01 16.01 15.97"/><polygon class="cls-1" points="4 15.97 0.01 15.97 0.01 12.01 1.01 12.01 1.01 14.97 4 14.97 4 15.97"/><path class="cls-1" d="M8.41,3.18A4.82,4.82,0,1,0,13.23,8,4.83,4.83,0,0,0,8.41,3.18Zm0,.74A4.08,4.08,0,0,1,12.49,8a4,4,0,0,1-.85,2.47L5.69,5A4,4,0,0,1,8.41,3.93Zm0,8.15A4.08,4.08,0,0,1,4.34,8a4,4,0,0,1,.85-2.47L11.14,11A4,4,0,0,1,8.41,12.07Z"/></svg>
|
||||
|
After Width: | Height: | Size: 847 B |
1
extensions/server-report/src/media/blocker_inverse.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}</style></defs><title>blocker_inverse</title><polygon class="cls-1" points="0.99 3.99 -0.01 3.99 -0.01 0.03 3.98 0.03 3.98 1.03 0.99 1.03 0.99 3.99"/><polygon class="cls-1" points="16.01 3.99 15.01 3.99 15.01 1.03 12.02 1.03 12.02 0.03 16.01 0.03 16.01 3.99"/><polygon class="cls-1" points="16.01 15.97 12.02 15.97 12.02 14.97 15.01 14.97 15.01 12.01 16.01 12.01 16.01 15.97"/><polygon class="cls-1" points="4 15.97 0.01 15.97 0.01 12.01 1.01 12.01 1.01 14.97 4 14.97 4 15.97"/><path class="cls-1" d="M8.41,3.18A4.82,4.82,0,1,0,13.23,8,4.83,4.83,0,0,0,8.41,3.18Zm0,.74A4.08,4.08,0,0,1,12.49,8a4,4,0,0,1-.85,2.47L5.69,5A4,4,0,0,1,8.41,3.93Zm0,8.15A4.08,4.08,0,0,1,4.34,8a4,4,0,0,1,.85-2.47L11.14,11A4,4,0,0,1,8.41,12.07Z"/></svg>
|
||||
|
After Width: | Height: | Size: 852 B |
1
extensions/server-report/src/media/documentation.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#212121;}</style></defs><title>documentation</title><path class="cls-1" d="M14,4.29V16H1V0H9.72ZM13,5H9V1H2V15H13ZM3,4H8V5H3ZM3,8H8V9H3Zm0,4H8v1H3ZM9,7h3v3H9Zm0,4h3v3H9Zm1-7H12.3L10,1.71Zm0,5h1V8H10Zm0,4h1V12H10Z"/></svg>
|
||||
|
After Width: | Height: | Size: 339 B |
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}</style></defs><title>documentation_1</title><path class="cls-1" d="M14,4.29V16H1V0H9.72ZM13,5H9V1H2V15H13ZM3,4H8V5H3ZM3,8H8V9H3Zm0,4H8v1H3ZM9,7h3v3H9Zm0,4h3v3H9Zm1-7H12.3L10,1.71Zm0,5h1V8H10Zm0,4h1V12H10Z"/></svg>
|
||||
|
After Width: | Height: | Size: 338 B |
1
extensions/server-report/src/media/insights.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#212121;}</style></defs><title>insights</title><path class="cls-1" d="M15,4V8H14V5.71L9.49,10.2l-2-2L2,13.71V14H15v1H1V1H2V12.29L7.49,6.8l2,2L13.28,5H11V4Z"/></svg>
|
||||
|
After Width: | Height: | Size: 282 B |
1
extensions/server-report/src/media/insights_inverse.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}</style></defs><title>insights_inverse</title><path class="cls-1" d="M15,4V8H14V5.71L9.49,10.2l-2-2L2,13.71V14H15v1H1V1H2V12.29L7.49,6.8l2,2L13.28,5H11V4Z"/></svg>
|
||||
|
After Width: | Height: | Size: 287 B |
1
extensions/server-report/src/media/launch.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><title>launch</title><path d="M12.8,8.4l1.07-1.07v6.4H0V4.13H10.67L9.6,5.2H1.07v7.47H12.8Zm0-6.4H16V5.2H14.93V3.82l-3.8,3.8-.76-.76,3.8-3.8H12.8Z"/></svg>
|
||||
|
After Width: | Height: | Size: 247 B |
1
extensions/server-report/src/media/launch_inverse.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}</style></defs><title>launch_inverse</title><path class="cls-1" d="M12.8,8.4l1.07-1.07v6.4H0V4.13H10.67L9.6,5.2H1.07v7.47H12.8Zm0-6.4H16V5.2H14.93V3.82l-3.8,3.8-.76-.76,3.8-3.8H12.8Z"/></svg>
|
||||
|
After Width: | Height: | Size: 315 B |
1
extensions/server-report/src/media/monitor.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><title>usage</title><path d="M7,7H0A6.88,6.88,0,0,1,.25,5.14,7,7,0,0,1,5.14.25,6.92,6.92,0,0,1,7,0ZM6.75,8,1.88,12.87a6.91,6.91,0,0,1-1.4-2.26A7.33,7.33,0,0,1,0,8ZM6,1.08a6,6,0,0,0-1.77.6A6,6,0,0,0,1.68,4.23,6,6,0,0,0,1.08,6H6ZM1.08,9a6.63,6.63,0,0,0,.32,1.23A5.58,5.58,0,0,0,2,11.37L4.34,9ZM8,1l.89,0a8.52,8.52,0,0,1,.86.09,8.14,8.14,0,0,1,.84.18,6.66,6.66,0,0,1,.84.29,7.51,7.51,0,0,1,4.25,4.73,7.58,7.58,0,0,1,.06,4.18A7.51,7.51,0,0,1,15,12.29,7.49,7.49,0,0,1,12.29,15a7.5,7.5,0,0,1-1.79.75,7.63,7.63,0,0,1-4.87-.3A7.53,7.53,0,0,1,3.2,13.8l-.35-.35L8,8.29Zm.5,14a6.31,6.31,0,0,0,1.73-.23,6.66,6.66,0,0,0,1.55-.66,6.5,6.5,0,0,0,2.33-2.33,6.64,6.64,0,0,0,.66-1.55,6.47,6.47,0,0,0,0-3.36,6.69,6.69,0,0,0-.59-1.49,6.45,6.45,0,0,0-.93-1.29,6.63,6.63,0,0,0-1.21-1,6.49,6.49,0,0,0-1.44-.71A6.32,6.32,0,0,0,9,2v6.7L4.27,13.44a6.39,6.39,0,0,0,2,1.16A6.47,6.47,0,0,0,8.5,15Z"/></svg>
|
||||
|
After Width: | Height: | Size: 969 B |
1
extensions/server-report/src/media/monitor_inverse.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}</style></defs><title>usage_inverse</title><path class="cls-1" d="M7,7H0A6.88,6.88,0,0,1,.25,5.14,7,7,0,0,1,5.14.25,6.92,6.92,0,0,1,7,0ZM6.75,8,1.88,12.87a6.91,6.91,0,0,1-1.4-2.26A7.33,7.33,0,0,1,0,8ZM6,1.08a6,6,0,0,0-1.77.6A6,6,0,0,0,1.68,4.23,6,6,0,0,0,1.08,6H6ZM1.08,9a6.63,6.63,0,0,0,.32,1.23A5.58,5.58,0,0,0,2,11.37L4.34,9ZM8,1l.89,0a8.52,8.52,0,0,1,.86.09,8.14,8.14,0,0,1,.84.18,6.66,6.66,0,0,1,.84.29,7.51,7.51,0,0,1,4.25,4.73,7.58,7.58,0,0,1,.06,4.18A7.51,7.51,0,0,1,15,12.29,7.49,7.49,0,0,1,12.29,15a7.5,7.5,0,0,1-1.79.75,7.63,7.63,0,0,1-4.87-.3A7.53,7.53,0,0,1,3.2,13.8l-.35-.35L8,8.29Zm.5,14a6.31,6.31,0,0,0,1.73-.23,6.66,6.66,0,0,0,1.55-.66,6.5,6.5,0,0,0,2.33-2.33,6.64,6.64,0,0,0,.66-1.55,6.47,6.47,0,0,0,0-3.36,6.69,6.69,0,0,0-.59-1.49,6.45,6.45,0,0,0-.93-1.29,6.63,6.63,0,0,0-1.21-1,6.49,6.49,0,0,0-1.44-.71A6.32,6.32,0,0,0,9,2v6.7L4.27,13.44a6.39,6.39,0,0,0,2,1.16A6.47,6.47,0,0,0,8.5,15Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
1
extensions/server-report/src/media/performance.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#101e23;}.cls-2{fill:#4bb8d1;}.cls-3{fill:#0c1011;}</style></defs><title>health</title><path class="cls-1" d="M12.58,1.51A6.36,6.36,0,0,0,8,3.9,6.32,6.32,0,0,0,3.41,1.51,3.81,3.81,0,0,0,0,5.35,5.7,5.7,0,0,0,.64,7.88h.72l0-.08A5.18,5.18,0,0,1,.64,5.39c.07-1.25.87-3.14,2.8-3.23h.12A5.81,5.81,0,0,1,7.73,4.63L8,5.06l.27-.43a5.72,5.72,0,0,1,4.28-2.47c1.93.09,2.73,2,2.8,3.23a5.15,5.15,0,0,1-.64,2.34l0,0a2.38,2.38,0,0,1-.34.68,19.45,19.45,0,0,1-6.57,6.06,11.11,11.11,0,0,1-1.25-.81c-.34-.25-.66-.52-1-.8h0a22.83,22.83,0,0,1-2.76-3H2a18.68,18.68,0,0,0,5.76,5.29h0l0,0h0c3.49-1.63,7-5.73,7.49-7.18V8A5.85,5.85,0,0,0,16,5.35,3.81,3.81,0,0,0,12.58,1.51Z"/><path class="cls-1" d="M1.41,8l-.1-.15h0Z"/><path class="cls-1" d="M7.79,15.22v0h0Z"/><path class="cls-1" d="M7.76,15.23h0v0Z"/><path class="cls-1" d="M14.72,7.73l0,0a.13.13,0,0,0,0,0Z"/><path class="cls-2" d="M12.62,8.7v.12a.48.48,0,0,1-.48.48H8.66l0,.07L7.38,12.65h0A.72.72,0,0,1,6,12.53V9.44H6V6.6L5,9.05H5a.56.56,0,0,1-.52.37H.92V8.36H4.13l0-.07L5.41,5h0a.72.72,0,0,1,1.42.12V8.22h0v2.84L7.77,8.6h0a.56.56,0,0,1,.52-.37h3.84A.48.48,0,0,1,12.62,8.7Z"/><path class="cls-3" d="M12.62,8.7v.12a.48.48,0,0,1-.48.48H8.66l0,.07L7.38,12.65h0A.72.72,0,0,1,6,12.53V9.44H6V6.6L5,9.05H5a.56.56,0,0,1-.52.37H.92V8.36H4.13l0-.07L5.41,5h0a.72.72,0,0,1,1.42.12V8.22h0v2.84L7.77,8.6h0a.56.56,0,0,1,.52-.37h3.84A.48.48,0,0,1,12.62,8.7Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}.cls-2{fill:#101e23;}.cls-3{fill:#4bb8d1;}</style></defs><title>health_inverse</title><path class="cls-1" d="M12.58,1.51A6.36,6.36,0,0,0,8,3.9,6.32,6.32,0,0,0,3.41,1.51,3.81,3.81,0,0,0,0,5.35,5.7,5.7,0,0,0,.64,7.88h.72l0-.08A5.18,5.18,0,0,1,.64,5.39c.07-1.25.87-3.14,2.8-3.23h.12A5.81,5.81,0,0,1,7.73,4.63L8,5.06l.27-.43a5.72,5.72,0,0,1,4.28-2.47c1.93.09,2.73,2,2.8,3.23a5.15,5.15,0,0,1-.64,2.34l0,0a2.38,2.38,0,0,1-.34.68,19.45,19.45,0,0,1-6.57,6.06,11.11,11.11,0,0,1-1.25-.81c-.34-.25-.66-.52-1-.8h0a22.83,22.83,0,0,1-2.76-3H2a18.68,18.68,0,0,0,5.76,5.29h0l0,0h0c3.49-1.63,7-5.73,7.49-7.18V8A5.85,5.85,0,0,0,16,5.35,3.81,3.81,0,0,0,12.58,1.51Z"/><path class="cls-2" d="M1.41,8l-.1-.15h0Z"/><path class="cls-2" d="M7.79,15.22v0h0Z"/><path class="cls-2" d="M7.76,15.23h0v0Z"/><path class="cls-2" d="M14.72,7.73l0,0a.13.13,0,0,0,0,0Z"/><path class="cls-3" d="M12.62,8.7v.12a.48.48,0,0,1-.48.48H8.66l0,.07L7.38,12.65h0A.72.72,0,0,1,6,12.53V9.44H6V6.6L5,9.05H5a.56.56,0,0,1-.52.37H.92V8.36H4.13l0-.07L5.41,5h0a.72.72,0,0,1,1.42.12V8.22h0v2.84L7.77,8.6h0a.56.56,0,0,1,.52-.37h3.84A.48.48,0,0,1,12.62,8.7Z"/><path class="cls-1" d="M12.62,8.7v.12a.48.48,0,0,1-.48.48H8.66l0,.07L7.38,12.65h0A.72.72,0,0,1,6,12.53V9.44H6V6.6L5,9.05H5a.56.56,0,0,1-.52.37H.92V8.36H4.13l0-.07L5.41,5h0a.72.72,0,0,1,1.42.12V8.22h0v2.84L7.77,8.6h0a.56.56,0,0,1,.52-.37h3.84A.48.48,0,0,1,12.62,8.7Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
9
extensions/server-report/src/media/tempdb.svg
Normal file
@@ -0,0 +1,9 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<title>TemporaryDatabase</title>
|
||||
<g>
|
||||
<path d="M3.086,3.758a1.565,1.565,0,0,0,.492.445,3.788,3.788,0,0,0,.719.336,6.428,6.428,0,0,0,.848.234q.449.095.878.153t.817.082c.258.015.477.023.66.023s.4-.008.66-.023.53-.043.817-.082.579-.09.878-.153a6.428,6.428,0,0,0,.848-.234,3.842,3.842,0,0,0,.715-.332,1.6,1.6,0,0,0,.5-.449.555.555,0,0,0,.063-.11A.3.3,0,0,0,12,3.531a.462.462,0,0,0-.133-.312,1.7,1.7,0,0,0-.32-.274,3.616,3.616,0,0,0-.383-.222c-.13-.065-.234-.114-.312-.145a6.1,6.1,0,0,0-.79-.254q-.421-.1-.859-.172t-.871-.093c-.289-.018-.566-.028-.832-.028s-.543.01-.832.028-.58.049-.871.093-.578.1-.859.172a6.047,6.047,0,0,0-.79.254c-.078.031-.182.08-.312.145a3.616,3.616,0,0,0-.383.222,1.673,1.673,0,0,0-.32.274A.462.462,0,0,0,3,3.531a.3.3,0,0,0,.023.117A.555.555,0,0,0,3.086,3.758Z" fill="none"/>
|
||||
<path d="M7.435,14.03c-.282,0-.6-.017-.951-.046a10.214,10.214,0,0,1-1.148-.16,7.424,7.424,0,0,1-1.106-.3,3.184,3.184,0,0,1-.894-.481,1.519,1.519,0,0,1-.223-.219A.436.436,0,0,1,3,12.531V5.016A5.236,5.236,0,0,0,4.023,5.5a8.163,8.163,0,0,0,1.149.312,10.5,10.5,0,0,0,1.191.168c.4.035.778.051,1.137.051s.738-.016,1.137-.051a10.368,10.368,0,0,0,1.187-.168A8.39,8.39,0,0,0,10.973,5.5,5.218,5.218,0,0,0,12,5.016V7a5.092,5.092,0,0,1,1,.1V3.531a1.333,1.333,0,0,0-.152-.625,1.97,1.97,0,0,0-.4-.515,3.518,3.518,0,0,0-1.039-.664,7.269,7.269,0,0,0-1.3-.418,10.78,10.78,0,0,0-1.367-.215c-.456-.041-.871-.063-1.246-.063-.245,0-.511.01-.8.028s-.583.048-.891.089-.617.1-.929.164a7.689,7.689,0,0,0-.9.254,5.562,5.562,0,0,0-.8.356,2.788,2.788,0,0,0-.637.469,2.164,2.164,0,0,0-.395.511A1.3,1.3,0,0,0,2,3.531v9a1.316,1.316,0,0,0,.176.676,2.049,2.049,0,0,0,.465.543,3.278,3.278,0,0,0,.656.426,6.65,6.65,0,0,0,.75.32,7.384,7.384,0,0,0,.75.227c.245.06.463.1.656.136a11.923,11.923,0,0,0,2.047.172c.177,0,.354-.005.532-.013A5.006,5.006,0,0,1,7.435,14.03ZM3.133,3.219a1.673,1.673,0,0,1,.32-.274,3.616,3.616,0,0,1,.383-.222c.13-.065.234-.114.312-.145a6.047,6.047,0,0,1,.79-.254q.422-.1.859-.172c.291-.044.582-.075.871-.093s.566-.028.832-.028.543.01.832.028.579.049.871.093.578.1.859.172a6.1,6.1,0,0,1,.79.254c.078.031.182.08.312.145a3.616,3.616,0,0,1,.383.222,1.7,1.7,0,0,1,.32.274A.462.462,0,0,1,12,3.531a.3.3,0,0,1-.023.117.555.555,0,0,1-.063.11,1.6,1.6,0,0,1-.5.449,3.842,3.842,0,0,1-.715.332,6.428,6.428,0,0,1-.848.234q-.449.095-.878.153t-.817.082q-.387.022-.66.023c-.183,0-.4-.008-.66-.023s-.53-.043-.817-.082-.579-.09-.878-.153A6.428,6.428,0,0,1,4.3,4.539,3.788,3.788,0,0,1,3.578,4.2a1.565,1.565,0,0,1-.492-.445.555.555,0,0,1-.063-.11A.3.3,0,0,1,3,3.531.462.462,0,0,1,3.133,3.219Z"/>
|
||||
<polygon points="12 10 11 10 11 13 13.5 13 13.5 12 12 12 12 10"/>
|
||||
<path d="M15.688,10.441a3.99,3.99,0,0,0-2.129-2.129,4.051,4.051,0,0,0-3.118,0,3.99,3.99,0,0,0-2.129,2.129,4.051,4.051,0,0,0,0,3.118,3.99,3.99,0,0,0,2.129,2.129,4.051,4.051,0,0,0,3.118,0,3.99,3.99,0,0,0,2.129-2.129,4.051,4.051,0,0,0,0-3.118Zm-.922,2.727a3.029,3.029,0,0,1-1.6,1.6,3.022,3.022,0,0,1-2.332,0,3.04,3.04,0,0,1-1.6-1.6,3.022,3.022,0,0,1,0-2.332,3.029,3.029,0,0,1,1.6-1.6,3.022,3.022,0,0,1,2.332,0,3.019,3.019,0,0,1,1.6,1.6,3.022,3.022,0,0,1,0,2.332Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
9
extensions/server-report/src/media/tempdb_inverse.svg
Normal file
@@ -0,0 +1,9 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<title>TemporaryDatabase_Inverse</title>
|
||||
<g>
|
||||
<path d="M3.086,3.758a1.565,1.565,0,0,0,.492.445,3.788,3.788,0,0,0,.719.336,6.428,6.428,0,0,0,.848.234q.449.095.878.153t.817.082c.258.015.477.023.66.023s.4-.008.66-.023.53-.043.817-.082.579-.09.878-.153a6.428,6.428,0,0,0,.848-.234,3.842,3.842,0,0,0,.715-.332,1.6,1.6,0,0,0,.5-.449.555.555,0,0,0,.063-.11A.3.3,0,0,0,12,3.531a.462.462,0,0,0-.133-.312,1.7,1.7,0,0,0-.32-.274,3.616,3.616,0,0,0-.383-.222c-.13-.065-.234-.114-.312-.145a6.1,6.1,0,0,0-.79-.254q-.421-.1-.859-.172t-.871-.093c-.289-.018-.566-.028-.832-.028s-.543.01-.832.028-.58.049-.871.093-.578.1-.859.172a6.047,6.047,0,0,0-.79.254c-.078.031-.182.08-.312.145a3.616,3.616,0,0,0-.383.222,1.673,1.673,0,0,0-.32.274A.462.462,0,0,0,3,3.531a.3.3,0,0,0,.023.117A.555.555,0,0,0,3.086,3.758Z" fill="#fff"/>
|
||||
<path d="M7.435,14.03c-.282,0-.6-.017-.951-.046a10.214,10.214,0,0,1-1.148-.16,7.424,7.424,0,0,1-1.106-.3,3.184,3.184,0,0,1-.894-.481,1.519,1.519,0,0,1-.223-.219A.436.436,0,0,1,3,12.531V5.016A5.236,5.236,0,0,0,4.023,5.5a8.163,8.163,0,0,0,1.149.312,10.5,10.5,0,0,0,1.191.168c.4.035.778.051,1.137.051s.738-.016,1.137-.051a10.368,10.368,0,0,0,1.187-.168A8.39,8.39,0,0,0,10.973,5.5,5.218,5.218,0,0,0,12,5.016V7a5.092,5.092,0,0,1,1,.1V3.531a1.333,1.333,0,0,0-.152-.625,1.97,1.97,0,0,0-.4-.515,3.518,3.518,0,0,0-1.039-.664,7.269,7.269,0,0,0-1.3-.418,10.78,10.78,0,0,0-1.367-.215c-.456-.041-.871-.063-1.246-.063-.245,0-.511.01-.8.028s-.583.048-.891.089-.617.1-.929.164a7.689,7.689,0,0,0-.9.254,5.562,5.562,0,0,0-.8.356,2.788,2.788,0,0,0-.637.469,2.164,2.164,0,0,0-.395.511A1.3,1.3,0,0,0,2,3.531v9a1.316,1.316,0,0,0,.176.676,2.049,2.049,0,0,0,.465.543,3.278,3.278,0,0,0,.656.426,6.65,6.65,0,0,0,.75.32,7.384,7.384,0,0,0,.75.227c.245.06.463.1.656.136a11.923,11.923,0,0,0,2.047.172c.177,0,.354-.005.532-.013A5.006,5.006,0,0,1,7.435,14.03ZM3.133,3.219a1.673,1.673,0,0,1,.32-.274,3.616,3.616,0,0,1,.383-.222c.13-.065.234-.114.312-.145a6.047,6.047,0,0,1,.79-.254q.422-.1.859-.172c.291-.044.582-.075.871-.093s.566-.028.832-.028.543.01.832.028.579.049.871.093.578.1.859.172a6.1,6.1,0,0,1,.79.254c.078.031.182.08.312.145a3.616,3.616,0,0,1,.383.222,1.7,1.7,0,0,1,.32.274A.462.462,0,0,1,12,3.531a.3.3,0,0,1-.023.117.555.555,0,0,1-.063.11,1.6,1.6,0,0,1-.5.449,3.842,3.842,0,0,1-.715.332,6.428,6.428,0,0,1-.848.234q-.449.095-.878.153t-.817.082q-.387.022-.66.023c-.183,0-.4-.008-.66-.023s-.53-.043-.817-.082-.579-.09-.878-.153A6.428,6.428,0,0,1,4.3,4.539,3.788,3.788,0,0,1,3.578,4.2a1.565,1.565,0,0,1-.492-.445.555.555,0,0,1-.063-.11A.3.3,0,0,1,3,3.531.462.462,0,0,1,3.133,3.219Z" fill="#fff"/>
|
||||
<polygon points="12 10 11 10 11 13 13.5 13 13.5 12 12 12 12 10" fill="#fff"/>
|
||||
<path d="M15.688,10.441a3.99,3.99,0,0,0-2.129-2.129,4.051,4.051,0,0,0-3.118,0,3.99,3.99,0,0,0-2.129,2.129,4.051,4.051,0,0,0,0,3.118,3.99,3.99,0,0,0,2.129,2.129,4.051,4.051,0,0,0,3.118,0,3.99,3.99,0,0,0,2.129-2.129,4.051,4.051,0,0,0,0-3.118Zm-.922,2.727a3.029,3.029,0,0,1-1.6,1.6,3.022,3.022,0,0,1-2.332,0,3.04,3.04,0,0,1-1.6-1.6,3.022,3.022,0,0,1,0-2.332,3.029,3.029,0,0,1,1.6-1.6,3.022,3.022,0,0,1,2.332,0,3.019,3.019,0,0,1,1.6,1.6,3.022,3.022,0,0,1,0,2.332Z" fill="#fff"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
34
extensions/server-report/src/resources/templateTab.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script type="text/javascript">
|
||||
window.onload = function () {
|
||||
document.getElementById('frame').src = "{{{url}}}";
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#frame {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<iframe id="frame" width="100%" height="100%" frameborder="0"></iframe>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
103
extensions/server-report/src/sql/all_db_space_used.sql
Normal file
@@ -0,0 +1,103 @@
|
||||
--Source: https://gallery.technet.microsoft.com/scriptcenter/All-Databases-Data-log-a36da95d
|
||||
-- Use for a demo/sample purpose only. This query is not built-in to any product.
|
||||
|
||||
------------------------------Data file size----------------------------
|
||||
declare @dbsize table
|
||||
(Dbname nvarchar(128),
|
||||
file_Size_MB decimal(20,2)default (0),
|
||||
Space_Used_MB decimal(20,2)default (0),
|
||||
Free_Space_MB decimal(20,2) default (0))
|
||||
insert into @dbsize
|
||||
(Dbname,file_Size_MB,Space_Used_MB,Free_Space_MB)
|
||||
exec sp_MSforeachdb
|
||||
'use [?];
|
||||
select DB_NAME() AS DbName,
|
||||
sum(size)/128.0 AS File_Size_MB,
|
||||
sum(CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT))/128.0 as Space_Used_MB,
|
||||
SUM( size)/128.0 - sum(CAST(FILEPROPERTY(name,''SpaceUsed'') AS INT))/128.0 AS Free_Space_MB
|
||||
from sys.database_files where type=0 group by type'
|
||||
-------------------log size--------------------------------------
|
||||
declare @logsize table
|
||||
(Dbname nvarchar(128),
|
||||
Log_File_Size_MB decimal(20,2)default (0),
|
||||
log_Space_Used_MB decimal(20,2)default (0),
|
||||
log_Free_Space_MB decimal(20,2)default (0))
|
||||
insert into @logsize
|
||||
(Dbname,Log_File_Size_MB,log_Space_Used_MB,log_Free_Space_MB)
|
||||
exec sp_MSforeachdb
|
||||
'use [?];
|
||||
select DB_NAME() AS DbName,
|
||||
sum(size)/128.0 AS Log_File_Size_MB,
|
||||
sum(CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT))/128.0 as log_Space_Used_MB,
|
||||
SUM( size)/128.0 - sum(CAST(FILEPROPERTY(name,''SpaceUsed'') AS INT))/128.0 AS log_Free_Space_MB
|
||||
from sys.database_files where type=1 group by type'
|
||||
--------------------------------database free size
|
||||
declare @dbfreesize table
|
||||
(name nvarchar(128),
|
||||
database_size varchar(50),
|
||||
Freespace varchar(50)default (0.00))
|
||||
insert into @dbfreesize
|
||||
(name,database_size,Freespace)
|
||||
exec sp_MSforeachdb
|
||||
'use [?];SELECT database_name = db_name()
|
||||
,database_size = ltrim(str((convert(DECIMAL(15, 2), dbsize) + convert(DECIMAL(15, 2), logsize)) * 8192 / 1048576, 15, 2) + ''MB'')
|
||||
,''unallocated space'' = ltrim(str((
|
||||
CASE
|
||||
WHEN dbsize >= reservedpages
|
||||
THEN (convert(DECIMAL(15, 2), dbsize) - convert(DECIMAL(15, 2), reservedpages)) * 8192 / 1048576
|
||||
ELSE 0
|
||||
END
|
||||
), 15, 2) + '' MB'')
|
||||
FROM (
|
||||
SELECT dbsize = sum(convert(BIGINT, CASE
|
||||
WHEN type = 0
|
||||
THEN size
|
||||
ELSE 0
|
||||
END))
|
||||
,logsize = sum(convert(BIGINT, CASE
|
||||
WHEN type <> 0
|
||||
THEN size
|
||||
ELSE 0
|
||||
END))
|
||||
FROM sys.database_files
|
||||
) AS files
|
||||
,(
|
||||
SELECT reservedpages = sum(a.total_pages)
|
||||
,usedpages = sum(a.used_pages)
|
||||
,pages = sum(CASE
|
||||
WHEN it.internal_type IN (
|
||||
202
|
||||
,204
|
||||
,211
|
||||
,212
|
||||
,213
|
||||
,214
|
||||
,215
|
||||
,216
|
||||
)
|
||||
THEN 0
|
||||
WHEN a.type <> 1
|
||||
THEN a.used_pages
|
||||
WHEN p.index_id < 2
|
||||
THEN a.data_pages
|
||||
ELSE 0
|
||||
END)
|
||||
FROM sys.partitions p
|
||||
INNER JOIN sys.allocation_units a
|
||||
ON p.partition_id = a.container_id
|
||||
LEFT JOIN sys.internal_tables it
|
||||
ON p.object_id = it.object_id
|
||||
) AS partitions'
|
||||
-----------------------------------
|
||||
select TOP 10
|
||||
d.Dbname,
|
||||
--(file_size_mb + log_file_size_mb) as DBsize,
|
||||
--d.file_Size_MB,
|
||||
d.Space_Used_MB,
|
||||
--d.Free_Space_MB,
|
||||
--l.Log_File_Size_MB,
|
||||
l.log_Space_Used_MB--,
|
||||
--l.log_Free_Space_MB,
|
||||
--fs.Freespace as DB_Freespace
|
||||
from @dbsize d join @logsize l on d.Dbname=l.Dbname join @dbfreesize fs on d.Dbname=fs.name
|
||||
order by d.Space_Used_MB DESC
|
||||
19
extensions/server-report/src/sql/allocationContention.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
--SQL script to grab allocation contention from histogram
|
||||
Use tempdb
|
||||
DECLARE @target_data XML;
|
||||
SELECT @target_data = CAST(t.target_data AS XML)
|
||||
FROM sys.dm_xe_sessions AS s
|
||||
JOIN sys.dm_xe_session_targets AS t
|
||||
ON t.event_session_address = s.address
|
||||
WHERE s.name = N'PageContention' and t.target_name = N'histogram';
|
||||
|
||||
with wait_stats as
|
||||
(
|
||||
SELECT
|
||||
n.value('(value)[1]','bigint') AS id,
|
||||
n.value('(@count)[1]', 'bigint') AS [Count]
|
||||
FROM @target_data.nodes('//HistogramTarget/Slot') AS q(n)
|
||||
)
|
||||
|
||||
SELECT [dbo].[mapPageType](wait_stats.id), wait_stats.Count
|
||||
FROM wait_stats
|
||||
33
extensions/server-report/src/sql/backup_detail.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
declare @condition tinyint;
|
||||
SET @condition = 24;
|
||||
|
||||
select
|
||||
d.database_id as [Database ID],
|
||||
d.name as [Database],
|
||||
d.recovery_model_desc as [Recovery model],
|
||||
d.state_desc as [Database state],
|
||||
case
|
||||
when b.type = N'D' then N'Database'
|
||||
when b.type = N'I' then N'Differential Database'
|
||||
when b.type = N'L' then N'Log'
|
||||
when b.type = N'F' then N'File or Filegroup'
|
||||
when b.type = N'G' then N'Differental File'
|
||||
when b.type = N'P' then N'Partial'
|
||||
when b.type = N'Q' then N'Differential Partial'
|
||||
else NULL
|
||||
end
|
||||
as [Backup type],
|
||||
b.backup_start_date as [Backup start date],
|
||||
b.backup_finish_date as [Backup finish date],
|
||||
case
|
||||
when m.last_backup_time is null then 0 --N'No backup found'
|
||||
when datediff(hh, m.last_backup_time, getdate()) > @condition then 1 -- N'Older than 24hrs'
|
||||
else 2 --N'Within 24hrs'
|
||||
end as [Backup_Health]
|
||||
from sys.databases as d
|
||||
left join msdb..backupset as b on d.name = b.database_name
|
||||
left join (select bs.database_name, max(bs.backup_start_date) as last_backup_time
|
||||
from msdb..backupset as bs
|
||||
group by bs.database_name ) as m on d.name = m.database_name and b.backup_start_date = m.last_backup_time
|
||||
where b.backup_start_date is null or b.backup_start_date = m.last_backup_time
|
||||
order by d.database_id asc
|
||||
15
extensions/server-report/src/sql/backup_insight.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
declare @condition tinyint;
|
||||
SET @condition = 24;
|
||||
with
|
||||
backupInsight_cte (database_id, last_backup, health_check)
|
||||
as
|
||||
(
|
||||
select d.database_id, max(b.backup_start_date) AS last_backup, case when (datediff( hh , max(b.backup_start_date) , getdate()) < @condition) then 1 else 0 end as health_check
|
||||
from sys.databases as d left join msdb..backupset as b on d.name = b.database_name
|
||||
group by d.database_id
|
||||
)
|
||||
select
|
||||
sum(health_check) [Within 24hrs],
|
||||
sum(case when health_check = 0 AND last_backup IS NOT NULL then 1 else 0 end) [Older than 24hrs],
|
||||
sum(case when health_check = 0 AND last_backup IS NULL then 1 else 0 end) [No backup found]
|
||||
from backupInsight_cte
|
||||
12
extensions/server-report/src/sql/backup_size_trend.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
SELECT
|
||||
[database_name] AS "database",
|
||||
format(backup_start_date, 'yyyy-MM-dd') as date,
|
||||
--DATEPART(month,[backup_start_date]) AS "Month",
|
||||
AVG([backup_size]/1024/1024) AS "size MB"
|
||||
--AVG([compressed_backup_size]/1024/1024) AS "Compressed Backup Size MB",
|
||||
--AVG([backup_size]/[compressed_backup_size]) AS "Compression Ratio"
|
||||
from (SELECT TOP 100 *
|
||||
FROM msdb.dbo.backupset
|
||||
where [type] = 'D'
|
||||
ORDER BY backup_start_date DESC) AS recentbackups
|
||||
GROUP BY [database_name], format(backup_start_date, 'yyyy-MM-dd') --DATEPART(mm,[backup_start_date]);
|
||||
25
extensions/server-report/src/sql/cpumetric.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- source: https://sqlserverperformance.wordpress.com/2009/07/30/how-to-get-sql-server-cpu-utilization-from-a-query/
|
||||
-- Use for a demo/sample purpose only. This query is not built-in to any product.
|
||||
|
||||
DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks)FROM sys.dm_os_sys_info);
|
||||
|
||||
SELECT Top(30) 'CPU%' as [label],
|
||||
DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time],
|
||||
SQLProcessUtilization AS [SQL Server Process CPU Utilization]
|
||||
-- SystemIdle AS [System Idle Process],
|
||||
-- 100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization],
|
||||
FROM (
|
||||
SELECT record.value('(./Record/@id)[1]', 'int') AS record_id,
|
||||
record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int')
|
||||
AS [SystemIdle],
|
||||
record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]',
|
||||
'int')
|
||||
AS [SQLProcessUtilization], [timestamp]
|
||||
FROM (
|
||||
SELECT [timestamp], convert(xml, record) AS [record]
|
||||
FROM sys.dm_os_ring_buffers
|
||||
WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR'
|
||||
AND record LIKE '%<SystemHealth>%') AS x
|
||||
) AS y
|
||||
--ORDER BY record_id DESC;
|
||||
ORDER BY [Event Time] DESC;
|
||||
12
extensions/server-report/src/sql/db_size.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
with fs
|
||||
as
|
||||
(
|
||||
select database_id, type, size * 8.0 / 1024 size
|
||||
from sys.master_files
|
||||
)
|
||||
select
|
||||
name,
|
||||
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataFileSizeMB,
|
||||
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeMB
|
||||
from sys.databases db
|
||||
where database_id > 4
|
||||
30
extensions/server-report/src/sql/memorybydb.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- source:https://www.mssqltips.com/sqlservertip/2393/determine-sql-server-memory-use-by-database-and-object/
|
||||
-- Use for a demo/sample purpose only. This query is not built-in to any product.
|
||||
|
||||
DECLARE @total_buffer INT;
|
||||
|
||||
SELECT @total_buffer = cntr_value
|
||||
FROM sys.dm_os_performance_counters
|
||||
WHERE RTRIM([object_name]) LIKE '%Buffer Manager'
|
||||
AND counter_name = 'Database Pages';
|
||||
|
||||
;WITH src AS
|
||||
(
|
||||
SELECT
|
||||
database_id, db_buffer_pages = COUNT_BIG(*)
|
||||
FROM sys.dm_os_buffer_descriptors
|
||||
--WHERE database_id BETWEEN 5 AND 32766
|
||||
GROUP BY database_id
|
||||
)
|
||||
SELECT TOP 10
|
||||
[db_name] = CASE [database_id] WHEN 32767
|
||||
THEN 'Resource DB'
|
||||
ELSE DB_NAME([database_id]) END,
|
||||
--db_buffer_pages,
|
||||
--db_buffer_MB = db_buffer_pages / 128,
|
||||
db_buffer_percent = CONVERT(DECIMAL(6,3),
|
||||
db_buffer_pages * 100.0 / @total_buffer)
|
||||
FROM src
|
||||
--ORDER BY db_buffer_MB DESC;
|
||||
order by db_buffer_percent DESC;
|
||||
|
||||
22
extensions/server-report/src/sql/metadataContention.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
--SQL script to grab metadata contention from histogram
|
||||
Use tempdb
|
||||
DECLARE @target_data XML;
|
||||
SELECT @target_data = CAST(t.target_data AS XML)
|
||||
FROM sys.dm_xe_sessions AS s
|
||||
JOIN sys.dm_xe_session_targets AS t
|
||||
ON t.event_session_address = s.address
|
||||
WHERE s.name = N'ObjectContention' and t.target_name = N'histogram';
|
||||
|
||||
with wait_stats as
|
||||
(
|
||||
SELECT
|
||||
n.value('(value)[1]','bigint') AS alloc_unit_id,
|
||||
n.value('(@count)[1]', 'bigint') AS [Count]
|
||||
FROM @target_data.nodes('//HistogramTarget/Slot') AS q(n)
|
||||
)
|
||||
|
||||
SELECT objects.id, SUM(objects.count) as [Count] FROM
|
||||
(SELECT [dbo].[isSystemTable](wait_stats.alloc_unit_id) AS id, wait_stats.Count AS [count]
|
||||
FROM wait_stats
|
||||
WHERE [dbo].[isSystemTable](wait_stats.alloc_unit_id) not in (0, 99)) AS objects
|
||||
GROUP BY objects.id
|
||||
80
extensions/server-report/src/sql/startEvent.sql
Normal file
@@ -0,0 +1,80 @@
|
||||
--Starts the XEvents sessions and creates the functions needed to find object id and give name to the page types
|
||||
BEGIN TRY
|
||||
IF NOT EXISTS (SELECT * FROM sys.dm_xe_sessions WHERE name = 'PageContention')
|
||||
BEGIN
|
||||
CREATE EVENT SESSION [PageContention] ON SERVER
|
||||
ADD EVENT latch_suspend_end(
|
||||
WHERE class = 28
|
||||
AND (page_type_id = 8
|
||||
OR page_type_id = 9
|
||||
OR page_type_id = 11))
|
||||
ADD TARGET package0.histogram(SET slots=16, filtering_event_name=N'latch_suspend_end', source=N'page_type_id', source_type=(0))
|
||||
ALTER EVENT SESSION [PageContention] ON SERVER
|
||||
STATE = START
|
||||
END
|
||||
IF NOT EXISTS (SELECT * FROM sys.dm_xe_sessions WHERE name = 'ObjectContention')
|
||||
BEGIN
|
||||
CREATE EVENT SESSION [ObjectContention] ON SERVER
|
||||
ADD EVENT latch_suspend_end(
|
||||
WHERE class = 28
|
||||
AND database_id = 2)
|
||||
ADD TARGET package0.histogram(SET slots=256, filtering_event_name=N'latch_suspend_end', source=N'page_alloc_unit_id', source_type=(0))
|
||||
ALTER EVENT SESSION [ObjectContention] ON SERVER
|
||||
STATE = START
|
||||
END
|
||||
SELECT 0 AS RESULTCODE
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
PRINT 'XEvent fields not supported'
|
||||
SELECT 1 AS RESULTCODE
|
||||
END CATCH
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'[dbo].[isSystemTable]', N'FN') IS NOT NULL
|
||||
DROP FUNCTION [dbo].[isSystemTable]
|
||||
GO
|
||||
|
||||
CREATE FUNCTION [dbo].[isSystemTable] (@alloc bigint)
|
||||
RETURNS bigint
|
||||
|
||||
AS BEGIN
|
||||
|
||||
DECLARE @index BIGINT;
|
||||
DECLARE @objId BIGINT;
|
||||
|
||||
SELECT @index =
|
||||
CONVERT (BIGINT,
|
||||
CONVERT (FLOAT, @alloc)
|
||||
* (1 / POWER (2.0, 48))
|
||||
);
|
||||
SELECT @objId =
|
||||
CONVERT (BIGINT,
|
||||
CONVERT (FLOAT, @alloc - (@index * CONVERT (BIGINT, POWER (2.0, 48))))
|
||||
* (1 / POWER (2.0, 16))
|
||||
);
|
||||
|
||||
IF (@objId > 0 AND @objId <= 100 AND @index <= 255)
|
||||
return @objId
|
||||
|
||||
return 0
|
||||
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID(N'[dbo].[mapPageType]', N'FN') IS NOT NULL
|
||||
DROP FUNCTION [dbo].[mapPageType]
|
||||
GO
|
||||
|
||||
CREATE FUNCTION [dbo].[mapPageType] (@pageTypeId bigint)
|
||||
RETURNS varchar(20)
|
||||
|
||||
AS BEGIN
|
||||
IF @pageTypeId = 8
|
||||
return 'GAM_PAGE'
|
||||
ELSE IF @pageTypeId = 9
|
||||
return 'SGAM_PAGE'
|
||||
ELSE IF @pageTypeId = 11
|
||||
return 'PFS_PAGE'
|
||||
return ''
|
||||
END
|
||||
GO
|
||||
4
extensions/server-report/src/sql/stopEvent.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
--Stops the XEvent Sessions
|
||||
DROP EVENT SESSION [PageContention] ON SERVER
|
||||
DROP EVENT SESSION [ObjectContention] ON SERVER
|
||||
SELECT 0 AS RESULTCODE
|
||||
33
extensions/server-report/src/sql/typeofContentions.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
--SQL script to grab all contention
|
||||
Use tempdb
|
||||
DECLARE @pc XML;
|
||||
DECLARE @obj XML;
|
||||
|
||||
SELECT @pc = CAST(t.target_data AS XML)
|
||||
FROM sys.dm_xe_sessions AS s
|
||||
JOIN sys.dm_xe_session_targets AS t
|
||||
ON t.event_session_address = s.address
|
||||
WHERE s.name = N'PageContention' and t.target_name = N'histogram';
|
||||
|
||||
SELECT @obj = CAST(t.target_data AS XML)
|
||||
FROM sys.dm_xe_sessions AS s
|
||||
JOIN sys.dm_xe_session_targets AS t
|
||||
ON t.event_session_address = s.address
|
||||
WHERE s.name = N'ObjectContention' and t.target_name = N'histogram';
|
||||
|
||||
SELECT 'Metadata Contention' AS wait_type, SUM(obj.count) AS [Count]
|
||||
FROM (
|
||||
SELECT
|
||||
n.value('(value)[1]','bigint') AS alloc_unit_id,
|
||||
n.value('(@count)[1]', 'bigint') AS [count]
|
||||
FROM @obj.nodes('//HistogramTarget/Slot') AS q(n)
|
||||
) obj
|
||||
WHERE [dbo].[isSystemTable](obj.alloc_unit_id) not in (0, 99)
|
||||
UNION
|
||||
SELECT 'Allocation Contention' AS wait_type, SUM(pc.count) AS [Count]
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
n.value('(@count)[1]', 'bigint') AS [count]
|
||||
FROM @pc.nodes('//HistogramTarget/Slot') AS q(n)
|
||||
) pc
|
||||
95
extensions/server-report/src/sql/wait_resources.sql
Normal file
@@ -0,0 +1,95 @@
|
||||
WITH [Waits] AS
|
||||
(
|
||||
SELECT wait_type, resource_description, count(resource_description) AS RESOURCE_USE, COUNT(*) AS TOTAL FROM sys.dm_os_waiting_tasks
|
||||
WHERE [wait_type] NOT IN (
|
||||
-- These wait types are almost 100% never a problem and so they are
|
||||
-- filtered out to avoid them skewing the results. Click on the URL
|
||||
-- for more information.
|
||||
N'BROKER_EVENTHANDLER', -- https://www.sqlskills.com/help/waits/BROKER_EVENTHANDLER
|
||||
N'BROKER_RECEIVE_WAITFOR', -- https://www.sqlskills.com/help/waits/BROKER_RECEIVE_WAITFOR
|
||||
N'BROKER_TASK_STOP', -- https://www.sqlskills.com/help/waits/BROKER_TASK_STOP
|
||||
N'BROKER_TO_FLUSH', -- https://www.sqlskills.com/help/waits/BROKER_TO_FLUSH
|
||||
N'BROKER_TRANSMITTER', -- https://www.sqlskills.com/help/waits/BROKER_TRANSMITTER
|
||||
N'CHECKPOINT_QUEUE', -- https://www.sqlskills.com/help/waits/CHECKPOINT_QUEUE
|
||||
N'CHKPT', -- https://www.sqlskills.com/help/waits/CHKPT
|
||||
N'CLR_AUTO_EVENT', -- https://www.sqlskills.com/help/waits/CLR_AUTO_EVENT
|
||||
N'CLR_MANUAL_EVENT', -- https://www.sqlskills.com/help/waits/CLR_MANUAL_EVENT
|
||||
N'CLR_SEMAPHORE', -- https://www.sqlskills.com/help/waits/CLR_SEMAPHORE
|
||||
N'CXCONSUMER', -- https://www.sqlskills.com/help/waits/CXCONSUMER
|
||||
|
||||
-- Maybe comment these four out if you have mirroring issues
|
||||
N'DBMIRROR_DBM_EVENT', -- https://www.sqlskills.com/help/waits/DBMIRROR_DBM_EVENT
|
||||
N'DBMIRROR_EVENTS_QUEUE', -- https://www.sqlskills.com/help/waits/DBMIRROR_EVENTS_QUEUE
|
||||
N'DBMIRROR_WORKER_QUEUE', -- https://www.sqlskills.com/help/waits/DBMIRROR_WORKER_QUEUE
|
||||
N'DBMIRRORING_CMD', -- https://www.sqlskills.com/help/waits/DBMIRRORING_CMD
|
||||
|
||||
N'DIRTY_PAGE_POLL', -- https://www.sqlskills.com/help/waits/DIRTY_PAGE_POLL
|
||||
N'DISPATCHER_QUEUE_SEMAPHORE', -- https://www.sqlskills.com/help/waits/DISPATCHER_QUEUE_SEMAPHORE
|
||||
N'EXECSYNC', -- https://www.sqlskills.com/help/waits/EXECSYNC
|
||||
N'FSAGENT', -- https://www.sqlskills.com/help/waits/FSAGENT
|
||||
N'FT_IFTS_SCHEDULER_IDLE_WAIT', -- https://www.sqlskills.com/help/waits/FT_IFTS_SCHEDULER_IDLE_WAIT
|
||||
N'FT_IFTSHC_MUTEX', -- https://www.sqlskills.com/help/waits/FT_IFTSHC_MUTEX
|
||||
|
||||
-- Maybe comment these six out if you have AG issues
|
||||
N'HADR_CLUSAPI_CALL', -- https://www.sqlskills.com/help/waits/HADR_CLUSAPI_CALL
|
||||
N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', -- https://www.sqlskills.com/help/waits/HADR_FILESTREAM_IOMGR_IOCOMPLETION
|
||||
N'HADR_LOGCAPTURE_WAIT', -- https://www.sqlskills.com/help/waits/HADR_LOGCAPTURE_WAIT
|
||||
N'HADR_NOTIFICATION_DEQUEUE', -- https://www.sqlskills.com/help/waits/HADR_NOTIFICATION_DEQUEUE
|
||||
N'HADR_TIMER_TASK', -- https://www.sqlskills.com/help/waits/HADR_TIMER_TASK
|
||||
N'HADR_WORK_QUEUE', -- https://www.sqlskills.com/help/waits/HADR_WORK_QUEUE
|
||||
|
||||
N'KSOURCE_WAKEUP', -- https://www.sqlskills.com/help/waits/KSOURCE_WAKEUP
|
||||
N'LAZYWRITER_SLEEP', -- https://www.sqlskills.com/help/waits/LAZYWRITER_SLEEP
|
||||
N'LOGMGR_QUEUE', -- https://www.sqlskills.com/help/waits/LOGMGR_QUEUE
|
||||
N'MEMORY_ALLOCATION_EXT', -- https://www.sqlskills.com/help/waits/MEMORY_ALLOCATION_EXT
|
||||
N'ONDEMAND_TASK_QUEUE', -- https://www.sqlskills.com/help/waits/ONDEMAND_TASK_QUEUE
|
||||
N'PARALLEL_REDO_DRAIN_WORKER', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_DRAIN_WORKER
|
||||
N'PARALLEL_REDO_LOG_CACHE', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_LOG_CACHE
|
||||
N'PARALLEL_REDO_TRAN_LIST', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_TRAN_LIST
|
||||
N'PARALLEL_REDO_WORKER_SYNC', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_WORKER_SYNC
|
||||
N'PARALLEL_REDO_WORKER_WAIT_WORK', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_WORKER_WAIT_WORK
|
||||
N'PREEMPTIVE_OS_FLUSHFILEBUFFERS', -- https://www.sqlskills.com/help/waits/PREEMPTIVE_OS_FLUSHFILEBUFFERS
|
||||
N'PREEMPTIVE_XE_GETTARGETSTATE', -- https://www.sqlskills.com/help/waits/PREEMPTIVE_XE_GETTARGETSTATE
|
||||
N'PWAIT_ALL_COMPONENTS_INITIALIZED', -- https://www.sqlskills.com/help/waits/PWAIT_ALL_COMPONENTS_INITIALIZED
|
||||
N'PWAIT_DIRECTLOGCONSUMER_GETNEXT', -- https://www.sqlskills.com/help/waits/PWAIT_DIRECTLOGCONSUMER_GETNEXT
|
||||
N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', -- https://www.sqlskills.com/help/waits/QDS_PERSIST_TASK_MAIN_LOOP_SLEEP
|
||||
N'QDS_ASYNC_QUEUE', -- https://www.sqlskills.com/help/waits/QDS_ASYNC_QUEUE
|
||||
N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP',
|
||||
-- https://www.sqlskills.com/help/waits/QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP
|
||||
N'QDS_SHUTDOWN_QUEUE', -- https://www.sqlskills.com/help/waits/QDS_SHUTDOWN_QUEUE
|
||||
N'REDO_THREAD_PENDING_WORK', -- https://www.sqlskills.com/help/waits/REDO_THREAD_PENDING_WORK
|
||||
N'REQUEST_FOR_DEADLOCK_SEARCH', -- https://www.sqlskills.com/help/waits/REQUEST_FOR_DEADLOCK_SEARCH
|
||||
N'RESOURCE_QUEUE', -- https://www.sqlskills.com/help/waits/RESOURCE_QUEUE
|
||||
N'SERVER_IDLE_CHECK', -- https://www.sqlskills.com/help/waits/SERVER_IDLE_CHECK
|
||||
N'SLEEP_BPOOL_FLUSH', -- https://www.sqlskills.com/help/waits/SLEEP_BPOOL_FLUSH
|
||||
N'SLEEP_DBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_DBSTARTUP
|
||||
N'SLEEP_DCOMSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_DCOMSTARTUP
|
||||
N'SLEEP_MASTERDBREADY', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERDBREADY
|
||||
N'SLEEP_MASTERMDREADY', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERMDREADY
|
||||
N'SLEEP_MASTERUPGRADED', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERUPGRADED
|
||||
N'SLEEP_MSDBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_MSDBSTARTUP
|
||||
N'SLEEP_SYSTEMTASK', -- https://www.sqlskills.com/help/waits/SLEEP_SYSTEMTASK
|
||||
N'SLEEP_TASK', -- https://www.sqlskills.com/help/waits/SLEEP_TASK
|
||||
N'SLEEP_TEMPDBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_TEMPDBSTARTUP
|
||||
N'SNI_HTTP_ACCEPT', -- https://www.sqlskills.com/help/waits/SNI_HTTP_ACCEPT
|
||||
N'SOS_WORK_DISPATCHER', -- https://www.sqlskills.com/help/waits/SOS_WORK_DISPATCHER
|
||||
N'SP_SERVER_DIAGNOSTICS_SLEEP', -- https://www.sqlskills.com/help/waits/SP_SERVER_DIAGNOSTICS_SLEEP
|
||||
N'SQLTRACE_BUFFER_FLUSH', -- https://www.sqlskills.com/help/waits/SQLTRACE_BUFFER_FLUSH
|
||||
N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', -- https://www.sqlskills.com/help/waits/SQLTRACE_INCREMENTAL_FLUSH_SLEEP
|
||||
N'SQLTRACE_WAIT_ENTRIES', -- https://www.sqlskills.com/help/waits/SQLTRACE_WAIT_ENTRIES
|
||||
N'VDI_CLIENT_OTHER', -- https://www.sqlskills.com/help/waits/VDI_CLIENT_OTHER
|
||||
N'WAIT_FOR_RESULTS', -- https://www.sqlskills.com/help/waits/WAIT_FOR_RESULTS
|
||||
N'WAITFOR', -- https://www.sqlskills.com/help/waits/WAITFOR
|
||||
N'WAITFOR_TASKSHUTDOWN', -- https://www.sqlskills.com/help/waits/WAITFOR_TASKSHUTDOWN
|
||||
N'WAIT_XTP_RECOVERY', -- https://www.sqlskills.com/help/waits/WAIT_XTP_RECOVERY
|
||||
N'WAIT_XTP_HOST_WAIT', -- https://www.sqlskills.com/help/waits/WAIT_XTP_HOST_WAIT
|
||||
N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', -- https://www.sqlskills.com/help/waits/WAIT_XTP_OFFLINE_CKPT_NEW_LOG
|
||||
N'WAIT_XTP_CKPT_CLOSE', -- https://www.sqlskills.com/help/waits/WAIT_XTP_CKPT_CLOSE
|
||||
N'XE_DISPATCHER_JOIN', -- https://www.sqlskills.com/help/waits/XE_DISPATCHER_JOIN
|
||||
N'XE_DISPATCHER_WAIT', -- https://www.sqlskills.com/help/waits/XE_DISPATCHER_WAIT
|
||||
N'XE_TIMER_EVENT' -- https://www.sqlskills.com/help/waits/XE_TIMER_EVENT
|
||||
)
|
||||
GROUP BY sys.dm_os_waiting_tasks.resource_description, wait_type
|
||||
)
|
||||
|
||||
SELECT [TASKS].[wait_type] AS [WaitType], [TASKS].[resource_description] as [Resource], 100.0 * [TASKS].[TOTAL] / SUM ([TASKS].[TOTAL]) OVER () AS [Percentage] FROM Waits AS TASKS GROUP BY [TASKS].[wait_type], [TASKS].[resource_description], [TASKS].[TOTAL]
|
||||
@@ -0,0 +1,77 @@
|
||||
-- SOURCE: https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/
|
||||
-- Use for a demo/sample purpose only. This query is not built-in to any product.
|
||||
|
||||
WITH [Waits] AS
|
||||
(SELECT
|
||||
[wait_type],
|
||||
[wait_time_ms] / 1000.0 AS [WaitS],
|
||||
([wait_time_ms] - [signal_wait_time_ms]) / 1000.0 AS [ResourceS],
|
||||
[signal_wait_time_ms] / 1000.0 AS [SignalS],
|
||||
[waiting_tasks_count] AS [WaitCount],
|
||||
100.0 * [wait_time_ms] / SUM ([wait_time_ms]) OVER() AS [Percentage],
|
||||
ROW_NUMBER() OVER(ORDER BY [wait_time_ms] DESC) AS [RowNum]
|
||||
FROM sys.dm_os_wait_stats
|
||||
WHERE [wait_type] NOT IN (
|
||||
N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR',
|
||||
N'BROKER_TASK_STOP', N'BROKER_TO_FLUSH',
|
||||
N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE',
|
||||
N'CHKPT', N'CLR_AUTO_EVENT',
|
||||
N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE',
|
||||
|
||||
-- Maybe uncomment these four if you have mirroring issues
|
||||
N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE',
|
||||
N'DBMIRROR_WORKER_QUEUE', N'DBMIRRORING_CMD',
|
||||
|
||||
N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE',
|
||||
N'EXECSYNC', N'FSAGENT',
|
||||
N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX',
|
||||
|
||||
-- Maybe uncomment these six if you have AG issues
|
||||
N'HADR_CLUSAPI_CALL', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION',
|
||||
N'HADR_LOGCAPTURE_WAIT', N'HADR_NOTIFICATION_DEQUEUE',
|
||||
N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE',
|
||||
|
||||
N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP',
|
||||
N'LOGMGR_QUEUE', N'MEMORY_ALLOCATION_EXT',
|
||||
N'ONDEMAND_TASK_QUEUE',
|
||||
N'PREEMPTIVE_OS_FLUSHFILEBUFFERS',
|
||||
N'PREEMPTIVE_XE_GETTARGETSTATE',
|
||||
N'PWAIT_ALL_COMPONENTS_INITIALIZED',
|
||||
N'PWAIT_DIRECTLOGCONSUMER_GETNEXT',
|
||||
N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', N'QDS_ASYNC_QUEUE',
|
||||
N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP',
|
||||
N'QDS_SHUTDOWN_QUEUE', N'REDO_THREAD_PENDING_WORK',
|
||||
N'REQUEST_FOR_DEADLOCK_SEARCH', N'RESOURCE_QUEUE',
|
||||
N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH',
|
||||
N'SLEEP_DBSTARTUP', N'SLEEP_DCOMSTARTUP',
|
||||
N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY',
|
||||
N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP',
|
||||
N'SLEEP_SYSTEMTASK', N'SLEEP_TASK',
|
||||
N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT',
|
||||
N'SP_SERVER_DIAGNOSTICS_SLEEP', N'SQLTRACE_BUFFER_FLUSH',
|
||||
N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP',
|
||||
N'SQLTRACE_WAIT_ENTRIES', N'VDI_CLIENT_OTHER', N'WAIT_FOR_RESULTS',
|
||||
N'WAITFOR', N'WAITFOR_TASKSHUTDOWN',
|
||||
N'WAIT_XTP_RECOVERY',
|
||||
N'WAIT_XTP_HOST_WAIT', N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG',
|
||||
N'WAIT_XTP_CKPT_CLOSE', N'XE_DISPATCHER_JOIN',
|
||||
N'XE_DISPATCHER_WAIT', N'XE_TIMER_EVENT')
|
||||
AND [waiting_tasks_count] > 0
|
||||
)
|
||||
SELECT
|
||||
MAX ([W1].[wait_type]) AS [WaitType],
|
||||
CAST (MAX ([W1].[WaitS]) AS DECIMAL (16,2)) AS [Wait_S],
|
||||
CAST (MAX ([W1].[ResourceS]) AS DECIMAL (16,2)) AS [Resource_S],
|
||||
CAST (MAX ([W1].[SignalS]) AS DECIMAL (16,2)) AS [Signal_S],
|
||||
MAX ([W1].[WaitCount]) AS [WaitCount],
|
||||
CAST (MAX ([W1].[Percentage]) AS DECIMAL (5,2)) AS [Percentage],
|
||||
CAST ((MAX ([W1].[WaitS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgWait_S],
|
||||
CAST ((MAX ([W1].[ResourceS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgRes_S],
|
||||
CAST ((MAX ([W1].[SignalS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgSig_S],
|
||||
CAST ('https://www.sqlskills.com/help/waits/' + MAX ([W1].[wait_type]) as XML) AS [Help/Info URL]
|
||||
FROM [Waits] AS [W1]
|
||||
INNER JOIN [Waits] AS [W2]
|
||||
ON [W2].[RowNum] <= [W1].[RowNum]
|
||||
GROUP BY [W1].[RowNum]
|
||||
HAVING SUM ([W2].[Percentage]) - MAX( [W1].[Percentage] ) < 95; -- percentage threshold
|
||||
GO
|
||||
77
extensions/server-report/src/sql/waits_paul_randal.sql
Normal file
@@ -0,0 +1,77 @@
|
||||
-- SOURCE: https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/
|
||||
-- Use for a demo/sample purpose only. This query is not built-in to any product.
|
||||
|
||||
WITH [Waits] AS
|
||||
(SELECT
|
||||
[wait_type],
|
||||
[wait_time_ms] / 1000.0 AS [WaitS],
|
||||
([wait_time_ms] - [signal_wait_time_ms]) / 1000.0 AS [ResourceS],
|
||||
[signal_wait_time_ms] / 1000.0 AS [SignalS],
|
||||
[waiting_tasks_count] AS [WaitCount],
|
||||
100.0 * [wait_time_ms] / SUM ([wait_time_ms]) OVER() AS [Percentage],
|
||||
ROW_NUMBER() OVER(ORDER BY [wait_time_ms] DESC) AS [RowNum]
|
||||
FROM sys.dm_os_wait_stats
|
||||
WHERE [wait_type] NOT IN (
|
||||
N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR',
|
||||
N'BROKER_TASK_STOP', N'BROKER_TO_FLUSH',
|
||||
N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE',
|
||||
N'CHKPT', N'CLR_AUTO_EVENT',
|
||||
N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE',
|
||||
|
||||
-- Maybe uncomment these four if you have mirroring issues
|
||||
N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE',
|
||||
N'DBMIRROR_WORKER_QUEUE', N'DBMIRRORING_CMD',
|
||||
|
||||
N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE',
|
||||
N'EXECSYNC', N'FSAGENT',
|
||||
N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX',
|
||||
|
||||
-- Maybe uncomment these six if you have AG issues
|
||||
N'HADR_CLUSAPI_CALL', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION',
|
||||
N'HADR_LOGCAPTURE_WAIT', N'HADR_NOTIFICATION_DEQUEUE',
|
||||
N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE',
|
||||
|
||||
N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP',
|
||||
N'LOGMGR_QUEUE', N'MEMORY_ALLOCATION_EXT',
|
||||
N'ONDEMAND_TASK_QUEUE',
|
||||
N'PREEMPTIVE_OS_FLUSHFILEBUFFERS',
|
||||
N'PREEMPTIVE_XE_GETTARGETSTATE',
|
||||
N'PWAIT_ALL_COMPONENTS_INITIALIZED',
|
||||
N'PWAIT_DIRECTLOGCONSUMER_GETNEXT',
|
||||
N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', N'QDS_ASYNC_QUEUE',
|
||||
N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP',
|
||||
N'QDS_SHUTDOWN_QUEUE', N'REDO_THREAD_PENDING_WORK',
|
||||
N'REQUEST_FOR_DEADLOCK_SEARCH', N'RESOURCE_QUEUE',
|
||||
N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH',
|
||||
N'SLEEP_DBSTARTUP', N'SLEEP_DCOMSTARTUP',
|
||||
N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY',
|
||||
N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP',
|
||||
N'SLEEP_SYSTEMTASK', N'SLEEP_TASK',
|
||||
N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT',
|
||||
N'SP_SERVER_DIAGNOSTICS_SLEEP', N'SQLTRACE_BUFFER_FLUSH',
|
||||
N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP',
|
||||
N'SQLTRACE_WAIT_ENTRIES', N'VDI_CLIENT_OTHER', N'WAIT_FOR_RESULTS',
|
||||
N'WAITFOR', N'WAITFOR_TASKSHUTDOWN',
|
||||
N'WAIT_XTP_RECOVERY',
|
||||
N'WAIT_XTP_HOST_WAIT', N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG',
|
||||
N'WAIT_XTP_CKPT_CLOSE', N'XE_DISPATCHER_JOIN',
|
||||
N'XE_DISPATCHER_WAIT', N'XE_TIMER_EVENT')
|
||||
AND [waiting_tasks_count] > 0
|
||||
)
|
||||
SELECT
|
||||
MAX ([W1].[wait_type]) AS [WaitType],
|
||||
--CAST (MAX ([W1].[WaitS]) AS DECIMAL (16,2)) AS [Wait_S],
|
||||
--CAST (MAX ([W1].[ResourceS]) AS DECIMAL (16,2)) AS [Resource_S],
|
||||
--CAST (MAX ([W1].[SignalS]) AS DECIMAL (16,2)) AS [Signal_S],
|
||||
--MAX ([W1].[WaitCount]) AS [WaitCount]--,
|
||||
CAST (MAX ([W1].[Percentage]) AS DECIMAL (5,2)) AS [Percentage]
|
||||
--CAST ((MAX ([W1].[WaitS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgWait_S],
|
||||
--CAST ((MAX ([W1].[ResourceS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgRes_S],
|
||||
--CAST ((MAX ([W1].[SignalS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgSig_S],
|
||||
--CAST ('https://www.sqlskills.com/help/waits/' + MAX ([W1].[wait_type]) as XML) AS [Help/Info URL]
|
||||
FROM [Waits] AS [W1]
|
||||
INNER JOIN [Waits] AS [W2]
|
||||
ON [W2].[RowNum] <= [W1].[RowNum]
|
||||
GROUP BY [W1].[RowNum]
|
||||
HAVING SUM ([W2].[Percentage]) - MAX( [W1].[Percentage] ) < 95; -- percentage threshold
|
||||
GO
|
||||
9
extensions/server-report/src/typings/refs.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path='../../../../src/sql/azdata.d.ts'/>
|
||||
/// <reference path='../../../../src/sql/azdata.proposed.d.ts'/>
|
||||
/// <reference path='../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference types='@types/node'/>
|
||||
46
extensions/server-report/src/utils.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as handlebars from 'handlebars';
|
||||
import * as Constants from './constants';
|
||||
import * as LocalizedConstants from './localizedConstants';
|
||||
|
||||
/**
|
||||
* Helper to log messages to the developer console if enabled
|
||||
* @param msg Message to log to the console
|
||||
*/
|
||||
export function logDebug(msg: any): void {
|
||||
let config = vscode.workspace.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let logDebugInfo = config[Constants.configLogDebugInfo];
|
||||
if (logDebugInfo === true) {
|
||||
let currentTime = new Date().toLocaleTimeString();
|
||||
let outputMsg = '[' + currentTime + ']: ' + msg ? msg.toString() : '';
|
||||
console.log(outputMsg);
|
||||
}
|
||||
}
|
||||
|
||||
export function renderTemplateHtml(extensionPath: string, templateName: string, templateValues: object): Thenable<string> {
|
||||
let templatePath = path.join(extensionPath, 'resources', templateName);
|
||||
|
||||
// 1) Read the template from the disk
|
||||
// 2) Compile it as a handlebars template and render the HTML
|
||||
// 3) On failure, return a simple string as an error
|
||||
return fs.readFile(templatePath, 'utf-8')
|
||||
.then(templateText => {
|
||||
let template = handlebars.compile(templateText);
|
||||
return template(templateValues);
|
||||
})
|
||||
.then(
|
||||
undefined,
|
||||
error => {
|
||||
logDebug(error);
|
||||
return LocalizedConstants.msgErrorLoadingTab;
|
||||
}
|
||||
);
|
||||
}
|
||||
23
extensions/server-report/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"extends": "../shared.tsconfig.json",
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"outDir": "./out",
|
||||
"lib": [
|
||||
"es6",
|
||||
"es2015.promise"
|
||||
],
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"declaration": false,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types"
|
||||
],
|
||||
"strict": false,
|
||||
"noUnusedParameters": false,
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
95
extensions/server-report/yarn.lock
Normal file
@@ -0,0 +1,95 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/fs-extra@8.1.0":
|
||||
version "8.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.0.tgz#1114834b53c3914806cd03b3304b37b3bd221a4d"
|
||||
integrity sha512-UoOfVEzAUpeSPmjm7h1uk5MH6KZma2z2O7a75onTGjnNvAvMVrPzPL/vBbT65iIGHWj6rokwfmYcmxmlSf2uwg==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/node@*":
|
||||
version "14.14.22"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18"
|
||||
integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==
|
||||
|
||||
commander@~2.20.3:
|
||||
version "2.20.3"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
|
||||
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
|
||||
|
||||
fs-extra@^8.1.0:
|
||||
version "8.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
|
||||
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
|
||||
dependencies:
|
||||
graceful-fs "^4.2.0"
|
||||
jsonfile "^4.0.0"
|
||||
universalify "^0.1.0"
|
||||
|
||||
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
|
||||
integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
|
||||
|
||||
handlebars@^4.5.3:
|
||||
version "4.7.6"
|
||||
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
|
||||
integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
|
||||
dependencies:
|
||||
minimist "^1.2.5"
|
||||
neo-async "^2.6.0"
|
||||
source-map "^0.6.1"
|
||||
wordwrap "^1.0.0"
|
||||
optionalDependencies:
|
||||
uglify-js "^3.1.4"
|
||||
|
||||
jsonfile@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
|
||||
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
|
||||
optionalDependencies:
|
||||
graceful-fs "^4.1.6"
|
||||
|
||||
minimist@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||
|
||||
neo-async@^2.6.0:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
|
||||
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==
|
||||
|
||||
openurl@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/openurl/-/openurl-1.1.1.tgz#3875b4b0ef7a52c156f0db41d4609dbb0f94b387"
|
||||
integrity sha1-OHW0sO96UsFW8NtB1GCduw+Us4c=
|
||||
|
||||
source-map@^0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||
|
||||
uglify-js@^3.1.4:
|
||||
version "3.9.1"
|
||||
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.9.1.tgz#a56a71c8caa2d36b5556cc1fd57df01ae3491539"
|
||||
integrity sha512-JUPoL1jHsc9fOjVFHdQIhqEEJsQvfKDjlubcCilu8U26uZ73qOg8VsN8O1jbuei44ZPlwL7kmbAdM4tzaUvqnA==
|
||||
dependencies:
|
||||
commander "~2.20.3"
|
||||
|
||||
universalify@^0.1.0:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
|
||||
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||
|
||||
vscode-nls@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
|
||||
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
|
||||
|
||||
wordwrap@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
|
||||
integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=
|
||||