Skip to content

Commit 3f4f737

Browse files
committed
Simplify T-SQL probe sample query
1 parent f9c8b88 commit 3f4f737

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

samples/manage/sql-assessment-api/notebooks/CustomizationSamples/CustomRuleTSQLProbe.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@
1212
"[12.0,12.0.6259.0)",
1313
"[13.0,)"
1414
],
15-
"platform": "/Windows|Linux/"
15+
"platform": [ "Windows", "Linux" ]
1616
},
1717
"id": "DBSpaceAvailable",
1818
"itemType": "definition",
1919
"displayName": "Database files have little free space",
2020
"description": "Average available space in all the database files is less than the threshold.",
21-
"message": "Database has only @{SPACEAVAILABLEPERC}% of free space (threshold is set to @{threshold}%). Total space: @{SPACETOTALMB} MB. Free space: @{SPACEAVAILABLEMB} MB",
21+
"message": "Database has only @{space_available_rel:P0} of free space (threshold is set to @{threshold:P0}). Total space: @{space_total:N2} MB. Free space: @{space_available:N2} MB",
2222
"probes": ["DBSpaceAvailable"],
23-
"threshold": 25,
24-
"condition": [
25-
{"greater": ["@SPACEAVAILABLEPERC", "@threshold"]}
26-
]
27-
}
23+
"threshold": 0.25,
24+
"condition": { "greater": [ "@space_available_rel", "@threshold" ] }
25+
}
2826
],
2927
"probes":{
3028
"DBSpaceAvailable": [
@@ -33,13 +31,12 @@
3331
"target": {
3432
"type": "Database",
3533
"engineEdition": "OnPremises, ManagedInstance",
36-
"platform": "/Windows|Linux/"
34+
"platform": [ "Windows", "Linux" ]
3735
},
3836
"implementation": {
3937
"useDatabase": true,
40-
"query":
41-
"SELECT convert(decimal(12,2),((sum (convert(decimal(12,2),round(a.size/128.000,2))) - sum(convert(decimal(12,2),round(fileproperty(a.name,'SpaceUsed')/128.000,2)))) /sum (convert(decimal(12,2),round(a.size/128.000,2)))*100)) as SPACEAVAILABLEPERC , SUM(convert(decimal(12,2),round(a.size/128.000,2))) as SPACETOTALMB , SUM(convert(decimal(12,2),round(fileproperty(a.name,'SpaceUsed')/128.000,2))) as SPACEUSEDMB , SUM(convert(decimal(12,2),round((a.size-fileproperty(a.name,'SpaceUsed'))/128.000,2))) as SPACEAVAILABLEMB FROM dbo.sysfiles a WHERE groupid <> 0;"
42-
}
38+
"query": "SELECT (total - used)/total AS space_available_rel, total as space_total, used as space_used, total - used as space_available FROM ( SELECT SUM(a.size)/128.0 AS total, SUM(fileproperty(a.name,'SpaceUsed'))/128.0 AS used FROM dbo.sysfiles a WHERE groupid <> 0)data;"
39+
}
4340
}
4441
]
4542
}

0 commit comments

Comments
 (0)