Skip to content

Commit

Permalink
Merge pull request #1 from Matticusau/Dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Matticusau authored Apr 20, 2018
2 parents ffae6c9 + 9fa090f commit 630090e
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.vsix
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387

// To debug the extension:
// 1. please install the "SQL Operations Studio Debug" extension into VSCode
// 2. Ensure sqlops is added to your path:
// - open SQL Operations Studio
// - run the command "Install 'sqlops' command in PATH"
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "sqlopsExtensionHost",
"request": "launch",
"runtimeExecutable": "sqlops",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}\\src"
]
}
]
}
4 changes: 4 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
57 changes: 57 additions & 0 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[CmdLetBinding()]
Param (
[Parameter()]
[string]$BuildDir
)

[string]$scriptPath = $PSScriptRoot;

# set the location history
Push-Location;

# make sure the releases folder exists
if ($null -eq $BuildDir -or $BuildDir.Length -eq 0)
{
$BuildDir = Join-Path -Path $scriptPath -ChildPath 'Build';
}
if (-not(Test-Path -Path $BuildDir))
{
New-Item -Path $BuildDir -ItemType Directory -Force | Out-Null;
}

# Get the packages to build in this repo
$packageFiles = Get-ChildItem -Path $scriptPath -Recurse -Filter 'package.json'

if ($packageFiles.Count -eq 0)
{
Write-Error -Message 'No Extensions found to package'
Exit
}

# set our working location to the build folder
Set-Location -Path $BuildDir;

# process each package found
foreach ($package in $packageFiles)
{
Write-Verbose -Message "Processing $($package.fullname)";

# try
# {
Set-Location -Path $package.DirectoryName;
vsce.cmd package;
Get-ChildItem -Path $package.DirectoryName -Filter '*.vsix' | Move-Item -Destination $BuildDir -Force;
# }
# catch
# {

# }

Write-Verbose -Message ('Finished processing package {0}' -f $packageJson.name);

}

# return to the previous user location
Pop-Location;

Write-Verbose -Message 'Extension Packaging Complete';
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Change Log

All notable changes to the "sqlops-mssql-instance-insights" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]

- None

## [0.2.0-beta1]

### Added

