The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
Beeswing
4 years agoNew Contributor III
How to check disk space
Hi,
I've had a dig around, but I can't seem to find it. Anyone know where I can see the disk space utilisation?
We've set up a number of new apps in our environment recently, and I'm concerned we might be running out of space.
21 Replies
- NicolasArgenteValued Contributor
Hi Beeswing,
I do not think you can find this directly and the reason behind is that the space increases automatically on Azure elastic pools. I think you could have a look under System > Environement>OS DB Server and do a filter on ElasticPoolStorageMB. That is the closest thing i can help with.Please give a kudo if it helps 🙂
- MarkMatsonNew Contributor III
Hi, you can check an individual database size with an extensibility rule containing code like this:
Dim sql As String = "EXEC sp_spaceused;"
Dim dbConnApp As DbConnInfoApp = brapi.Database.CreateApplicationDbConnInfo(si)
Using dbConnApp
Using dt As DataTable = BRAPi.Database.ExecuteSql(dbConnApp, sql.ToString, True)
If Not dt Is Nothing Then
'Reference dt to access data table results
For Each dr As DataRow In dt.Rows
'Process rows
brapi.ErrorLog.LogMessage(si, "database_size: " + dr("database_size"))
brapi.ErrorLog.LogMessage(si, "unallocated space: " + dr("unallocated space"))
Next
End If
End Using
End Using - NicoleBrunoValued Contributor
Hello!
We're on the cloud and this is how we review our application space:Bottom right corner of the dashboard lists the GB used by application in the environment where you've originated the dashboard (ie. DEV or PROD environments). Hope that's useful!
- BeeswingNew Contributor III
Hi.. I know it's been a while, but hoping you could provide some more info.
I don't have the Database Statistics Dashboard that you mentioned, and I can't find it on the market place. Is this one you created yourself? Or is it indeed from something in the market place?Thanks
- NicoleBrunoValued Contributor
Hi,
It's not a marketplace tool. Can you try searching your dashboards for "storage chart" and see if it's there?
I assume it's out of the box OS as we didn't create it. If you can't find it, I'd suggest contacting your OS customer success/account manager or maybe submitting a OS support ticket for more direction.
- SpalominoNew Contributor III
Mark: I hope you don't mind. I add the full code. For those like me who struggle with VB. :)
Imports SystemImports System.Collections.GenericImports System.DataImports System.Data.CommonImports System.GlobalizationImports System.IOImports System.LinqImports Microsoft.VisualBasicImports OneStream.Finance.DatabaseImports OneStream.Finance.EngineImports OneStream.Shared.CommonImports OneStream.Shared.DatabaseImports OneStream.Shared.EngineImports OneStream.Shared.WcfImports OneStream.Stage.DatabaseImports OneStream.Stage.EngineNamespace OneStream.BusinessRule.Extender.SJP_GIGChk 'Your Extensibility Rule must be the same name.Public Class MainClassPublic Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As ObjectTry'Hi, you can check an individual database size With an extensibility rule containing code Like this:Dim sql As String = "EXEC sp_spaceused;"Dim dbConnApp As DbConnInfoApp = brapi.Database.CreateApplicationDbConnInfo(si)Using dbConnAppUsing dt As DataTable = BRAPi.Database.ExecuteSql(dbConnApp, sql.ToString, True)If Not dt Is Nothing Then'Reference dt to access data table resultsFor Each dr As DataRow In dt.Rows'Process rowsbrapi.ErrorLog.LogMessage(si, "database_size: " + dr("database_size"))brapi.ErrorLog.LogMessage(si, "unallocated space: " + dr("unallocated space"))NextEnd IfEnd UsingEnd UsingReturn NothingCatch ex As ExceptionThrow ErrorHandler.LogWrite(si, New XFException(si, ex))End TryEnd FunctionEnd ClassEnd Namespace- Sandy2024New Contributor
Hi Spalomino
Thanks for providing this solution. I have a question, where i would see the results after running this business, Rule?
Thank you
Sandy
- jayaleckNew Contributor III
Hope you don't mind, took what you did and ran with it!
Imports SystemImports System.Collections.GenericImports System.DataImports System.Data.CommonImports System.GlobalizationImports System.IOImports System.LinqImports Microsoft.VisualBasicImports OneStream.Finance.DatabaseImports OneStream.Finance.EngineImports OneStream.Shared.CommonImports OneStream.Shared.DatabaseImports OneStream.Shared.EngineImports OneStream.Shared.WcfImports OneStream.Stage.DatabaseImports OneStream.Stage.EngineNamespace OneStream.BusinessRule.Extender.TEST_dbStatsPublic Class MainClassPublic Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As ObjectTryDim AppName As String = si.AppNameBRApi.ErrorLog.LogMessage(si, "SQL Version: v6 - single real-time query, no OSD dependency")' ---------------------------------------------------------------' Database Space Breakdown' ---------------------------------------------------------------' TotalSizeGB = ReservedGB + UnallocatedGB + LogFileGB' ReservedGB = UsedGB + UnusedGB' UsedGB = DataGB + IndexSizeGB'' Definitions:' TotalSizeGB - Full file size on disk (data files + log file)' UnallocatedGB - Free space no object has claimed yet' ReservedGB - Space claimed by tables and indexes' UsedGB - Space actively holding data and indexes' UnusedGB - Reserved by objects but sitting empty' DataGB - Row data only (index_id 0 or 1 = heap/clustered)' IndexSizeGB - Non-clustered indexes only (index_id > 1)' LogFileGB - Derived: TotalSize - Reserved - Unallocated'' Sources:' TotalSizeGB, UnallocatedGB → sys.database_files (real-time)' ReservedGB, DataGB,' IndexSizeGB, UnusedGB → sys.allocation_units' + sys.partitions (real-time)' split on index_id' ---------------------------------------------------------------Dim sql As String ="SELECT " &" DB_NAME() AS DatabaseName, " &" CAST(f.total_size * 8.0 / 1048576 AS DECIMAL(10,2)) AS TotalSizeGB, " &" CAST(f.total_used * 8.0 / 1048576 AS DECIMAL(10,2)) AS UsedByFilesGB, " &" CAST((f.total_size - f.total_used) " &" * 8.0 / 1048576 AS DECIMAL(10,2)) AS UnallocatedGB, " &" CAST(s.reserved_pages * 8.0 / 1048576 AS DECIMAL(10,2)) AS ReservedGB, " &" CAST(s.data_pages * 8.0 / 1048576 AS DECIMAL(10,2)) AS DataGB, " &" CAST(s.index_pages * 8.0 / 1048576 AS DECIMAL(10,2)) AS IndexSizeGB, " &" CAST((s.reserved_pages - s.data_pages - s.index_pages) " &" * 8.0 / 1048576 AS DECIMAL(10,2)) AS UnusedGB " &"FROM ( " &" SELECT " &" SUM(size) AS total_size, " &" SUM(FILEPROPERTY(name, 'SpaceUsed')) AS total_used " &" FROM sys.database_files " &") f " &"CROSS JOIN ( " &" SELECT " &" SUM(a.total_pages) AS reserved_pages, " &" SUM(CASE WHEN p.index_id IN (0,1) " &" THEN a.used_pages " &" ELSE 0 END) AS data_pages, " &" SUM(CASE WHEN p.index_id > 1 " &" THEN a.used_pages " &" ELSE 0 END) AS index_pages " &" FROM sys.partitions p " &" JOIN sys.allocation_units a " &" ON p.partition_id = a.container_id " &") s"Dim dbConnApp As DbConnInfoApp = BRApi.Database.CreateApplicationDbConnInfo(si)Dim totalSize As Decimal = 0Dim usedByFiles As Decimal = 0Dim unalloc As Decimal = 0Dim reserved As Decimal = 0Dim data As Decimal = 0Dim indexSize As Decimal = 0Dim unused As Decimal = 0Dim dbName As String = "N/A"Using dbConnAppUsing dt As DataTable = BRApi.Database.ExecuteSql(dbConnApp, sql, True)If dt IsNot Nothing AndAlso dt.Rows.Count > 0 ThenDim dr As DataRow = dt.Rows(0)dbName = dr("DatabaseName").ToString()totalSize = CDec(dr("TotalSizeGB"))usedByFiles = CDec(dr("UsedByFilesGB"))unalloc = CDec(dr("UnallocatedGB"))reserved = CDec(dr("ReservedGB"))data = CDec(dr("DataGB"))indexSize = CDec(dr("IndexSizeGB"))unused = CDec(dr("UnusedGB"))End IfEnd UsingEnd Using' ---------------------------------------------------------------' Derive UsedGB and LogFileGB in VB' ---------------------------------------------------------------Dim usedGB As Decimal = Math.Round(data + indexSize, 2)Dim logFileGB As Decimal = Math.Round(totalSize - reserved - unalloc, 2)' ---------------------------------------------------------------' Percentage breakdown — against TotalSizeGB as baseline' ---------------------------------------------------------------Dim pctReserved As Decimal = Math.Round(reserved / totalSize * 100, 1)Dim pctUsed As Decimal = Math.Round(usedGB / totalSize * 100, 1)Dim pctData As Decimal = Math.Round(data / totalSize * 100, 1)Dim pctIndex As Decimal = Math.Round(indexSize / totalSize * 100, 1)Dim pctUnused As Decimal = Math.Round(unused / totalSize * 100, 1)Dim pctUnalloc As Decimal = Math.Round(unalloc / totalSize * 100, 1)Dim pctLog As Decimal = Math.Round(logFileGB / totalSize * 100, 1)' ---------------------------------------------------------------' Math verification checks' ---------------------------------------------------------------Dim checkTotal As Decimal = Math.Round(reserved + unalloc + logFileGB, 2)Dim checkReserved As Decimal = Math.Round(usedGB + unused, 2)Dim checkUsed As Decimal = Math.Round(data + indexSize, 2)Dim totalRounded As Decimal = Math.Round(totalSize, 2)Dim reservedRounded As Decimal = Math.Round(reserved, 2)' ---------------------------------------------------------------' Log full breakdown' ---------------------------------------------------------------BRApi.ErrorLog.LogMessage(si,$"App: {AppName} | DB: {dbName} | " &$"--- Level 1 (Total) --- " &$"TotalSize: {totalSize} GB | " &$"UsedByFiles: {usedByFiles} GB | " &$"Unallocated: {unalloc} GB ({pctUnalloc}% of Total) | " &$"LogFile: {logFileGB} GB ({pctLog}% of Total) | " &$"--- Level 2 (Reserved) --- " &$"Reserved: {reserved} GB ({pctReserved}% of Total) | " &$"UsedGB (Data+Index): {usedGB} GB ({pctUsed}% of Total) | " &$"Unused: {unused} GB ({pctUnused}% of Total) | " &$"--- Level 3 (Used) --- " &$"Data: {data} GB ({pctData}% of Total) | " &$"IndexSize: {indexSize} GB ({pctIndex}% of Total) | " &$"--- Math Checks --- " &$"Total=Reserved+Unalloc+Log: {checkTotal} = {totalRounded} → {checkTotal = totalRounded} | " &$"Reserved=Used+Unused: {checkReserved} = {reservedRounded} → {checkReserved = reservedRounded} | " &$"Used=Data+Index: {checkUsed} = {usedGB} → {checkUsed = usedGB}")Return NothingCatch ex As ExceptionThrow ErrorHandler.LogWrite(si, New XFException(si, ex))End TryEnd FunctionEnd ClassEnd Namespace
- T_Kress
OneStream Employee
The system diagnostics dashboard has that info here:
- SpalominoNew Contributor III
Sandy: The output of the code shows up in the System>Error Log. You will see two lines one for unallocated space, the other for database_size.
T_Kress: Thanks for sharing. I did download that application, but I couldn't get it to run on my version of 8.5. That is why I went the code direction.
Thanks,
SP
- Sandy2024New Contributor
I tried this solution, and it works perfectly for an application. It would show the size details for that specific app which is open. I am just wondering if it's possible to make this rule work for Environment level?
- SpalominoNew Contributor III
Sandy: I am sure that is possible. We would just need to find the SQL stored command that would provide that information. I'll look around and see what I can find.
Related Content
- 4 months ago
- 5 months ago
- 3 years ago
- 2 years ago