From 44fbed6f8279e69782c30ff700c187427aa164ca Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 27 Sep 2023 13:01:46 +0100 Subject: [PATCH 1/3] Some layout and wording tweaks. Signed-off-by: Konstantina Chremmou --- .../SettingsPanels/NRPEEditPage.Designer.cs | 136 +++---- XenAdmin/SettingsPanels/NRPEEditPage.cs | 11 +- XenAdmin/SettingsPanels/NRPEEditPage.resx | 345 +++++++----------- XenAdmin/XenAdmin.csproj | 1 - 4 files changed, 192 insertions(+), 301 deletions(-) diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.Designer.cs b/XenAdmin/SettingsPanels/NRPEEditPage.Designer.cs index d5bcfdf00..5a157e6e7 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.Designer.cs +++ b/XenAdmin/SettingsPanels/NRPEEditPage.Designer.cs @@ -1,6 +1,3 @@ -using System.Windows.Forms; -using DataGridView = System.Windows.Forms.DataGridView; - namespace XenAdmin.SettingsPanels { partial class NRPEEditPage @@ -32,26 +29,21 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NRPEEditPage)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); this.NRPETableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.PoolTipsTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.PoolTipsPicture = new System.Windows.Forms.PictureBox(); - this.PoolTipsLabel = new System.Windows.Forms.Label(); - this.DescLabel = new System.Windows.Forms.Label(); + this.EnableNRPECheckBox = new System.Windows.Forms.CheckBox(); + this.DescLabelPool = new XenAdmin.Controls.Common.AutoHeightLabel(); + this.descLabelHost = new XenAdmin.Controls.Common.AutoHeightLabel(); this.GeneralConfigureGroupBox = new System.Windows.Forms.GroupBox(); this.GeneralConfigTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.EnableNRPECheckBox = new System.Windows.Forms.CheckBox(); this.AllowHostsLabel = new System.Windows.Forms.Label(); this.AllowHostsTextBox = new System.Windows.Forms.TextBox(); this.DebugLogCheckBox = new System.Windows.Forms.CheckBox(); this.SslDebugLogCheckBox = new System.Windows.Forms.CheckBox(); - this.CheckDataGridView = new System.Windows.Forms.DataGridView(); + this.CheckDataGridView = new XenAdmin.Controls.DataGridViewEx.DataGridViewEx(); this.CheckColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.WarningThresholdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.CriticalThresholdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.NRPETableLayoutPanel.SuspendLayout(); - this.PoolTipsTableLayoutPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.PoolTipsPicture)).BeginInit(); this.GeneralConfigureGroupBox.SuspendLayout(); this.GeneralConfigTableLayoutPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.CheckDataGridView)).BeginInit(); @@ -60,61 +52,46 @@ private void InitializeComponent() // NRPETableLayoutPanel // resources.ApplyResources(this.NRPETableLayoutPanel, "NRPETableLayoutPanel"); - this.NRPETableLayoutPanel.Controls.Add(this.PoolTipsTableLayoutPanel, 0, 4); - this.NRPETableLayoutPanel.Controls.Add(this.DescLabel, 0, 0); - this.NRPETableLayoutPanel.Controls.Add(this.GeneralConfigureGroupBox, 0, 1); - this.NRPETableLayoutPanel.Controls.Add(this.CheckDataGridView, 0, 2); + this.NRPETableLayoutPanel.Controls.Add(this.EnableNRPECheckBox, 0, 2); + this.NRPETableLayoutPanel.Controls.Add(this.DescLabelPool, 0, 0); + this.NRPETableLayoutPanel.Controls.Add(this.descLabelHost, 0, 1); + this.NRPETableLayoutPanel.Controls.Add(this.GeneralConfigureGroupBox, 0, 3); + this.NRPETableLayoutPanel.Controls.Add(this.CheckDataGridView, 0, 4); this.NRPETableLayoutPanel.Name = "NRPETableLayoutPanel"; // - // PoolTipsTableLayoutPanel - // - resources.ApplyResources(this.PoolTipsTableLayoutPanel, "PoolTipsTableLayoutPanel"); - this.PoolTipsTableLayoutPanel.Controls.Add(this.PoolTipsPicture, 0, 0); - this.PoolTipsTableLayoutPanel.Controls.Add(this.PoolTipsLabel, 1, 0); - this.PoolTipsTableLayoutPanel.Name = "PoolTipsTableLayoutPanel"; - // - // PoolTipsPicture + // EnableNRPECheckBox // - resources.ApplyResources(this.PoolTipsPicture, "PoolTipsPicture"); - this.PoolTipsPicture.Image = global::XenAdmin.Properties.Resources._000_Info3_h32bit_16; - this.PoolTipsPicture.Name = "PoolTipsPicture"; - this.PoolTipsPicture.TabStop = false; + resources.ApplyResources(this.EnableNRPECheckBox, "EnableNRPECheckBox"); + this.EnableNRPECheckBox.Name = "EnableNRPECheckBox"; + this.EnableNRPECheckBox.UseVisualStyleBackColor = true; + this.EnableNRPECheckBox.CheckedChanged += new System.EventHandler(this.EnableNRPECheckBox_CheckedChanged); // - // PoolTipsLabel + // DescLabelPool // - resources.ApplyResources(this.PoolTipsLabel, "PoolTipsLabel"); - this.PoolTipsLabel.Name = "PoolTipsLabel"; + resources.ApplyResources(this.DescLabelPool, "DescLabelPool"); + this.DescLabelPool.Name = "DescLabelPool"; // - // DescLabel + // descLabelHost // - resources.ApplyResources(this.DescLabel, "DescLabel"); - this.DescLabel.Name = "DescLabel"; + resources.ApplyResources(this.descLabelHost, "descLabelHost"); + this.descLabelHost.Name = "descLabelHost"; // // GeneralConfigureGroupBox // - resources.ApplyResources(this.GeneralConfigureGroupBox, "GeneralConfigureGroupBox"); this.GeneralConfigureGroupBox.Controls.Add(this.GeneralConfigTableLayoutPanel); + resources.ApplyResources(this.GeneralConfigureGroupBox, "GeneralConfigureGroupBox"); this.GeneralConfigureGroupBox.Name = "GeneralConfigureGroupBox"; this.GeneralConfigureGroupBox.TabStop = false; // // GeneralConfigTableLayoutPanel // resources.ApplyResources(this.GeneralConfigTableLayoutPanel, "GeneralConfigTableLayoutPanel"); - this.GeneralConfigTableLayoutPanel.Controls.Add(this.EnableNRPECheckBox, 0, 1); - this.GeneralConfigTableLayoutPanel.Controls.Add(this.AllowHostsLabel, 0, 2); - this.GeneralConfigTableLayoutPanel.Controls.Add(this.AllowHostsTextBox, 1, 2); - this.GeneralConfigTableLayoutPanel.Controls.Add(this.DebugLogCheckBox, 0, 3); - this.GeneralConfigTableLayoutPanel.Controls.Add(this.SslDebugLogCheckBox, 0, 4); + this.GeneralConfigTableLayoutPanel.Controls.Add(this.AllowHostsLabel, 0, 0); + this.GeneralConfigTableLayoutPanel.Controls.Add(this.AllowHostsTextBox, 1, 0); + this.GeneralConfigTableLayoutPanel.Controls.Add(this.DebugLogCheckBox, 0, 1); + this.GeneralConfigTableLayoutPanel.Controls.Add(this.SslDebugLogCheckBox, 0, 2); this.GeneralConfigTableLayoutPanel.Name = "GeneralConfigTableLayoutPanel"; // - // EnableNRPECheckBox - // - resources.ApplyResources(this.EnableNRPECheckBox, "EnableNRPECheckBox"); - this.GeneralConfigTableLayoutPanel.SetColumnSpan(this.EnableNRPECheckBox, 2); - this.EnableNRPECheckBox.Name = "EnableNRPECheckBox"; - this.EnableNRPECheckBox.UseVisualStyleBackColor = true; - this.EnableNRPECheckBox.CheckedChanged += new System.EventHandler(this.EnableNRPECheckBox_CheckedChanged); - // // AllowHostsLabel // resources.ApplyResources(this.AllowHostsLabel, "AllowHostsLabel"); @@ -141,45 +118,37 @@ private void InitializeComponent() // // CheckDataGridView // - this.CheckDataGridView.AllowUserToAddRows = false; - this.CheckDataGridView.AllowUserToDeleteRows = false; - this.CheckDataGridView.AllowUserToResizeRows = false; - resources.ApplyResources(this.CheckDataGridView, "CheckDataGridView"); - this.CheckDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - this.CheckDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; this.CheckDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; - this.CheckDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.CheckDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + this.CheckDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.CheckDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.CheckColumn, this.WarningThresholdColumn, this.CriticalThresholdColumn}); + resources.ApplyResources(this.CheckDataGridView, "CheckDataGridView"); this.CheckDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; - this.CheckDataGridView.EnableHeadersVisualStyles = false; - this.CheckDataGridView.MultiSelect = false; this.CheckDataGridView.Name = "CheckDataGridView"; - this.CheckDataGridView.RowHeadersVisible = false; + this.CheckDataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.CheckDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.CheckDataGridView.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.CheckDataGridView_BeginEdit); this.CheckDataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.CheckDataGridView_EndEdit); // // CheckColumn // - this.CheckColumn.FillWeight = 103.4483F; + this.CheckColumn.FillWeight = 40F; resources.ApplyResources(this.CheckColumn, "CheckColumn"); this.CheckColumn.Name = "CheckColumn"; this.CheckColumn.ReadOnly = true; // // WarningThresholdColumn // - dataGridViewCellStyle1.Format = "N2"; - dataGridViewCellStyle1.NullValue = null; - this.WarningThresholdColumn.DefaultCellStyle = dataGridViewCellStyle1; - this.WarningThresholdColumn.FillWeight = 98.27586F; + this.WarningThresholdColumn.FillWeight = 30F; resources.ApplyResources(this.WarningThresholdColumn, "WarningThresholdColumn"); this.WarningThresholdColumn.Name = "WarningThresholdColumn"; // // CriticalThresholdColumn // - this.CriticalThresholdColumn.FillWeight = 98.27586F; + this.CriticalThresholdColumn.FillWeight = 30F; resources.ApplyResources(this.CriticalThresholdColumn, "CriticalThresholdColumn"); this.CriticalThresholdColumn.Name = "CriticalThresholdColumn"; // @@ -191,10 +160,8 @@ private void InitializeComponent() this.Name = "NRPEEditPage"; this.NRPETableLayoutPanel.ResumeLayout(false); this.NRPETableLayoutPanel.PerformLayout(); - this.PoolTipsTableLayoutPanel.ResumeLayout(false); - this.PoolTipsTableLayoutPanel.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.PoolTipsPicture)).EndInit(); this.GeneralConfigureGroupBox.ResumeLayout(false); + this.GeneralConfigureGroupBox.PerformLayout(); this.GeneralConfigTableLayoutPanel.ResumeLayout(false); this.GeneralConfigTableLayoutPanel.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.CheckDataGridView)).EndInit(); @@ -204,26 +171,19 @@ private void InitializeComponent() } #endregion - private TableLayoutPanel NRPETableLayoutPanel; - - private Label DescLabel; - - private GroupBox GeneralConfigureGroupBox; - private TableLayoutPanel GeneralConfigTableLayoutPanel; - - private CheckBox EnableNRPECheckBox; - private Label AllowHostsLabel; - private TextBox AllowHostsTextBox; - private CheckBox DebugLogCheckBox; - private CheckBox SslDebugLogCheckBox; - - private DataGridView CheckDataGridView; - private DataGridViewTextBoxColumn CheckColumn; - private DataGridViewTextBoxColumn WarningThresholdColumn; - private DataGridViewTextBoxColumn CriticalThresholdColumn; - - private TableLayoutPanel PoolTipsTableLayoutPanel; - private PictureBox PoolTipsPicture; - private Label PoolTipsLabel; + private System.Windows.Forms.TableLayoutPanel NRPETableLayoutPanel; + private XenAdmin.Controls.Common.AutoHeightLabel DescLabelPool; + private System.Windows.Forms.GroupBox GeneralConfigureGroupBox; + private System.Windows.Forms.TableLayoutPanel GeneralConfigTableLayoutPanel; + private System.Windows.Forms.CheckBox EnableNRPECheckBox; + private System.Windows.Forms.Label AllowHostsLabel; + private System.Windows.Forms.TextBox AllowHostsTextBox; + private System.Windows.Forms.CheckBox DebugLogCheckBox; + private System.Windows.Forms.CheckBox SslDebugLogCheckBox; + private Controls.DataGridViewEx.DataGridViewEx CheckDataGridView; + private Controls.Common.AutoHeightLabel descLabelHost; + private System.Windows.Forms.DataGridViewTextBoxColumn CheckColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn WarningThresholdColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn CriticalThresholdColumn; } } \ No newline at end of file diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.cs b/XenAdmin/SettingsPanels/NRPEEditPage.cs index b33406a67..eae55f6b1 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.cs +++ b/XenAdmin/SettingsPanels/NRPEEditPage.cs @@ -75,7 +75,7 @@ public string SubText } } - public Image Image => Images.StaticImages._000_EnablePowerControl_h32bit_16; + public Image Image => Images.StaticImages._000_Module_h32bit_16; public NRPEEditPage(bool isHost) { @@ -122,11 +122,6 @@ public NRPEEditPage(bool isHost) AllowHostsTextBox.GotFocus += AllowHostsTextBox_GotFocus; AllowHostsTextBox.LostFocus += AllowHostsTextBox_LostFocus; - if (isHost) - { - PoolTipsPicture.Hide(); - PoolTipsLabel.Hide(); - } InvalidParamToolTip = new ToolTip { IsBalloon = true, @@ -201,6 +196,10 @@ public void HideLocalValidationMessages() public void SetXenObjects(IXenObject orig, IXenObject clone) { Clone = clone; + + descLabelHost.Visible = IsHost; + DescLabelPool.Visible = !IsHost; + if (IsHost) { InitNRPEGeneralConfiguration(); diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.resx b/XenAdmin/SettingsPanels/NRPEEditPage.resx index 1359a1cf6..434ae8216 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.resx +++ b/XenAdmin/SettingsPanels/NRPEEditPage.resx @@ -117,10 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Top, Left, Right - True @@ -128,213 +124,144 @@ 1 - - Top, Left, Right - - + True - - 2 - - - Left - - - - - + + NoControl - - - - - 0, 7 - - - 0, 0, 0, 0 - - - 18, 17 - - - 17 - - - PoolTipsPicture - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - PoolTipsTableLayoutPanel - - - 0 - - - Top, Bottom, Left, Right + + 3, 88 - - True + + 3, 3, 3, 8 - - NoControl + + 3, 0, 0, 0 - - 23, 3 + + 95, 17 - - 3, 3, 3, 3 + + 2 - - 600, 0 + + &Enable NRPE - - 600, 26 + + EnableNRPECheckBox - - 16 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - For the pool properties, there will not be showing the real configuration values in every host. When clicking OK, NRPE configuration and check threshold will be sent to all the hosts in this pool. + + NRPETableLayoutPanel - - MiddleLeft + + 0 - - PoolTipsLabel + + True - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Fill - - PoolTipsTableLayoutPanel + + NoControl - - 1 + + 3, 0 - - 3, 407 + + 3, 0, 3, 10 - - 1 + + 644, 39 - - 641, 32 + + 0 - - 5 + + Nagios Remote Plugin Executor (NRPE) allows you to monitor remotely resource metrics on the servers of your pool. +This page does not offer an overview of the NRPE configuration and metric threshold settings of the pool servers. Use it only to apply your chosen configuration and threshold settings to all servers in the pool. - - PoolTipsTableLayoutPanel + + DescLabelPool - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + XenAdmin.Controls.Common.AutoHeightLabel, [XenCenter], Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - + NRPETableLayoutPanel - - 0 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="PoolTipsPicture" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="PoolTipsLabel" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="Absolute,20,AutoSize,0" /><Rows Styles="Percent,100" /></TableLayoutSettings> - - - Top, Bottom, Left, Right + + 1 - + True - - NoControl + + Fill - - 3, 0 + + 3, 49 - - 641, 26 + + 3, 0, 3, 10 - - 5 + + 644, 26 - - NRPE (Nagios Remote Plugin Excutor) allow you to execute Nagios plugins on a remote host. You can modify NRPE general configuration and NRPE Check threshold in this page. + + 1 - - DescLabel + + Nagios Remote Plugin Executor (NRPE) allows you to monitor remotely resource metrics on the servers of your pool. +Use this page to review and modify the NRPE configuration and metric threshold settings used for this server. - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + descLabelHost - + + XenAdmin.Controls.Common.AutoHeightLabel, [XenCenter], Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + + NRPETableLayoutPanel - - 1 + + 2 - - Top, Bottom, Left, Right + + True - - Top, Bottom, Left, Right + + GrowAndShrink 2 - - Top, Left, Right + + Left - + True - - NoControl - - - 3, 3 - - - 636, 17 - - - 0 - - - Enable NRPE - - - EnableNRPECheckBox - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - GeneralConfigTableLayoutPanel - - - 0 - NoControl - 3, 23 + 3, 6 - 100, 24 + 96, 13 - 1 + 0 - Allow Hosts: - - - MiddleLeft + &Monitoring servers: AllowHostsLabel @@ -346,22 +273,19 @@ GeneralConfigTableLayoutPanel - 1 + 0 Left, Right - 120, 25 - - - 3, 0, 20, 0 + 105, 3 - 502, 20 + 530, 20 - 2 + 1 AllowHostsTextBox @@ -373,10 +297,7 @@ GeneralConfigTableLayoutPanel - 2 - - - Top, Left, Right + 1 True @@ -385,16 +306,19 @@ NoControl - 3, 50 + 3, 29 + + + 3, 0, 0, 0 - 636, 17 + 211, 17 - 3 + 2 - Record debugging message to syslog + Record &debugging messages to syslog DebugLogCheckBox @@ -406,10 +330,7 @@ GeneralConfigTableLayoutPanel - 3 - - - Top, Left, Right + 2 True @@ -418,16 +339,19 @@ NoControl - 3, 73 + 3, 52 + + + 3, 0, 0, 0 - 636, 17 + 181, 17 - 4 + 3 - Record SSL message to syslog + Record &SSL messages to syslog SslDebugLogCheckBox @@ -439,22 +363,22 @@ GeneralConfigTableLayoutPanel - 4 + 3 - - 10, 12 + + Top - - 3, 3, 3, 0 + + 3, 16 - 6 + 3 - 642, 93 + 638, 72 - 13 + 0 GeneralConfigTableLayoutPanel @@ -469,19 +393,25 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="EnableNRPECheckBox" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="AllowHostsLabel" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="AllowHostsTextBox" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="DebugLogCheckBox" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="SslDebugLogCheckBox" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /></Controls><Columns Styles="Percent,18.36735,Percent,81.63265" /><Rows Styles="Absolute,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="AllowHostsLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="AllowHostsTextBox" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="DebugLogCheckBox" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="SslDebugLogCheckBox" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /></TableLayoutSettings> + + + Fill - 3, 29 + 3, 116 + + + 3, 3, 3, 10 - 3, 0, 3, 0 + 3, 3, 3, 0 - 641, 118 + 644, 100 - 7 + 3 General Configuration @@ -496,16 +426,13 @@ NRPETableLayoutPanel - 2 - - - Top, Left, Right + 3 - Check + Metric - 220 + 100 True @@ -514,7 +441,7 @@ Warning Threshold - 140 + 100 True @@ -523,28 +450,34 @@ Critical Threshold - 140 + 100 + + + Fill - 3, 153 + 3, 229 - 641, 248 + 644, 305 - 15 + 4 CheckDataGridView - System.Windows.Forms.DataGridView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + XenAdmin.Controls.DataGridViewEx.DataGridViewEx, [XenCenter], Version=0.0.0.0, Culture=neutral, PublicKeyToken=null NRPETableLayoutPanel - 3 + 4 + + + Fill 0, 0 @@ -556,10 +489,10 @@ 5 - 647, 442 + 650, 537 - 4 + 0 NRPETableLayoutPanel @@ -574,7 +507,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="PoolTipsTableLayoutPanel" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="DescLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="GeneralConfigureGroupBox" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="CheckDataGridView" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="EnableNRPECheckBox" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="DescLabelPool" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="descLabelHost" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="GeneralConfigureGroupBox" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="CheckDataGridView" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /></TableLayoutSettings> True @@ -586,7 +519,7 @@ True - 650, 621 + 650, 537 CheckColumn diff --git a/XenAdmin/XenAdmin.csproj b/XenAdmin/XenAdmin.csproj index d0338e5fc..3930e9eef 100755 --- a/XenAdmin/XenAdmin.csproj +++ b/XenAdmin/XenAdmin.csproj @@ -484,7 +484,6 @@ NRPEEditPage.cs - NRPEEditPage.cs UserControl From c281bef1bd16da090ca1ec2aadda1e0c39cdfec2 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 27 Sep 2023 19:05:27 +0100 Subject: [PATCH 2/3] Moved NRPE related files to the same folder. Signed-off-by: Konstantina Chremmou --- XenAdmin/SettingsPanels/NRPEEditPage.cs | 8 +++++--- XenModel/{ => Actions}/NRPE/NRPEHostConfiguration.cs | 2 +- XenModel/Actions/{Host => NRPE}/NRPEUpdateAction.cs | 2 +- XenModel/XenModel.csproj | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) rename XenModel/{ => Actions}/NRPE/NRPEHostConfiguration.cs (96%) rename XenModel/Actions/{Host => NRPE}/NRPEUpdateAction.cs (97%) diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.cs b/XenAdmin/SettingsPanels/NRPEEditPage.cs index eae55f6b1..d89080012 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.cs +++ b/XenAdmin/SettingsPanels/NRPEEditPage.cs @@ -29,13 +29,15 @@ */ using System; +using System.Collections.Generic; using System.Drawing; +using System.Text.RegularExpressions; using System.Windows.Forms; -using XenAPI; using XenAdmin.Actions; -using System.Collections.Generic; using XenAdmin.Core; -using System.Text.RegularExpressions; +using XenAdmin.Actions.NRPE; +using XenAPI; + namespace XenAdmin.SettingsPanels { diff --git a/XenModel/NRPE/NRPEHostConfiguration.cs b/XenModel/Actions/NRPE/NRPEHostConfiguration.cs similarity index 96% rename from XenModel/NRPE/NRPEHostConfiguration.cs rename to XenModel/Actions/NRPE/NRPEHostConfiguration.cs index 597556aac..c143a3cca 100644 --- a/XenModel/NRPE/NRPEHostConfiguration.cs +++ b/XenModel/Actions/NRPE/NRPEHostConfiguration.cs @@ -31,7 +31,7 @@ using System; using System.Collections.Generic; -namespace XenAdmin +namespace XenAdmin.Actions.NRPE { public class NRPEHostConfiguration : ICloneable { diff --git a/XenModel/Actions/Host/NRPEUpdateAction.cs b/XenModel/Actions/NRPE/NRPEUpdateAction.cs similarity index 97% rename from XenModel/Actions/Host/NRPEUpdateAction.cs rename to XenModel/Actions/NRPE/NRPEUpdateAction.cs index 38eefe94b..05cb749db 100644 --- a/XenModel/Actions/Host/NRPEUpdateAction.cs +++ b/XenModel/Actions/NRPE/NRPEUpdateAction.cs @@ -33,7 +33,7 @@ using XenAPI; -namespace XenAdmin.Actions +namespace XenAdmin.Actions.NRPE { public class NRPEUpdateAction : AsyncAction { diff --git a/XenModel/XenModel.csproj b/XenModel/XenModel.csproj index 949403fbd..2850c5ca4 100755 --- a/XenModel/XenModel.csproj +++ b/XenModel/XenModel.csproj @@ -88,7 +88,7 @@ - + @@ -199,7 +199,7 @@ - + From 9fff62072fe8746242f0751305d6a9f2a6ab3c79 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Thu, 28 Sep 2023 13:22:46 +0100 Subject: [PATCH 3/3] Some corrections in wording, code style, C# usage, and null checks. Signed-off-by: Konstantina Chremmou --- XenAdmin/Dialogs/PropertiesDialog.cs | 2 +- XenAdmin/SettingsPanels/NRPEEditPage.cs | 66 +++++++++-------- .../Actions/NRPE/NRPEHostConfiguration.cs | 72 +++++++++---------- XenModel/Messages.Designer.cs | 21 ++++-- XenModel/Messages.resx | 15 ++-- 5 files changed, 91 insertions(+), 85 deletions(-) diff --git a/XenAdmin/Dialogs/PropertiesDialog.cs b/XenAdmin/Dialogs/PropertiesDialog.cs index a6dda37d7..b35caaf89 100755 --- a/XenAdmin/Dialogs/PropertiesDialog.cs +++ b/XenAdmin/Dialogs/PropertiesDialog.cs @@ -320,7 +320,7 @@ private void Build() } if (isHost || isPool) { - NRPEEditPage = new NRPEEditPage(isHost); + NRPEEditPage = new NRPEEditPage(); ShowTab(NRPEEditPage); } } diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.cs b/XenAdmin/SettingsPanels/NRPEEditPage.cs index d89080012..ccf22e2e3 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.cs +++ b/XenAdmin/SettingsPanels/NRPEEditPage.cs @@ -45,12 +45,11 @@ public partial class NRPEEditPage : UserControl, IEditPage { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private static readonly Regex REGEX_IPV4 = new Regex("^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)"); private static readonly Regex REGEX_IPV4_CIDR = new Regex("^([0-9]{1,3}\\.){3}[0-9]{1,3}(\\/([0-9]|[1-2][0-9]|3[0-2]))?$"); private static readonly Regex REGEX_DOMAIN = new Regex("^(((?!-))(xn--|_)?[a-z0-9-]{0,61}[a-z0-9]{1,1}\\.)*(xn--)?([a-z0-9][a-z0-9\\-]{0,60}|[a-z0-9-]{1,30}\\.[a-z]{2,})$"); - private readonly bool IsHost = true; + private bool _isHost; private IXenObject Clone; private readonly ToolTip InvalidParamToolTip; @@ -62,11 +61,12 @@ public partial class NRPEEditPage : UserControl, IEditPage private NRPEHostConfiguration NRPEOriginalConfig; private NRPEHostConfiguration NRPECurrentConfig; + public string SubText { get { - if (IsHost) + if (_isHost) { return EnableNRPECheckBox.Checked ? Messages.NRPE_ACTIVE : Messages.NRPE_INACTIVE; } @@ -79,11 +79,10 @@ public string SubText public Image Image => Images.StaticImages._000_Module_h32bit_16; - public NRPEEditPage(bool isHost) + public NRPEEditPage() { - IsHost = isHost; InitializeComponent(); - Text = "NRPE"; + Text = Messages.NRPE; NRPECurrentConfig = new NRPEHostConfiguration { @@ -118,7 +117,7 @@ public NRPEEditPage(bool isHost) CheckGroupDictByLabel.Add(checkGroup.NameCell.Value.ToString(), checkGroup); } - UpdateOtherComponentBasedEnableNRPECheckBox(false); + UpdateOtherComponentBasedEnableNRPECheckBox(); AllowHostsTextBox.ForeColor = Color.FromKnownColor(KnownColor.ControlDark); AllowHostsTextBox.GotFocus += AllowHostsTextBox_GotFocus; @@ -146,11 +145,7 @@ public bool ValidToSave return true; } - bool valid = true; - if (!IsAllowHostsValid()) - { - valid = false; - } + bool valid = IsAllowHostsValid(); foreach (CheckGroup checkGroup in CheckGroupList) { @@ -189,7 +184,7 @@ public void ShowLocalValidationMessages() public void HideLocalValidationMessages() { - if (InvalidParamToolTip.Tag is Control ctrl && ctrl != null) + if (InvalidParamToolTip.Tag is Control ctrl) { InvalidParamToolTip.Hide(ctrl); } @@ -198,11 +193,12 @@ public void HideLocalValidationMessages() public void SetXenObjects(IXenObject orig, IXenObject clone) { Clone = clone; + _isHost = Clone is Host; - descLabelHost.Visible = IsHost; - DescLabelPool.Visible = !IsHost; + descLabelHost.Visible = _isHost; + DescLabelPool.Visible = !_isHost; - if (IsHost) + if (_isHost) { InitNRPEGeneralConfiguration(); InitNRPEThreshold(); @@ -257,7 +253,7 @@ private void InitNRPEGeneralConfiguration() } NRPEOriginalConfig = (NRPEHostConfiguration) NRPECurrentConfig.Clone(); - UpdateOtherComponentBasedEnableNRPECheckBox(EnableNRPECheckBox.Checked); + UpdateOtherComponentBasedEnableNRPECheckBox(); } private void InitNRPEThreshold() @@ -326,24 +322,18 @@ private string AllowHostsWithoutLocalAddress(string allowHosts) UpdatedAllowHosts.Substring(0, UpdatedAllowHosts.Length - 1); } - private void UpdateOtherComponentBasedEnableNRPECheckBox(bool check) + private void UpdateOtherComponentBasedEnableNRPECheckBox() { - if (check) + if (EnableNRPECheckBox.Checked) { - AllowHostsTextBox.Enabled = true; - AllowHostsLabel.Enabled = true; - DebugLogCheckBox.Enabled = true; - SslDebugLogCheckBox.Enabled = true; + GeneralConfigureGroupBox.Enabled = true; CheckDataGridView.Enabled = true; CheckDataGridView.BackgroundColor = Color.FromKnownColor(KnownColor.Window); CheckDataGridView.DefaultCellStyle.BackColor = Color.FromKnownColor(KnownColor.Window); } else { - AllowHostsTextBox.Enabled = false; - AllowHostsLabel.Enabled = false; - DebugLogCheckBox.Enabled = false; - SslDebugLogCheckBox.Enabled = false; + GeneralConfigureGroupBox.Enabled = false; CheckDataGridView.Enabled = false; CheckDataGridView.BackgroundColor = Color.FromKnownColor(KnownColor.Control); CheckDataGridView.DefaultCellStyle.BackColor = Color.FromKnownColor(KnownColor.Control); @@ -352,7 +342,7 @@ private void UpdateOtherComponentBasedEnableNRPECheckBox(bool check) private void EnableNRPECheckBox_CheckedChanged(object sender, EventArgs e) { - UpdateOtherComponentBasedEnableNRPECheckBox(EnableNRPECheckBox.Checked); + UpdateOtherComponentBasedEnableNRPECheckBox(); } private void AllowHostsTextBox_GotFocus(object sender, EventArgs e) @@ -375,8 +365,9 @@ private void AllowHostsTextBox_LostFocus(object sender, EventArgs e) private void CheckDataGridView_BeginEdit(object sender, DataGridViewCellCancelEventArgs e) { - DataGridViewCell currentCell = CheckDataGridView.CurrentRow.Cells[e.ColumnIndex]; - if (!IsHost && currentCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlDark))) + DataGridViewCell currentCell = CheckDataGridView.CurrentRow?.Cells[e.ColumnIndex]; + + if (currentCell != null && !_isHost && currentCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlDark))) { currentCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText); currentCell.Value = ""; @@ -385,13 +376,20 @@ private void CheckDataGridView_BeginEdit(object sender, DataGridViewCellCancelEv private void CheckDataGridView_EndEdit(object sender, DataGridViewCellEventArgs e) { - DataGridViewCell currentCell = CheckDataGridView.CurrentRow.Cells[e.ColumnIndex]; - if (!IsHost && currentCell.Value.ToString().Trim().Equals("")) + DataGridViewCell currentCell = CheckDataGridView.CurrentRow?.Cells[e.ColumnIndex]; + + if (currentCell != null &&!_isHost && currentCell.Value.ToString().Trim().Equals("")) { currentCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark); CheckGroupDictByLabel.TryGetValue(CheckDataGridView.CurrentRow.Cells[0].Value.ToString(), out CheckGroup checkGroup); - currentCell.Value = currentCell.ColumnIndex == 1 ? - checkGroup.WarningThresholdDefault : (object)checkGroup.CriticalThresholdDefault; + + if (checkGroup != null) + { + if (currentCell.ColumnIndex == WarningThresholdColumn.Index) + currentCell.Value = checkGroup.WarningThresholdDefault; + else if (currentCell.ColumnIndex == CriticalThresholdColumn.Index) + currentCell.Value = checkGroup.CriticalThresholdDefault; + } } } } diff --git a/XenModel/Actions/NRPE/NRPEHostConfiguration.cs b/XenModel/Actions/NRPE/NRPEHostConfiguration.cs index c143a3cca..7f1e62098 100644 --- a/XenModel/Actions/NRPE/NRPEHostConfiguration.cs +++ b/XenModel/Actions/NRPE/NRPEHostConfiguration.cs @@ -35,55 +35,51 @@ namespace XenAdmin.Actions.NRPE { public class NRPEHostConfiguration : ICloneable { - public static readonly string XAPI_NRPE_PLUGIN_NAME = "nrpe"; - public static readonly string XAPI_NRPE_STATUS = "status"; - public static readonly string XAPI_NRPE_GET_CONFIG = "get-config"; - public static readonly string XAPI_NRPE_GET_THRESHOLD = "get-threshold"; - public static readonly string XAPI_NRPE_ENABLE = "enable"; - public static readonly string XAPI_NRPE_DISABLE = "disable"; - public static readonly string XAPI_NRPE_SET_CONFIG = "set-config"; - public static readonly string XAPI_NRPE_SET_THRESHOLD = "set-threshold"; - public static readonly string XAPI_NRPE_RESTART = "restart"; - - public static readonly string DEBUG_ENABLE = "1"; - public static readonly string DEBUG_DISABLE = "0"; - - public static readonly string SSL_LOGGING_ENABLE = "0xff"; - public static readonly string SSL_LOGGING_DISABLE = "0x00"; + public const string XAPI_NRPE_PLUGIN_NAME = "nrpe"; + public const string XAPI_NRPE_STATUS = "status"; + public const string XAPI_NRPE_GET_CONFIG = "get-config"; + public const string XAPI_NRPE_GET_THRESHOLD = "get-threshold"; + public const string XAPI_NRPE_ENABLE = "enable"; + public const string XAPI_NRPE_DISABLE = "disable"; + public const string XAPI_NRPE_SET_CONFIG = "set-config"; + public const string XAPI_NRPE_SET_THRESHOLD = "set-threshold"; + public const string XAPI_NRPE_RESTART = "restart"; + + public const string DEBUG_ENABLE = "1"; + public const string DEBUG_DISABLE = "0"; + + public const string SSL_LOGGING_ENABLE = "0xff"; + public const string SSL_LOGGING_DISABLE = "0x00"; public static readonly string ALLOW_HOSTS_PLACE_HOLDER = Messages.NRPE_ALLOW_HOSTS_PLACE_HOLDER; - private bool enableNRPE; - private string allowHosts; - private bool debug; - private bool sslLogging; private readonly Dictionary checkDict = new Dictionary(); - public bool EnableNRPE { get => enableNRPE; set => enableNRPE = value; } - public string AllowHosts { get => allowHosts; set => allowHosts = value; } - public bool Debug { get => debug; set => debug = value; } - public bool SslLogging { get => sslLogging; set => sslLogging = value; } - public Dictionary CheckDict { get => checkDict; } + public bool EnableNRPE { get; set; } + + public string AllowHosts { get; set; } + + public bool Debug { get; set; } + + public bool SslLogging { get; set; } + + public Dictionary CheckDict => checkDict; public class Check { - public string Name; - public string WarningThreshold; - public string CriticalThreshold; + public string Name { get; } + public string WarningThreshold { get; } + public string CriticalThreshold{ get; } public Check(string name, string warningThreshold, string criticalThreshold) { - this.Name = name; - this.WarningThreshold = warningThreshold; - this.CriticalThreshold = criticalThreshold; + Name = name; + WarningThreshold = warningThreshold; + CriticalThreshold = criticalThreshold; } } - public NRPEHostConfiguration() - { - } - public void AddNRPECheck(Check checkItem) { checkDict.Add(checkItem.Name, checkItem); @@ -98,10 +94,10 @@ public object Clone() { NRPEHostConfiguration cloned = new NRPEHostConfiguration { - enableNRPE = enableNRPE, - allowHosts = allowHosts, - debug = debug, - sslLogging = sslLogging + EnableNRPE = EnableNRPE, + AllowHosts = AllowHosts, + Debug = Debug, + SslLogging = SslLogging }; return cloned; } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 4640a32ae..e387c153d 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -29078,6 +29078,15 @@ public static string NOW { } } + /// + /// Looks up a localized string similar to NRPE. + /// + public static string NRPE { + get { + return ResourceManager.GetString("NRPE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Changing NRPE configuration.... /// @@ -29097,7 +29106,7 @@ public static string NRPE_ACTIVE { } /// - /// Looks up a localized string similar to Allow hosts should not be empty.. + /// Looks up a localized string similar to Monitoring servers should not be empty.. /// public static string NRPE_ALLOW_HOSTS_EMPTY_ERROR { get { @@ -29106,7 +29115,7 @@ public static string NRPE_ALLOW_HOSTS_EMPTY_ERROR { } /// - /// Looks up a localized string similar to Allow hosts format is not correct. + /// Looks up a localized string similar to Monitoring servers format is not correct. /// public static string NRPE_ALLOW_HOSTS_ERROR_TITLE { get { @@ -29115,7 +29124,7 @@ public static string NRPE_ALLOW_HOSTS_ERROR_TITLE { } /// - /// Looks up a localized string similar to Allow hosts should be comma separated IP address or domain list, e.g. 192.168.1.1, test.domain.com. + /// Looks up a localized string similar to Monitoring servers should be comma separated IP address or domain list, e.g. 192.168.1.1, test.domain.com. /// public static string NRPE_ALLOW_HOSTS_FORMAT_ERROR { get { @@ -29268,7 +29277,7 @@ public static string NRPE_THRESHOLD_RANGE_ERROR { } /// - /// Looks up a localized string similar to Threshold value should be 3 numbers separated with comma.. + /// Looks up a localized string similar to Threshold value should consist of 3 comma separated numbers.. /// public static string NRPE_THRESHOLD_SHOULD_BE_3_NUMBERS { get { @@ -29277,7 +29286,7 @@ public static string NRPE_THRESHOLD_SHOULD_BE_3_NUMBERS { } /// - /// Looks up a localized string similar to Threshold value should be number.. + /// Looks up a localized string similar to Threshold value should be a number.. /// public static string NRPE_THRESHOLD_SHOULD_BE_NUMBER { get { @@ -29295,7 +29304,7 @@ public static string NRPE_THRESHOLD_SHOULD_NOT_BE_EMPTY { } /// - /// Looks up a localized string similar to Warning threshold should be bigger than critical threshold.. + /// Looks up a localized string similar to Warning threshold should be greater than critical threshold.. /// public static string NRPE_THRESHOLD_WARNING_SHOULD_BIGGER_THAN_CRITICAL { get { diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 55095208a..b4418b67c 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -10092,6 +10092,9 @@ When you configure an NFS storage repository, you simply provide the host name o Now + + NRPE + Changing NRPE configuration... @@ -10099,13 +10102,13 @@ When you configure an NFS storage repository, you simply provide the host name o NRPE service is active - Allow hosts should not be empty. + Monitoring servers should not be empty. - Allow hosts format is not correct + Monitoring servers format is not correct - Allow hosts should be comma separated IP address or domain list, e.g. 192.168.1.1, test.domain.com + Monitoring servers should be comma separated IP address or domain list, e.g. 192.168.1.1, test.domain.com Comma separated IP address or domain list, e.g. 192.168.1.1, test.domain.com @@ -10156,16 +10159,16 @@ When you configure an NFS storage repository, you simply provide the host name o Threshold value should range from {0} to {1}. - Threshold value should be 3 numbers separated with comma. + Threshold value should consist of 3 comma separated numbers. - Threshold value should be number. + Threshold value should be a number. Threshold value should not be empty. - Warning threshold should be bigger than critical threshold. + Warning threshold should be greater than critical threshold. Warning threshold should be less than critical threshold.