mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Initial improvement in sp_whoisactive (#1249)
* improve sp_whoisactive extension * formatting * use a grouping prefix for extension commands
This commit is contained in:
2
samples/sp_whoIsActive/package-lock.json
generated
2
samples/sp_whoIsActive/package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "whoisactive",
|
"name": "whoisactive",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "whoisactive",
|
"name": "whoisactive",
|
||||||
"displayName": "whoisactive",
|
"displayName": "whoisactive",
|
||||||
"description": "sp_whoisactive for SQL Operations Studio",
|
"description": "sp_whoisactive for SQL Operations Studio",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"publisher": "Microsoft",
|
"publisher": "Microsoft",
|
||||||
"preview": true,
|
"preview": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "sp_whoisactive.install",
|
"command": "sp_whoisactive.install",
|
||||||
"title": "Install sp_whoisactive",
|
"title": "Whoisactive: Install sp_whoisactive",
|
||||||
"icon": {
|
"icon": {
|
||||||
"light": "./out/src/media/download.svg",
|
"light": "./out/src/media/download.svg",
|
||||||
"dark": "./out/src/media/download_inverse.svg"
|
"dark": "./out/src/media/download_inverse.svg"
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "sp_whoisactive.findBlockLeaders",
|
"command": "sp_whoisactive.findBlockLeaders",
|
||||||
"title": "Find leader of block",
|
"title": "Whoisactive: Find leader of block",
|
||||||
"icon": {
|
"icon": {
|
||||||
"light": "./out/src/media/blocker.svg",
|
"light": "./out/src/media/blocker.svg",
|
||||||
"dark": "./out/src/media/blocker_inverse.svg"
|
"dark": "./out/src/media/blocker_inverse.svg"
|
||||||
@@ -40,11 +40,19 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "sp_whoisactive.getPlans",
|
"command": "sp_whoisactive.getPlans",
|
||||||
"title": "Get plans",
|
"title": "Whoisactive: Get plans",
|
||||||
"icon": {
|
"icon": {
|
||||||
"light": "./out/src/media/monitor.svg",
|
"light": "./out/src/media/monitor.svg",
|
||||||
"dark": "./out/src/media/monitor_inverse.svg"
|
"dark": "./out/src/media/monitor_inverse.svg"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "sp_whoisactive.documentation",
|
||||||
|
"title": "Whoisactive: Documentation",
|
||||||
|
"icon": {
|
||||||
|
"light": "./out/src/media/documentation.svg",
|
||||||
|
"dark": "./out/src/media/documentation_inverse.svg"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"views": {},
|
"views": {},
|
||||||
@@ -54,32 +62,9 @@
|
|||||||
"id": "sp_whoisactive",
|
"id": "sp_whoisactive",
|
||||||
"title": "sp_whoisactive",
|
"title": "sp_whoisactive",
|
||||||
"description": "Extension for checking who is active.",
|
"description": "Extension for checking who is active.",
|
||||||
"container": {
|
|
||||||
"nav-section": [
|
|
||||||
{
|
|
||||||
"id": "sp_whoisactive_insights",
|
|
||||||
"title": "Insights",
|
|
||||||
"icon": {
|
|
||||||
"light": "./out/src/media/insights.svg",
|
|
||||||
"dark": "./out/src/media/insights_inverse.svg"
|
|
||||||
},
|
|
||||||
"container": {
|
"container": {
|
||||||
"sp_whoisactive-insights": {}
|
"sp_whoisactive-insights": {}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "sp_whoisactive_documentation",
|
|
||||||
"title": "Documentation",
|
|
||||||
"icon": {
|
|
||||||
"light": "./out/src/media/documentation.svg",
|
|
||||||
"dark": "./out/src/media/documentation_inverse.svg"
|
|
||||||
},
|
|
||||||
"container": {
|
|
||||||
"webview-container": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dashboard.insights": [
|
"dashboard.insights": [
|
||||||
@@ -92,7 +77,8 @@
|
|||||||
"dataType": "number",
|
"dataType": "number",
|
||||||
"legendPosition": "none",
|
"legendPosition": "none",
|
||||||
"labelFirstColumn": false,
|
"labelFirstColumn": false,
|
||||||
"columnsAsLabels": true
|
"columnsAsLabels": true,
|
||||||
|
"showTopNData": 5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"queryFile": "./out/src/sql/cpuUsage.sql"
|
"queryFile": "./out/src/sql/cpuUsage.sql"
|
||||||
@@ -107,7 +93,8 @@
|
|||||||
"dataType": "number",
|
"dataType": "number",
|
||||||
"legendPosition": "none",
|
"legendPosition": "none",
|
||||||
"labelFirstColumn": false,
|
"labelFirstColumn": false,
|
||||||
"columnsAsLabels": true
|
"columnsAsLabels": true,
|
||||||
|
"showTopNData": 5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"queryFile": "./out/src/sql/cpuDelta.sql"
|
"queryFile": "./out/src/sql/cpuDelta.sql"
|
||||||
@@ -122,7 +109,8 @@
|
|||||||
"dataType": "number",
|
"dataType": "number",
|
||||||
"legendPosition": "none",
|
"legendPosition": "none",
|
||||||
"labelFirstColumn": false,
|
"labelFirstColumn": false,
|
||||||
"columnsAsLabels": true
|
"columnsAsLabels": true,
|
||||||
|
"showTopNData": 5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"queryFile": "./out/src/sql/memoryUsage.sql"
|
"queryFile": "./out/src/sql/memoryUsage.sql"
|
||||||
@@ -137,11 +125,21 @@
|
|||||||
"dataType": "number",
|
"dataType": "number",
|
||||||
"legendPosition": "none",
|
"legendPosition": "none",
|
||||||
"labelFirstColumn": false,
|
"labelFirstColumn": false,
|
||||||
"columnsAsLabels": true
|
"columnsAsLabels": true,
|
||||||
|
"showTopNData": 5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"queryFile": "./out/src/sql/memoryDelta.sql"
|
"queryFile": "./out/src/sql/memoryDelta.sql"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "sp_whoisactive-blocking_sessions",
|
||||||
|
"contrib": {
|
||||||
|
"type": {
|
||||||
|
"table": null
|
||||||
|
},
|
||||||
|
"queryFile": "./out/src/sql/blockingSessions.sql"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dashboard.containers": [
|
"dashboard.containers": [
|
||||||
@@ -155,12 +153,13 @@
|
|||||||
"tasks-widget": [
|
"tasks-widget": [
|
||||||
"sp_whoisactive.getPlans",
|
"sp_whoisactive.getPlans",
|
||||||
"sp_whoisactive.findBlockLeaders",
|
"sp_whoisactive.findBlockLeaders",
|
||||||
|
"sp_whoisactive.documentation",
|
||||||
"sp_whoisactive.install"
|
"sp_whoisactive.install"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "CPU Usage",
|
"name": "Top 5 CPU Usage",
|
||||||
"gridItemConfig": {
|
"gridItemConfig": {
|
||||||
"sizex": 2,
|
"sizex": 2,
|
||||||
"sizey": 1
|
"sizey": 1
|
||||||
@@ -170,7 +169,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "CPU Delta",
|
"name": "Top 5 CPU Delta",
|
||||||
"gridItemConfig": {
|
"gridItemConfig": {
|
||||||
"sizex": 2,
|
"sizex": 2,
|
||||||
"sizey": 1
|
"sizey": 1
|
||||||
@@ -180,7 +179,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Memory Usage",
|
"name": "Top 5 Memory Usage",
|
||||||
"gridItemConfig": {
|
"gridItemConfig": {
|
||||||
"sizex": 2,
|
"sizex": 2,
|
||||||
"sizey": 1
|
"sizey": 1
|
||||||
@@ -190,7 +189,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Memory Delta",
|
"name": "Top 5 Memory Delta",
|
||||||
"gridItemConfig": {
|
"gridItemConfig": {
|
||||||
"sizex": 2,
|
"sizex": 2,
|
||||||
"sizey": 1
|
"sizey": 1
|
||||||
@@ -198,6 +197,16 @@
|
|||||||
"widget": {
|
"widget": {
|
||||||
"sp_whoisactive-memory-delta": {}
|
"sp_whoisactive-memory-delta": {}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Blocking Sessions",
|
||||||
|
"gridItemConfig": {
|
||||||
|
"sizex": 2,
|
||||||
|
"sizey": 1
|
||||||
|
},
|
||||||
|
"widget": {
|
||||||
|
"sp_whoisactive-blocking_sessions": {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,23 +29,16 @@ export default class MainController extends ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public activate(): Promise<boolean> {
|
public activate(): Promise<boolean> {
|
||||||
sqlops.dashboard.registerWebviewProvider('sp_whoisactive_documentation', webview => {
|
sqlops.tasks.registerTask('sp_whoisactive.install', e => this.openurl('http://whoisactive.com/downloads/'));
|
||||||
let templateValues = {url: 'http://whoisactive.com/docs/'};
|
sqlops.tasks.registerTask('sp_whoisactive.documentation', e => this.openurl('http://whoisactive.com/docs/'));
|
||||||
Utils.renderTemplateHtml(path.join(__dirname, '..'), 'templateTab.html', templateValues)
|
|
||||||
.then(html => {
|
|
||||||
webview.html = html;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
sqlops.tasks.registerTask('sp_whoisactive.install', e => this.onInstall(e));
|
|
||||||
sqlops.tasks.registerTask('sp_whoisactive.findBlockLeaders', e => this.onExecute(e, 'findBlockLeaders.sql'));
|
sqlops.tasks.registerTask('sp_whoisactive.findBlockLeaders', e => this.onExecute(e, 'findBlockLeaders.sql'));
|
||||||
sqlops.tasks.registerTask('sp_whoisactive.getPlans', e => this.onExecute(e, 'getPlans.sql'));
|
sqlops.tasks.registerTask('sp_whoisactive.getPlans', e => this.onExecute(e, 'getPlans.sql'));
|
||||||
|
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onInstall(connection: sqlops.IConnectionProfile): void {
|
private openurl(link: string): void {
|
||||||
openurl.open('http://whoisactive.com/downloads/');
|
openurl.open(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onExecute(connection: sqlops.IConnectionProfile, fileName: string): void {
|
private onExecute(connection: sqlops.IConnectionProfile, fileName: string): void {
|
||||||
|
|||||||
4
samples/sp_whoIsActive/src/sql/blockingSessions.sql
Normal file
4
samples/sp_whoIsActive/src/sql/blockingSessions.sql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
SELECT blocking_session_id
|
||||||
|
FROM sys.dm_os_waiting_tasks
|
||||||
|
WHERE
|
||||||
|
blocking_session_id IS NOT NULL
|
||||||
Reference in New Issue
Block a user