Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Storage Node #657

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions DBADashDB/dbo/Stored Procedures/DBFiles_Get.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
@IncludeOK BIT=0,
@FilegroupLevel BIT=1,
@Types VARCHAR(50)=NULL,
@ShowHidden BIT=1
@ShowHidden BIT=1,
@DriveName NVARCHAR(256)=NULL
)
AS
DECLARE @StatusSQL NVARCHAR(MAX)
Expand Down Expand Up @@ -86,7 +87,8 @@ WHERE 1=1
)' END + '
' + @StatusSQL + '
' + CASE WHEN @DatabaseID IS NULL THEN '' ELSE 'AND F.DatabaseID = @DatabaseID' END + '
' + CASE WHEN @ShowHidden=1 THEN '' ELSE 'AND F.ShowInSummary=1' END
' + CASE WHEN @ShowHidden=1 THEN '' ELSE 'AND F.ShowInSummary=1' END + '
' + CASE WHEN @DriveName IS NULL THEN '' ELSE 'AND F.physical_name LIKE @DriveName + ''%''' END

PRINT @SQL
EXEC sp_executesql @SQL,N'@InstanceIDs VARCHAR(MAX), @DatabaseID INT, @Types VARCHAR(50)', @InstanceIDs, @DatabaseID, @Types
EXEC sp_executesql @SQL,N'@InstanceIDs VARCHAR(MAX), @DatabaseID INT, @Types VARCHAR(50),@DriveName NVARCHAR(256)', @InstanceIDs, @DatabaseID, @Types, @DriveName
17 changes: 14 additions & 3 deletions DBADashDB/dbo/Stored Procedures/Drives_Get.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
CREATE PROC [dbo].[Drives_Get](
CREATE PROC dbo.Drives_Get(
@InstanceIDs VARCHAR(MAX)=NULL,
@IncludeCritical BIT=1,
@IncludeWarning BIT=1,
@IncludeNA BIT=0,
@IncludeOK BIT=0,
@IncludeMetrics BIT=0,
@ShowHidden BIT=1
@ShowHidden BIT=1,
@DriveName NVARCHAR(256)=NULL,
@HasMetrics BIT=0
)
AS
DECLARE @StatusSQL NVARCHAR(MAX)
Expand Down Expand Up @@ -83,9 +85,18 @@ WHERE ' + CASE WHEN @InstanceIDs IS NULL OR @InstanceIDs = ''
WHERE ss.value = D.InstanceID)' END + '
' + @StatusSQL + '
' + CASE WHEN @ShowHidden=1 THEN '' ELSE 'AND D.ShowInSummary=1' END + '
' + CASE WHEN @DriveName IS NULL THEN '' ELSE 'AND D.Name = @DriveName' END + '
' + CASE WHEN @HasMetrics = 1 THEN 'AND EXISTS(
SELECT 1
FROM dbo.DBIOStats IOS
WHERE IOS.InstanceID = D.InstanceID
AND IOS.DatabaseID=-1
AND IOS.FileID = -1
AND IOS.Drive = CAST(LEFT(D.Name,1) AS CHAR(1))
) ' ELSE '' END + '
ORDER BY Status DESC, PctFreeSpace DESC;'

EXEC sp_executesql @SQL,N'@InstanceIDs VARCHAR(MAX)',@InstanceIDs
EXEC sp_executesql @SQL,N'@InstanceIDs VARCHAR(MAX),@DriveName NVARCHAR(256)',@InstanceIDs,@DriveName
GO
GRANT EXECUTE
ON OBJECT::[dbo].[Drives_Get] TO [Reports]
Expand Down
22 changes: 11 additions & 11 deletions DBADashGUI/AgentJobs/JobStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ public DataTable GetJobStatsSummary()
}

private readonly Dictionary<string, ColumnMetaData> columns = new() {
{"SucceededCount", new ColumnMetaData{Alias="Succeeded Count",isVisible=true,axis=1 } },
{"FailedCount", new ColumnMetaData{Alias="Failed Count",isVisible=true, axis=1 } },
{"RetryCount", new ColumnMetaData{Alias="Retry Count",isVisible=false,axis=1 } },
{"AvgDurationSec", new ColumnMetaData{Alias="Avg Duration",isVisible=true } },
{"MaxDurationSec", new ColumnMetaData{Alias="Max Duration",isVisible=false } },
{"MinDurationSec", new ColumnMetaData{Alias="Min Duration",isVisible=false } },
{"TotalDurationSec", new ColumnMetaData{Alias="Total Duration",isVisible=false } }
{"SucceededCount", new ColumnMetaData{Name="Succeeded Count",IsVisible=true,axis=1 } },
{"FailedCount", new ColumnMetaData{Name="Failed Count",IsVisible=true, axis=1 } },
{"RetryCount", new ColumnMetaData{Name="Retry Count",IsVisible=false,axis=1 } },
{"AvgDurationSec", new ColumnMetaData{Name="Avg Duration",IsVisible=true } },
{"MaxDurationSec", new ColumnMetaData{Name="Max Duration",IsVisible=false } },
{"MinDurationSec", new ColumnMetaData{Name="Min Duration",IsVisible=false } },
{"TotalDurationSec", new ColumnMetaData{Name="Total Duration",IsVisible=false } }
};

public void SetContext(DBADashContext context)
Expand Down Expand Up @@ -125,7 +125,7 @@ private void RefreshChart()
}
tsDateGroup.Visible = true;
tsMeasures.Visible = true;
columns["RetryCount"].isVisible = columns["RetryCount"].isVisible && (StepID > 0 || selectedStepID > 0);
columns["RetryCount"].IsVisible = columns["RetryCount"].IsVisible && (StepID > 0 || selectedStepID > 0);
tsMeasures.DropDownItems["RetryCount"].Enabled = StepID > 0 || selectedStepID > 0;

splitContainer1.Panel1Collapsed = false;
Expand Down Expand Up @@ -177,12 +177,12 @@ private void JobStats_Load(object sender, EventArgs e)
dgv.Columns.Add(new DataGridViewLinkColumn() { Name = "colView", HeaderText = "View", Text = "View", UseColumnTextForLinkValue = true, LinkColor = DashColors.LinkColor });
foreach (var c in columns)
{
var dd = new ToolStripMenuItem(c.Value.Alias)
var dd = new ToolStripMenuItem(c.Value.Name)
{
Name = (string)c.Key,
CheckOnClick = true
};
dd.Checked = dd.Enabled && c.Value.isVisible;
dd.Checked = dd.Enabled && c.Value.IsVisible;
dd.Click += MeasureDropDown_Click;
tsMeasures.DropDownItems.Add(dd);
}
Expand All @@ -191,7 +191,7 @@ private void JobStats_Load(object sender, EventArgs e)
private void MeasureDropDown_Click(object sender, EventArgs e)
{
var ts = (ToolStripMenuItem)sender;
columns[ts.Name].isVisible = ts.Checked;
columns[ts.Name].IsVisible = ts.Checked;
RefreshChart();
}

Expand Down
10 changes: 2 additions & 8 deletions DBADashGUI/Bak/BackupsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,18 +529,12 @@ private void TsCopyDetail_Click(object sender, EventArgs e)

private void TsCols_Click(object sender, EventArgs e)
{
using (var frm = new SelectColumns() { Columns = dgvSummary.Columns })
{
frm.ShowDialog(this);
}
dgvSummary.PromptColumnSelection();
}

private void TsDetailCols_Click(object sender, EventArgs e)
{
using (var frm = new SelectColumns() { Columns = dgvBackups.Columns })
{
frm.ShowDialog(this);
}
dgvBackups.PromptColumnSelection();
}
}
}
5 changes: 1 addition & 4 deletions DBADashGUI/Changes/AzureDBResourceGovernance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ private void TsExcel_Click(object sender, EventArgs e)

private void TsCols_Click(object sender, EventArgs e)
{
using (var frm = new SelectColumns() { Columns = dgv.Columns })
{
frm.ShowDialog(this);
}
dgv.PromptColumnSelection();
}
}
}
5 changes: 1 addition & 4 deletions DBADashGUI/Changes/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ private void TsExcel_Click(object sender, EventArgs e)

private void TsCols_Click(object sender, EventArgs e)
{
using (var frm = new SelectColumns() { Columns = dgvConfig.Columns })
{
frm.ShowDialog(this);
}
dgvConfig.PromptColumnSelection();
}
}
}
5 changes: 1 addition & 4 deletions DBADashGUI/Changes/DBConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ private void TsExcelHistory_Click(object sender, EventArgs e)

private void TsCols_Click(object sender, EventArgs e)
{
using (var frm = new SelectColumns() { Columns = dgvConfig.Columns })
{
frm.ShowDialog(this);
}
dgvConfig.PromptColumnSelection();
}
}
}
3 changes: 1 addition & 2 deletions DBADashGUI/Changes/DBOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,7 @@ private void TsExcelHistory_Click(object sender, EventArgs e)

private void TsCols_Click(object sender, EventArgs e)
{
using var frm = new SelectColumns() { Columns = dgv.Columns };
frm.ShowDialog(this);
dgv.PromptColumnSelection();
}

private void Dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
Expand Down
5 changes: 1 addition & 4 deletions DBADashGUI/Changes/HardwareChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ private void TsExcel_Click(object sender, EventArgs e)

private void TsCols_Click(object sender, EventArgs e)
{
using (var frm = new SelectColumns() { Columns = dgvHardware.Columns })
{
frm.ShowDialog(this);
}
dgvHardware.PromptColumnSelection();
}
}
}
5 changes: 1 addition & 4 deletions DBADashGUI/Changes/SQLPatching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ private void TsExcelHistory_Click(object sender, EventArgs e)

private void TsCols_Click(object sender, EventArgs e)
{
using (var frm = new SelectColumns() { Columns = dgvVersion.Columns })
{
frm.ShowDialog(this);
}
dgvVersion.PromptColumnSelection();
}
}
}
5 changes: 1 addition & 4 deletions DBADashGUI/Checks/IdentityColumns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,7 @@ private void TsRefresh_Click(object sender, EventArgs e)

private void TsColumns_Click(object sender, EventArgs e)
{
using (var frm = new SelectColumns() { Columns = dgv.Columns })
{
frm.ShowDialog(this);
}
dgv.PromptColumnSelection();
}

private void TsCopy_Click(object sender, EventArgs e)
Expand Down
10 changes: 5 additions & 5 deletions DBADashGUI/ColumnMetaData.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using LiveCharts.Defaults;
using DBADashGUI.Pickers;
using LiveCharts.Defaults;
using System;

namespace DBADashGUI
{
class ColumnMetaData
public class ColumnMetaData : ISelectable
{
public string Alias;
public bool isVisible;
public string Name { get; set; }
public bool IsVisible { get; set; }
public DateTimePoint[] Points;
public Int32 axis = 0;

}
}
20 changes: 20 additions & 0 deletions DBADashGUI/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static void SetConnectionString(RepositoryConnection connection)
};
connection.ConnectionString = builder.ToString();
RepositoryDBConnection = connection;
CommonData.ClearCache();
}

public static Guid HighPerformancePowerPlanGUID
Expand Down Expand Up @@ -371,5 +372,24 @@ internal static void ConfigureService()
Process.Start(psi);
Application.Exit();
}

public static string AsciiProgressBar(double progress, int totalWidth = 10)
{
var totalWidthDouble = totalWidth * 2; // Double width for half block resolution
var filledWidth = (int)Math.Round(totalWidthDouble * progress);

var fullBlocks = filledWidth / 2;
var fullBlockPart = new string('█', fullBlocks);

// Half blocks
var halfBlocks = filledWidth % 2;
var halfBlockPart = halfBlocks > 0 ? "▓" : "";

// Empty blocks
var emptyBlocks = totalWidthDouble / 2 - fullBlocks - halfBlocks;
var emptyBlockPart = new string('░', emptyBlocks);

return "[" + fullBlockPart + halfBlockPart + emptyBlockPart + "]";
}
}
}
50 changes: 50 additions & 0 deletions DBADashGUI/CommonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Runtime.Caching;

namespace DBADashGUI
{
internal static class CommonData
{
public static DataTable Instances;

static MemoryCache cache = MemoryCache.Default;

public static void UpdateInstancesList(string tagIDs = "", bool? Active = true, bool? azureDB = null, string searchString = "", string groupByTag = "")
{
Instances = GetInstances(tagIDs, Active, azureDB, searchString, groupByTag);
Expand Down Expand Up @@ -256,5 +259,52 @@ public static void AcknowledgeInstanceUptime(int instanceId)
cmd.ExecuteNonQuery();
}
}

public static DataTable GetDrives(HashSet<int> instanceIDs, bool includeMetrics, bool includeCritical, bool includeWarning, bool includeNA, bool includeOK, bool showHidden, string driveName,bool hasMetrics=false)
{
using var cn = new SqlConnection(Common.ConnectionString);
using var cmd = new SqlCommand("dbo.Drives_Get", cn) { CommandType = CommandType.StoredProcedure };
using var da = new SqlDataAdapter(cmd);
cn.Open();
cmd.Parameters.AddWithValue("InstanceIDs", string.Join(",", instanceIDs));
cmd.Parameters.Add(new SqlParameter() { ParameterName = "IncludeCritical", DbType = System.Data.DbType.Boolean, Value = includeCritical });
cmd.Parameters.Add(new SqlParameter() { ParameterName = "IncludeWarning", DbType = System.Data.DbType.Boolean, Value = includeWarning });
cmd.Parameters.Add(new SqlParameter() { ParameterName = "IncludeNA", DbType = System.Data.DbType.Boolean, Value = includeNA });
cmd.Parameters.Add(new SqlParameter() { ParameterName = "IncludeOK", DbType = System.Data.DbType.Boolean, Value = includeOK });
cmd.Parameters.AddWithNullableValue("DriveName", driveName);
cmd.Parameters.AddWithValue("IncludeMetrics", includeMetrics);
cmd.Parameters.AddWithValue("ShowHidden", showHidden);
cmd.Parameters.AddWithValue("HasMetrics", hasMetrics);

DataTable dt = new();
da.Fill(dt);
DateHelper.ConvertUTCToAppTimeZone(ref dt);
return dt;
}


public static DataTable GetMetricDrives(int instanceID,string driveName=null)
{
var key = "GetMetricDrives_" + instanceID + "_" + driveName;
if (cache.Get(key) is DataTable metricDrives) return metricDrives;

metricDrives = GetDrives(new HashSet<int>() { instanceID }, false, true, true, true, true, true, driveName,
true);
metricDrives.DefaultView.Sort = "Name";
metricDrives = metricDrives.DefaultView.ToTable();
var policy = new CacheItemPolicy { AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(5) };
cache.Add(key, metricDrives, policy);

return metricDrives;
}

public static void ClearCache()
{
foreach (var element in cache)
{
cache.Remove(element.Key);
}
}

}
}
4 changes: 4 additions & 0 deletions DBADashGUI/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ internal static class Config

private static readonly Lazy<int> _summaryCommandTimeout = new Lazy<int>(() => RepositorySettings.GetIntSetting("GUISummaryCommandTimeout", Common.ConnectionString) ?? _defaultCommandTimeout.Value);

private static readonly Lazy<int> _drivePerformanceMaxDrives = new Lazy<int>(() => RepositorySettings.GetIntSetting("GUIDrivePerformanceMaxDrives", Common.ConnectionString) ?? 8);

public static int ClientSummaryCacheDuration => _clientSummaryCacheDuration.Value;

public static int DefaultCommandTimeout => _defaultCommandTimeout.Value;

public static int SummaryCommandTimeout => _summaryCommandTimeout.Value;

public static int DrivePerformanceMaxDrives => _drivePerformanceMaxDrives.Value;
}
}
4 changes: 2 additions & 2 deletions DBADashGUI/DBAChecksStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum DBADashStatusEnum
Acknowledged = 5
}

public static Color GetStatusColour(DBADashStatusEnum status)
public static Color GetStatusColour(DBADashStatusEnum status, bool dark = false)
{
if (status == DBADashStatusEnum.Critical)
{
Expand All @@ -25,7 +25,7 @@ public static Color GetStatusColour(DBADashStatusEnum status)
}
else if (status == DBADashStatusEnum.NA)
{
return DashColors.NotApplicable;
return dark ? DashColors.TrimbleGray : DashColors.NotApplicable;
}
else if (status == DBADashStatusEnum.OK)
{
Expand Down
2 changes: 2 additions & 0 deletions DBADashGUI/DBADashContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ public class DBADashContext

public SQLTreeItem.TreeType Type { get; set; }
public SQLTreeItem.TreeType ParentType { get; set; }

public string DriveName { get; set; }
}
}
Loading