- Migration of code from [https://github.com/Matticusau/sqlops-widgets](https://github.com/Matticusau/sqlops-widgets)
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# MSSQL-Database-Insights widget

This collection of widgets are designed to provide insights into MSSQL Database to further extend the built-in default widgets.

Where possible all of these widgets will include more detail when you click *_Show Details_* from the widget menu.

See the [package README](./src/README.md) for more information.

## Change Log

See the [Change Log](./CHANGELOG.md) for the full changes.

## License

This project is released under the [MIT License](./LICENSE)

## Contributors

* Matticusau [GitHub](https://github.com/Matticusau) | [twitter](https://twitter.com/matticusau)
60 changes: 60 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# MSSQL-Database-Insights widget

This collection of widgets are designed to provide insights into MSSQL Database to further extend the built-in default widgets.

Where possible all of these widgets will include more detail when you click *_Show Details_* from the widget menu.

![Show details](../docs/images/show-detail.png)

## Supported SQL Server Versions

These widgets have been tested against the following SQL Server versions:

* SQL Server 2016
* SQL Server 2017 (Windows & linux)

If you find any issues using these widgets on these supported SQL Server versions, or any other versions please create an issue as we would like to make these available for as many releases as possible.

***We are looking for testers to confirm other environments.*** So if you find they do work on other releases let me know, and credit will be given.

## mssql-db-spaceused

This Database Dashboard widget includes information on the current used space within a Database. Information will be shown in the form of a pie chart displaying the percentage of used space verses free space.

![mssql-db-spaceused.png](../docs/images/mssql-database-insights/mssql-db-spaceused.png)

You can access more information about the space usaged in the detailed fly-out displayed when you select "..." on the widget.

![mssql-db-spaceused-details.png](../docs/images/mssql-database-insights/mssql-db-spaceused-details.png)

To enable this widget add the following json to either your user or workspace settings in the *dashboard.database.widgets* section.

```json
{
"name": "DB Space Used",
"widget": {
"mssql-db-spaceused": null
}
}
```

## mssql-db-spaceused-filetype

This Database Dashboard widget includes information on the current used space within a Database broken down by the various file types (ROWS, LOG). Information will be shown in the form of a bar chart displaying the percentage of used space verses free space for each file type.

![mssql-db-spaceused-filetype.png](../docs/images/mssql-database-insights/mssql-db-spaceused-filetype.png)

You can access more information about the space usaged in the detailed fly-out displayed when you select "..." on the widget.

![mssql-db-spaceused-details.png](../docs/images/mssql-database-insights/mssql-db-spaceused-details.png)

To enable this widget add the following json to either your user or workspace settings in the *dashboard.database.widgets* section.

```json
{
"name": "DB Space Used (by filetype)",
"widget": {
"mssql-db-spaceused-filetype": null
}
}
```
158 changes: 158 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"name": "mssql-db-insights",
"displayName": "MSSQL Db Insights",
"description": "Sql Server Database insights",
"version": "0.2.0-beta1",
"publisher": "matticusau",
"license": "MIT",
"author": {
"email": "[email protected]",
"name": "Matt Lavery",
"url": "http://www.matticus.net"
},
"repository": {
"type": "git",
"url": "https://github.com/matticusau/sqlops-mssql-db-insights"
},
"bugs": {
"url": "https://github.com/matticusau/sqlops-mssql-db-insights/issues"
},
"engines": {
"vscode": "^1.22.0",
"sqlops": "*"
},
"categories": [
"Other"
],
"homepage": "https://github.com/matticusau/sqlops-mssql-db-insights",
"contributes": {
"dashboard.insights": [
{
"id": "mssql-db-spaceused.insight",
"contrib": {
"queryFile": "./sql/mssql-db-spaceused.sql",
"type": {
"pie": {
"dataDirection": "horizontal",
"dataType": "number",
"legendPosition": "bottom",
"labelFirstColumn": false,
"columnsAsLabels": false
}
},
"details": {
"queryFile": "./sql/mssql-db-spaceused-detail.sql",
"label": {
"icon": "database",
"column": "file_name",
"state": [
{
"condition": {
"if": "greaterthan",
"greaterthan": "95"
},
"color": "red"
},
{
"condition": {
"if": "greaterthan",
"greaterthan": "85"
},
"color": "orange"
},
{
"condition": {
"if": "lessthan",
"lessthan": "86"
},
"color": "green"
}
]
},
"value": "used_space_percent",
"actions": null
}
}
},
{
"id": "mssql-db-spaceused-filetype.insight",
"contrib": {
"queryFile": "./sql/mssql-db-spaceused-filetype.sql",
"type": {
"horizontalBar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "bottom",
"labelFirstColumn": true,
"columnsAsLabels": true
}
},
"details": {
"queryFile": "./sql/mssql-db-spaceused-detail.sql",
"label": {
"icon": "database",
"column": "file_name",
"state": [
{
"condition": {
"if": "greaterthan",
"greaterthan": "95"
},
"color": "red"
},
{
"condition": {
"if": "greaterthan",
"greaterthan": "85"
},
"color": "orange"
},
{
"condition": {
"if": "lessthan",
"lessthan": "86"
},
"color": "green"
}
]
},
"value": "used_space_percent",
"actions": null
}
}
}
]
,
"dashboard.tabs": [
{
"id": "mssql-db-insights.tab",
"title": "MSSQL Db Insights",
"description": "SQL Server Database insights and widgets",
"container": {
"widgets-container": [
{
"name": "Database Space Used",
"gridItemConfig": {
"sizex": 1,
"sizey": 1
},
"widget": {
"mssql-db-spaceused.insight": {}
}
},
{
"name": "Database Space Used (File Type)",
"gridItemConfig": {
"sizex": 1,
"sizey": 1
},
"widget": {
"mssql-db-spaceused-filetype.insight": {}
}
}
]
}
}
]
}
}
18 changes: 18 additions & 0 deletions src/sql/mssql-db-spaceused-detail.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--
-- Author: Matticusau
-- Purpose: Provides detailed data for the DB Space Used Insights Widget
-- License: https://github.com/Matticusau/sqlops-widgets/blob/master/LICENSE
--
SELECT file_id
, name [file_name]
, type_desc
, physical_name
, CONVERT(decimal(18,2), size/128.0) [file_size_mb]
, CONVERT(decimal(18,2), max_size/128.0) [max_growth_size_mb]
, CONVERT(decimal(18,2), FILEPROPERTY(name, 'SpaceUsed')/128.0) [used_space_mb]
, CONVERT(decimal(18,2), size/128.0) - CONVERT(decimal(18,2), FILEPROPERTY(name,'SpaceUsed')/128.0) AS [free_space_mb]
, CONVERT(decimal(18,2), (FILEPROPERTY(name, 'SpaceUsed')/128.0) / (size/128.0) * 100) [used_space_percent]
, 100 - CONVERT(decimal(18,2), (FILEPROPERTY(name, 'SpaceUsed')/128.0) / (size/128.0) * 100) AS [free_space_percent]
FROM sys.database_files
ORDER BY type_desc
, file_id
16 changes: 16 additions & 0 deletions src/sql/mssql-db-spaceused-filetype.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--
-- Author: Matticusau
-- Purpose: Provides summary data for the DB Space Used Insights Widget
-- License: https://github.com/Matticusau/sqlops-widgets/blob/master/LICENSE
--
SELECT type_desc
-- , CONVERT(decimal(18,2), SUM(size)/128.0) [file_size_mb]
-- , CONVERT(decimal(18,2), SUM(max_size)/128.0) [max_growth_size_mb]
-- , CONVERT(decimal(18,2), SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) [used_space_mb]
-- , CONVERT(decimal(18,2), SUM(size)/128.0) - CONVERT(decimal(18,2), SUM(FILEPROPERTY(name,'SpaceUsed'))/128.0) AS [free_space_mb]
, CONVERT(decimal(18,2), (SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) / (SUM(size)/128.0) * 100) [used_space_percent]
, 100 - CONVERT(decimal(18,2), (SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) / (SUM(size)/128.0) * 100) AS [free_space_percent]
FROM sys.database_files
WHERE type_desc IN ('ROWS','LOG')
GROUP BY type_desc
ORDER BY type_desc
Loading

0 comments on commit 630090e

Please sign in to comment.