All the configurations of host in a pool are the same. Fix some review comments.

This commit is contained in:
Bengang Yuan 2023-10-16 16:59:33 +08:00 committed by Konstantina Chremmou
parent 5815dfa086
commit aac73932ce
8 changed files with 178 additions and 351 deletions

View File

@ -318,7 +318,7 @@ namespace XenAdmin.Dialogs
dialog.ShowDialog(Program.MainWindow);
}
}
if ((isHost || isPool) &&
if (isPoolOrStandalone &&
(connection.Session.IsLocalSuperuser || connection.Session.Roles.Any(r => r.name_label == Role.MR_ROLE_POOL_ADMIN)))
{
NRPEEditPage = new NRPEEditPage();

View File

@ -35,10 +35,10 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("XenCenter")]
[assembly: AssemblyDescription("XenCenter")]
[assembly: AssemblyTitle("[XenCenter]")]
[assembly: AssemblyDescription("[XenCenter]")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("XenCenter")]
[assembly: AssemblyProduct("[XenCenter]")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from

View File

@ -30,7 +30,8 @@ namespace XenAdmin.SettingsPanels
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NRPEEditPage));
this.NRPETableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.BatchConfigurationCheckBox = new System.Windows.Forms.CheckBox();
this.DescLabelPool = new XenAdmin.Controls.Common.AutoHeightLabel();
this.DescLabelHost = new XenAdmin.Controls.Common.AutoHeightLabel();
this.EnableNRPECheckBox = new System.Windows.Forms.CheckBox();
this.GeneralConfigureGroupBox = new System.Windows.Forms.GroupBox();
this.GeneralConfigTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
@ -38,21 +39,19 @@ namespace XenAdmin.SettingsPanels
this.AllowHostsTextBox = new System.Windows.Forms.TextBox();
this.DebugLogCheckBox = new System.Windows.Forms.CheckBox();
this.SslDebugLogCheckBox = new System.Windows.Forms.CheckBox();
this.CheckDataGridView = new XenAdmin.Controls.DataGridViewEx.DataGridViewEx();
this.RetrieveNRPEPanel = new System.Windows.Forms.TableLayoutPanel();
this.RetrieveNRPELabel = new System.Windows.Forms.Label();
this.RetrieveNRPEPicture = new System.Windows.Forms.PictureBox();
this.DescLabelPool = new XenAdmin.Controls.Common.AutoHeightLabel();
this.DescLabelHost = new XenAdmin.Controls.Common.AutoHeightLabel();
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.GeneralConfigureGroupBox.SuspendLayout();
this.GeneralConfigTableLayoutPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.CheckDataGridView)).BeginInit();
this.RetrieveNRPEPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.RetrieveNRPEPicture)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.CheckDataGridView)).BeginInit();
this.SuspendLayout();
//
// NRPETableLayoutPanel
@ -60,19 +59,21 @@ namespace XenAdmin.SettingsPanels
resources.ApplyResources(this.NRPETableLayoutPanel, "NRPETableLayoutPanel");
this.NRPETableLayoutPanel.Controls.Add(this.DescLabelPool, 0, 0);
this.NRPETableLayoutPanel.Controls.Add(this.DescLabelHost, 0, 1);
this.NRPETableLayoutPanel.Controls.Add(this.BatchConfigurationCheckBox, 0, 2);
this.NRPETableLayoutPanel.Controls.Add(this.EnableNRPECheckBox, 0, 3);
this.NRPETableLayoutPanel.Controls.Add(this.GeneralConfigureGroupBox, 0, 4);
this.NRPETableLayoutPanel.Controls.Add(this.CheckDataGridView, 0, 5);
this.NRPETableLayoutPanel.Controls.Add(this.RetrieveNRPEPanel, 0, 6);
this.NRPETableLayoutPanel.Name = "NRPETableLayoutPanel";
//
// BatchConfigurationCheckBox
// DescLabelPool
//
resources.ApplyResources(this.BatchConfigurationCheckBox, "BatchConfigurationCheckBox");
this.BatchConfigurationCheckBox.Name = "BatchConfigurationCheckBox";
this.BatchConfigurationCheckBox.UseVisualStyleBackColor = true;
this.BatchConfigurationCheckBox.CheckedChanged += new System.EventHandler(this.BatchConfigurationCheckBox_CheckedChanged);
resources.ApplyResources(this.DescLabelPool, "DescLabelPool");
this.DescLabelPool.Name = "DescLabelPool";
//
// DescLabelHost
//
resources.ApplyResources(this.DescLabelHost, "DescLabelHost");
this.DescLabelHost.Name = "DescLabelHost";
//
// EnableNRPECheckBox
//
@ -121,6 +122,21 @@ namespace XenAdmin.SettingsPanels
this.SslDebugLogCheckBox.Name = "SslDebugLogCheckBox";
this.SslDebugLogCheckBox.UseVisualStyleBackColor = true;
//
// CheckDataGridView
//
this.CheckDataGridView.BackgroundColor = System.Drawing.SystemColors.Window;
this.CheckDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
resources.ApplyResources(this.CheckDataGridView, "CheckDataGridView");
this.CheckDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.CheckDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.CheckColumn,
this.WarningThresholdColumn,
this.CriticalThresholdColumn});
this.CheckDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.CheckDataGridView.Name = "CheckDataGridView";
this.CheckDataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.CheckDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
//
// RetrieveNRPEPanel
//
resources.ApplyResources(this.RetrieveNRPEPanel, "RetrieveNRPEPanel");
@ -139,49 +155,22 @@ namespace XenAdmin.SettingsPanels
this.RetrieveNRPEPicture.Name = "RetrieveNRPEPicture";
this.RetrieveNRPEPicture.TabStop = false;
//
// DescLabelPool
//
resources.ApplyResources(this.DescLabelPool, "DescLabelPool");
this.DescLabelPool.Name = "DescLabelPool";
//
// DescLabelHost
//
resources.ApplyResources(this.DescLabelHost, "DescLabelHost");
this.DescLabelHost.Name = "DescLabelHost";
//
// CheckDataGridView
//
this.CheckDataGridView.BackgroundColor = System.Drawing.SystemColors.Window;
this.CheckDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
resources.ApplyResources(this.CheckDataGridView, "CheckDataGridView");
this.CheckDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.CheckDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.CheckColumn,
this.WarningThresholdColumn,
this.CriticalThresholdColumn});
this.CheckDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.CheckDataGridView.Name = "CheckDataGridView";
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 = 15.57632F;
this.CheckColumn.FillWeight = 40F;
resources.ApplyResources(this.CheckColumn, "CheckColumn");
this.CheckColumn.Name = "CheckColumn";
this.CheckColumn.ReadOnly = true;
//
// WarningThresholdColumn
//
this.WarningThresholdColumn.FillWeight = 42.21184F;
this.WarningThresholdColumn.FillWeight = 30F;
resources.ApplyResources(this.WarningThresholdColumn, "WarningThresholdColumn");
this.WarningThresholdColumn.Name = "WarningThresholdColumn";
//
// CriticalThresholdColumn
//
this.CriticalThresholdColumn.FillWeight = 42.21184F;
this.CriticalThresholdColumn.FillWeight = 30F;
resources.ApplyResources(this.CriticalThresholdColumn, "CriticalThresholdColumn");
this.CriticalThresholdColumn.Name = "CriticalThresholdColumn";
//
@ -197,9 +186,9 @@ namespace XenAdmin.SettingsPanels
this.GeneralConfigureGroupBox.PerformLayout();
this.GeneralConfigTableLayoutPanel.ResumeLayout(false);
this.GeneralConfigTableLayoutPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.CheckDataGridView)).EndInit();
this.RetrieveNRPEPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.RetrieveNRPEPicture)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CheckDataGridView)).EndInit();
this.ResumeLayout(false);
}
@ -216,13 +205,12 @@ namespace XenAdmin.SettingsPanels
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;
private System.Windows.Forms.Label RetrieveNRPELabel;
private System.Windows.Forms.TableLayoutPanel RetrieveNRPEPanel;
private System.Windows.Forms.PictureBox RetrieveNRPEPicture;
private System.Windows.Forms.CheckBox BatchConfigurationCheckBox;
private System.Windows.Forms.DataGridViewTextBoxColumn CheckColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn WarningThresholdColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn CriticalThresholdColumn;
}
}

View File

@ -37,14 +37,11 @@ using XenAdmin.Actions;
using XenAdmin.Core;
using XenAdmin.Actions.NRPE;
using XenAPI;
using System.Linq;
namespace XenAdmin.SettingsPanels
{
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,})$");
@ -108,21 +105,13 @@ namespace XenAdmin.SettingsPanels
ToolTipTitle = Messages.INVALID_PARAMETER,
Tag = AllowHostsTextBox
};
DisableAllComponent();
}
public string SubText
{
get
{
if (_isHost)
{
return Messages.NRPE_EDIT_PAGE_TEXT;
}
else
{
return Messages.NRPE_BATCH_CONFIGURATION;
}
return Messages.NRPE_EDIT_PAGE_TEXT;
}
}
@ -159,10 +148,9 @@ namespace XenAdmin.SettingsPanels
{
get
{
if (_isHost && IsNRPEConfigurationChanged() ||
!_isHost && BatchConfigurationCheckBox.Checked)
UpdateCurrentNRPEConfiguration();
if (!_nrpeCurrentConfig.Equals(_nrpeOriginalConfig))
{
UpdateCurrentNRPEConfiguration();
return true;
}
return false;
@ -198,35 +186,6 @@ namespace XenAdmin.SettingsPanels
return new NRPEUpdateAction(_clone, _nrpeCurrentConfig, _nrpeOriginalConfig, true);
}
public bool IsNRPEAvailable(IXenObject clone)
{
IXenObject checkHost;
if (clone is Host h)
{
checkHost = h;
}
else if (clone is Pool p)
{
List<Host> hostList = p.Connection.Cache.Hosts.ToList();
checkHost = hostList[0];
}
else
{
return false;
}
try
{
Host.call_plugin(checkHost.Connection.Session, checkHost.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
NRPEHostConfiguration.XAPI_NRPE_GET_THRESHOLD, null);
}
catch (Exception e)
{
log.InfoFormat("Execute NRPE plugin failed, failed reason: {0}. It may not support NRPE.", e.Message);
return false;
}
return true;
}
public void SetXenObjects(IXenObject orig, IXenObject clone)
{
_clone = clone;
@ -234,7 +193,6 @@ namespace XenAdmin.SettingsPanels
DescLabelHost.Visible = _isHost;
DescLabelPool.Visible = !_isHost;
BatchConfigurationCheckBox.Visible = !_isHost;
UpdateRetrievingNRPETip(NRPEHostConfiguration.RetrieveNRPEStatus.Retrieving);
DisableAllComponent();
@ -252,16 +210,9 @@ namespace XenAdmin.SettingsPanels
{
if (_nrpeOriginalConfig.Status == NRPEHostConfiguration.RetrieveNRPEStatus.Successful)
{
if (_isHost)
{
EnableNRPECheckBox.Enabled = true;
UpdateComponentValueBasedConfiguration();
UpdateComponentStatusBasedEnableNRPECheckBox();
}
else
{
BatchConfigurationCheckBox.Enabled = true;
}
EnableNRPECheckBox.Enabled = true;
UpdateComponentValueBasedConfiguration();
UpdateComponentStatusBasedEnableNRPECheckBox();
}
UpdateRetrievingNRPETip(_nrpeOriginalConfig.Status);
}
@ -312,39 +263,24 @@ namespace XenAdmin.SettingsPanels
SslDebugLogCheckBox.Checked = _nrpeOriginalConfig.SslLogging;
}
private void UpdateComponentStatusBasedBatchConfigurationCheckBox()
{
if (BatchConfigurationCheckBox.Checked)
{
EnableNRPECheckBox.Enabled = true;
UpdateComponentStatusBasedEnableNRPECheckBox();
}
else
{
DisableAllComponent();
}
}
private void UpdateComponentStatusBasedEnableNRPECheckBox()
{
GeneralConfigureGroupBox.Enabled = EnableNRPECheckBox.Checked;
CheckDataGridView.Enabled = EnableNRPECheckBox.Checked;
CheckDataGridView.ScrollBars = ScrollBars.Both;
CheckDataGridView.DefaultCellStyle.BackColor = EnableNRPECheckBox.Checked ?
Color.FromKnownColor(KnownColor.Window) : Color.FromKnownColor(KnownColor.Control);
if (_isHost)
foreach (var checkGroup in _checkGroupList)
{
foreach (var checkGroup in _checkGroupList)
if (EnableNRPECheckBox.Checked)
{
if (EnableNRPECheckBox.Checked)
{
checkGroup.WarningThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
checkGroup.CriticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
}
else
{
checkGroup.WarningThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
checkGroup.CriticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
}
checkGroup.WarningThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
checkGroup.CriticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
}
else
{
checkGroup.WarningThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
checkGroup.CriticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
}
}
}
@ -411,29 +347,6 @@ namespace XenAdmin.SettingsPanels
UpdatedAllowHosts.Substring(0, UpdatedAllowHosts.Length - 1);
}
private bool IsNRPEConfigurationChanged()
{
if (_nrpeCurrentConfig.EnableNRPE != _nrpeOriginalConfig.EnableNRPE ||
!_nrpeCurrentConfig.AllowHosts.Equals(_nrpeOriginalConfig.AllowHosts) ||
_nrpeCurrentConfig.Debug != _nrpeOriginalConfig.Debug ||
_nrpeCurrentConfig.SslLogging != _nrpeOriginalConfig.SslLogging)
{
return true;
}
foreach (KeyValuePair<string, NRPEHostConfiguration.Check> kvp in _nrpeCurrentConfig.CheckDict)
{
NRPEHostConfiguration.Check CurrentCheck = kvp.Value;
_nrpeOriginalConfig.GetNRPECheck(kvp.Key, out NRPEHostConfiguration.Check OriginalCheck);
if (CurrentCheck != null && OriginalCheck != null
&& (!CurrentCheck.WarningThreshold.Equals(OriginalCheck.WarningThreshold)
|| !CurrentCheck.CriticalThreshold.Equals(OriginalCheck.CriticalThreshold)))
{
return true;
}
}
return false;
}
private void UpdateCurrentNRPEConfiguration()
{
_nrpeCurrentConfig = new NRPEHostConfiguration
@ -445,20 +358,11 @@ namespace XenAdmin.SettingsPanels
};
foreach (KeyValuePair<string, CheckGroup> item in _checkGroupDictByName)
{
if (item.Value.WarningThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlText))
&& item.Value.CriticalThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlText)))
{
_nrpeCurrentConfig.AddNRPECheck(new NRPEHostConfiguration.Check(item.Key,
item.Value.WarningThresholdCell.Value.ToString(), item.Value.CriticalThresholdCell.Value.ToString()));
}
_nrpeCurrentConfig.AddNRPECheck(new NRPEHostConfiguration.Check(item.Key,
item.Value.WarningThresholdCell.Value.ToString(), item.Value.CriticalThresholdCell.Value.ToString()));
}
}
private void BatchConfigurationCheckBox_CheckedChanged(object sender, EventArgs e)
{
UpdateComponentStatusBasedBatchConfigurationCheckBox();
}
private void EnableNRPECheckBox_CheckedChanged(object sender, EventArgs e)
{
UpdateComponentStatusBasedEnableNRPECheckBox();
@ -481,36 +385,5 @@ namespace XenAdmin.SettingsPanels
AllowHostsTextBox.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
}
}
private void CheckDataGridView_BeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
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 = "";
}
}
private void CheckDataGridView_EndEdit(object sender, DataGridViewCellEventArgs e)
{
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);
if (checkGroup != null)
{
if (currentCell.ColumnIndex == WarningThresholdColumn.Index)
currentCell.Value = checkGroup.WarningThresholdDefault;
else if (currentCell.ColumnIndex == CriticalThresholdColumn.Index)
currentCell.Value = checkGroup.CriticalThresholdDefault;
}
_nrpeOriginalConfig.CheckDict.TryGetValue(checkGroup.Name, out NRPEHostConfiguration.Check check);
}
}
}
}

View File

@ -133,26 +133,26 @@
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="DescLabelPool.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 0</value>
<value>4, 0</value>
</data>
<data name="DescLabelPool.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 3, 10</value>
<value>4, 0, 4, 15</value>
</data>
<data name="DescLabelPool.Size" type="System.Drawing.Size, System.Drawing">
<value>644, 39</value>
<value>967, 40</value>
</data>
<data name="DescLabelPool.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="DescLabelPool.Text" xml:space="preserve">
<value>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.</value>
Use this page to review and modify the NRPE configuration and metric threshold settings used for this pool.</value>
</data>
<data name="&gt;&gt;DescLabelPool.Name" xml:space="preserve">
<value>DescLabelPool</value>
</data>
<data name="&gt;&gt;DescLabelPool.Type" xml:space="preserve">
<value>XenAdmin.Controls.Common.AutoHeightLabel, XenCenter, Version=0.0.0.9999, Culture=neutral, PublicKeyToken=null</value>
<value>XenAdmin.Controls.Common.AutoHeightLabel, XenCenter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;DescLabelPool.Parent" xml:space="preserve">
<value>NRPETableLayoutPanel</value>
@ -170,13 +170,13 @@ This page does not offer an overview of the NRPE configuration and metric thresh
<value>NoControl</value>
</data>
<data name="DescLabelHost.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 49</value>
<value>4, 55</value>
</data>
<data name="DescLabelHost.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 3, 10</value>
<value>4, 0, 4, 15</value>
</data>
<data name="DescLabelHost.Size" type="System.Drawing.Size, System.Drawing">
<value>644, 26</value>
<value>967, 40</value>
</data>
<data name="DescLabelHost.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -189,7 +189,7 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>DescLabelHost</value>
</data>
<data name="&gt;&gt;DescLabelHost.Type" xml:space="preserve">
<value>XenAdmin.Controls.Common.AutoHeightLabel, XenCenter, Version=0.0.0.9999, Culture=neutral, PublicKeyToken=null</value>
<value>XenAdmin.Controls.Common.AutoHeightLabel, XenCenter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;DescLabelHost.Parent" xml:space="preserve">
<value>NRPETableLayoutPanel</value>
@ -197,42 +197,6 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<data name="&gt;&gt;DescLabelHost.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="BatchConfigurationCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="BatchConfigurationCheckBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="BatchConfigurationCheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 88</value>
</data>
<data name="BatchConfigurationCheckBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 8</value>
</data>
<data name="BatchConfigurationCheckBox.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 0, 0</value>
</data>
<data name="BatchConfigurationCheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>171, 17</value>
</data>
<data name="BatchConfigurationCheckBox.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="BatchConfigurationCheckBox.Text" xml:space="preserve">
<value>Sync &amp;Configuration to all hosts</value>
</data>
<data name="&gt;&gt;BatchConfigurationCheckBox.Name" xml:space="preserve">
<value>BatchConfigurationCheckBox</value>
</data>
<data name="&gt;&gt;BatchConfigurationCheckBox.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;BatchConfigurationCheckBox.Parent" xml:space="preserve">
<value>NRPETableLayoutPanel</value>
</data>
<data name="&gt;&gt;BatchConfigurationCheckBox.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="EnableNRPECheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -240,16 +204,16 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NoControl</value>
</data>
<data name="EnableNRPECheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 116</value>
<value>4, 114</value>
</data>
<data name="EnableNRPECheckBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 8</value>
<value>4, 4, 4, 12</value>
</data>
<data name="EnableNRPECheckBox.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 0, 0</value>
<value>4, 0, 0, 0</value>
</data>
<data name="EnableNRPECheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>95, 17</value>
<value>137, 24</value>
</data>
<data name="EnableNRPECheckBox.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -267,7 +231,7 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NRPETableLayoutPanel</value>
</data>
<data name="&gt;&gt;EnableNRPECheckBox.ZOrder" xml:space="preserve">
<value>3</value>
<value>2</value>
</data>
<data name="GeneralConfigTableLayoutPanel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -288,10 +252,13 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NoControl</value>
</data>
<data name="AllowHostsLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 6</value>
<value>4, 7</value>
</data>
<data name="AllowHostsLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="AllowHostsLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>96, 13</value>
<value>142, 20</value>
</data>
<data name="AllowHostsLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -315,10 +282,13 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>Left, Right</value>
</data>
<data name="AllowHostsTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>105, 3</value>
<value>154, 4</value>
</data>
<data name="AllowHostsTextBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="AllowHostsTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>530, 20</value>
<value>801, 26</value>
</data>
<data name="AllowHostsTextBox.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -342,13 +312,16 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NoControl</value>
</data>
<data name="DebugLogCheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 29</value>
<value>4, 38</value>
</data>
<data name="DebugLogCheckBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="DebugLogCheckBox.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 0, 0</value>
<value>4, 0, 0, 0</value>
</data>
<data name="DebugLogCheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>211, 17</value>
<value>313, 24</value>
</data>
<data name="DebugLogCheckBox.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -375,13 +348,16 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NoControl</value>
</data>
<data name="SslDebugLogCheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 52</value>
<value>4, 70</value>
</data>
<data name="SslDebugLogCheckBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="SslDebugLogCheckBox.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 0, 0</value>
<value>4, 0, 0, 0</value>
</data>
<data name="SslDebugLogCheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>181, 17</value>
<value>269, 24</value>
</data>
<data name="SslDebugLogCheckBox.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
@ -405,13 +381,16 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>Top</value>
</data>
<data name="GeneralConfigTableLayoutPanel.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 16</value>
<value>4, 23</value>
</data>
<data name="GeneralConfigTableLayoutPanel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="GeneralConfigTableLayoutPanel.RowCount" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="GeneralConfigTableLayoutPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>638, 72</value>
<value>959, 98</value>
</data>
<data name="GeneralConfigTableLayoutPanel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -429,22 +408,22 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>0</value>
</data>
<data name="GeneralConfigTableLayoutPanel.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="AllowHostsLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="AllowHostsTextBox" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="DebugLogCheckBox" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="SslDebugLogCheckBox" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="AllowHostsLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="AllowHostsTextBox" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="DebugLogCheckBox" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="SslDebugLogCheckBox" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,30" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="GeneralConfigureGroupBox.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="GeneralConfigureGroupBox.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 144</value>
<value>4, 154</value>
</data>
<data name="GeneralConfigureGroupBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 10</value>
<value>4, 4, 4, 15</value>
</data>
<data name="GeneralConfigureGroupBox.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 0</value>
<value>4, 4, 4, 0</value>
</data>
<data name="GeneralConfigureGroupBox.Size" type="System.Drawing.Size, System.Drawing">
<value>644, 100</value>
<value>967, 150</value>
</data>
<data name="GeneralConfigureGroupBox.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
@ -462,7 +441,7 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NRPETableLayoutPanel</value>
</data>
<data name="&gt;&gt;GeneralConfigureGroupBox.ZOrder" xml:space="preserve">
<value>4</value>
<value>3</value>
</data>
<data name="CheckDataGridView.ColumnHeadersHeight" type="System.Int32, mscorlib">
<value>34</value>
@ -495,13 +474,19 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>Fill</value>
</data>
<data name="CheckDataGridView.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 257</value>
<value>4, 323</value>
</data>
<data name="CheckDataGridView.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="CheckDataGridView.RowHeadersWidth" type="System.Int32, mscorlib">
<value>62</value>
</data>
<data name="CheckDataGridView.ScrollBars" type="System.Windows.Forms.ScrollBars, System.Windows.Forms">
<value>None</value>
</data>
<data name="CheckDataGridView.Size" type="System.Drawing.Size, System.Drawing">
<value>644, 248</value>
<value>967, 411</value>
</data>
<data name="CheckDataGridView.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -510,13 +495,13 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>CheckDataGridView</value>
</data>
<data name="&gt;&gt;CheckDataGridView.Type" xml:space="preserve">
<value>XenAdmin.Controls.DataGridViewEx.DataGridViewEx, XenCenter, Version=0.0.0.9999, Culture=neutral, PublicKeyToken=null</value>
<value>XenAdmin.Controls.DataGridViewEx.DataGridViewEx, XenCenter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;CheckDataGridView.Parent" xml:space="preserve">
<value>NRPETableLayoutPanel</value>
</data>
<data name="&gt;&gt;CheckDataGridView.ZOrder" xml:space="preserve">
<value>5</value>
<value>4</value>
</data>
<data name="RetrieveNRPEPanel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -531,10 +516,13 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NoControl</value>
</data>
<data name="RetrieveNRPELabel.Location" type="System.Drawing.Point, System.Drawing">
<value>24, 0</value>
<value>36, 0</value>
</data>
<data name="RetrieveNRPELabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="RetrieveNRPELabel.Size" type="System.Drawing.Size, System.Drawing">
<value>619, 5</value>
<value>928, 32</value>
</data>
<data name="RetrieveNRPELabel.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -561,13 +549,10 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NoControl</value>
</data>
<data name="RetrieveNRPEPicture.Location" type="System.Drawing.Point, System.Drawing">
<value>2, 2</value>
</data>
<data name="RetrieveNRPEPicture.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>3, 3</value>
</data>
<data name="RetrieveNRPEPicture.Size" type="System.Drawing.Size, System.Drawing">
<value>17, 1</value>
<value>26, 26</value>
</data>
<data name="RetrieveNRPEPicture.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -585,16 +570,13 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>1</value>
</data>
<data name="RetrieveNRPEPanel.Location" type="System.Drawing.Point, System.Drawing">
<value>2, 510</value>
</data>
<data name="RetrieveNRPEPanel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>3, 741</value>
</data>
<data name="RetrieveNRPEPanel.RowCount" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="RetrieveNRPEPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>646, 5</value>
<value>968, 32</value>
</data>
<data name="RetrieveNRPEPanel.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -609,7 +591,7 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>NRPETableLayoutPanel</value>
</data>
<data name="&gt;&gt;RetrieveNRPEPanel.ZOrder" xml:space="preserve">
<value>6</value>
<value>5</value>
</data>
<data name="RetrieveNRPEPanel.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="RetrieveNRPELabel" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="RetrieveNRPEPicture" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
@ -621,13 +603,13 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>0, 0</value>
</data>
<data name="NRPETableLayoutPanel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 10, 3, 0</value>
<value>4, 15, 4, 0</value>
</data>
<data name="NRPETableLayoutPanel.RowCount" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="NRPETableLayoutPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>650, 537</value>
<value>975, 806</value>
</data>
<data name="NRPETableLayoutPanel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -645,19 +627,22 @@ Use this page to review and modify the NRPE configuration and metric threshold s
<value>0</value>
</data>
<data name="NRPETableLayoutPanel.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="DescLabelPool" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="DescLabelHost" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="BatchConfigurationCheckBox" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="EnableNRPECheckBox" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="GeneralConfigureGroupBox" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="CheckDataGridView" Row="5" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="RetrieveNRPEPanel" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="DescLabelPool" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="DescLabelHost" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="EnableNRPECheckBox" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="GeneralConfigureGroupBox" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="CheckDataGridView" Row="5" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="RetrieveNRPEPanel" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,Absolute,30" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>96, 96</value>
<value>144, 144</value>
</data>
<data name="$this.AutoScroll" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>650, 537</value>
<value>975, 806</value>
</data>
<data name="&gt;&gt;CheckColumn.Name" xml:space="preserve">
<value>CheckColumn</value>

View File

@ -34,7 +34,7 @@ using XenAPI;
namespace XenAdmin.Actions.NRPE
{
public class NRPEHostConfiguration : ICloneable
public class NRPEHostConfiguration : ICloneable, IEquatable<NRPEHostConfiguration>
{
public const string XAPI_NRPE_PLUGIN_NAME = "nrpe";
public const string XAPI_NRPE_STATUS = "status";
@ -101,6 +101,29 @@ namespace XenAdmin.Actions.NRPE
return _checkDict.TryGetValue(name, out check);
}
public bool Equals(NRPEHostConfiguration other)
{
if (EnableNRPE != other.EnableNRPE ||
!AllowHosts.Equals(other.AllowHosts) ||
Debug != other.Debug ||
SslLogging != other.SslLogging)
{
return false;
}
foreach (KeyValuePair<string, Check> kvp in CheckDict)
{
Check CurrentCheck = kvp.Value;
other.GetNRPECheck(kvp.Key, out Check OriginalCheck);
if (CurrentCheck != null && OriginalCheck != null
&& (!CurrentCheck.WarningThreshold.Equals(OriginalCheck.WarningThreshold)
|| !CurrentCheck.CriticalThreshold.Equals(OriginalCheck.CriticalThreshold)))
{
return false;
}
}
return true;
}
public object Clone()
{
NRPEHostConfiguration cloned = new NRPEHostConfiguration

View File

@ -33,6 +33,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading;
using XenAdmin.Core;
using XenAPI;
@ -58,46 +59,29 @@ namespace XenAdmin.Actions.NRPE
protected override void Run()
{
_nrpeCurrentConfig.Status = NRPEHostConfiguration.RetrieveNRPEStatus.Successful;
if (_clone is Pool p)
// For pool, retrieve the configuration from the master of the pool.
IXenObject o = _clone is Pool p ? Helpers.GetCoordinator(p) : _clone;
try
{
List<Host> hostList = p.Connection.Cache.Hosts.ToList();
Host checkHost = hostList[0];
try
{
Host.call_plugin(checkHost.Connection.Session, checkHost.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
NRPEHostConfiguration.XAPI_NRPE_GET_THRESHOLD, null);
}
catch (Exception e)
{
log.ErrorFormat("Execute NRPE plugin failed, failed reason: {0}.", e.Message);
_nrpeCurrentConfig.Status = e.Message.Contains("UNKNOWN_XENAPI_PLUGIN_FUNCTION") ?
NRPEHostConfiguration.RetrieveNRPEStatus.Unsupport : NRPEHostConfiguration.RetrieveNRPEStatus.Failed;
}
InitNRPEGeneralConfiguration(o);
InitNRPEThreshold(o);
}
else
catch (Exception e)
{
try
{
InitNRPEGeneralConfiguration();
InitNRPEThreshold();
}
catch (Exception e)
{
log.ErrorFormat("Execute NRPE plugin failed, failed reason: {0}.", e.Message);
_nrpeCurrentConfig.Status = e.Message.Contains("UNKNOWN_XENAPI_PLUGIN_FUNCTION") ?
NRPEHostConfiguration.RetrieveNRPEStatus.Unsupport : NRPEHostConfiguration.RetrieveNRPEStatus.Failed;
}
log.ErrorFormat("Execute NRPE plugin failed, failed reason: {0}", e.Message);
_nrpeCurrentConfig.Status = e.Message.Contains("UNKNOWN_XENAPI_PLUGIN_FUNCTION") || e.Message.Contains("The requested plug-in could not be found") ?
NRPEHostConfiguration.RetrieveNRPEStatus.Unsupport : NRPEHostConfiguration.RetrieveNRPEStatus.Failed;
}
}
private void InitNRPEGeneralConfiguration()
private void InitNRPEGeneralConfiguration(IXenObject o)
{
string status = Host.call_plugin(_clone.Connection.Session, _clone.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
string status = Host.call_plugin(o.Connection.Session, o.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
NRPEHostConfiguration.XAPI_NRPE_STATUS, null);
log.InfoFormat("Execute nrpe {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_STATUS, status);
_nrpeCurrentConfig.EnableNRPE = status.Trim().Equals("active enabled");
string nrpeConfig = Host.call_plugin(_clone.Connection.Session, _clone.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
string nrpeConfig = Host.call_plugin(o.Connection.Session, o.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
NRPEHostConfiguration.XAPI_NRPE_GET_CONFIG, null);
log.InfoFormat("Execute nrpe {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_GET_CONFIG, nrpeConfig);
@ -122,9 +106,9 @@ namespace XenAdmin.Actions.NRPE
}
}
private void InitNRPEThreshold()
private void InitNRPEThreshold(IXenObject o)
{
string nrpeThreshold = Host.call_plugin(_clone.Connection.Session, _clone.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
string nrpeThreshold = Host.call_plugin(o.Connection.Session, o.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
NRPEHostConfiguration.XAPI_NRPE_GET_THRESHOLD, null);
log.InfoFormat("Execute nrpe {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_GET_THRESHOLD, nrpeThreshold);

View File

@ -56,7 +56,7 @@ namespace XenAdmin.Actions.NRPE
{
if (_clone is Host)
{
SetNRPEConfigureForHost();
SetNRPEConfigureForHost(_clone);
}
else
{
@ -64,12 +64,12 @@ namespace XenAdmin.Actions.NRPE
}
}
private void SetNRPEConfigureForHost()
private void SetNRPEConfigureForHost(IXenObject o)
{
// Enable/Disable NRPE
if (!_nrpeHostConfiguration.EnableNRPE == _nrpeOriginalConfig.EnableNRPE)
{
SetNRPEStatus(_clone, _nrpeHostConfiguration.EnableNRPE);
SetNRPEStatus(o, _nrpeHostConfiguration.EnableNRPE);
}
if (!_nrpeHostConfiguration.EnableNRPE) // If disable, return
{
@ -81,7 +81,7 @@ namespace XenAdmin.Actions.NRPE
|| !_nrpeHostConfiguration.Debug.Equals(_nrpeOriginalConfig.Debug)
|| !_nrpeHostConfiguration.SslLogging.Equals(_nrpeOriginalConfig.SslLogging))
{
SetNRPEGeneralConfiguration(_clone, _nrpeHostConfiguration.AllowHosts, _nrpeHostConfiguration.Debug, _nrpeHostConfiguration.SslLogging);
SetNRPEGeneralConfiguration(o, _nrpeHostConfiguration.AllowHosts, _nrpeHostConfiguration.Debug, _nrpeHostConfiguration.SslLogging);
}
// NRPE Check Threshold
@ -93,45 +93,19 @@ namespace XenAdmin.Actions.NRPE
&& (!CurrentCheck.WarningThreshold.Equals(OriginalCheck.WarningThreshold)
|| !CurrentCheck.CriticalThreshold.Equals(OriginalCheck.CriticalThreshold)))
{
SetNRPEThreshold(_clone, CurrentCheck.Name, CurrentCheck.WarningThreshold, CurrentCheck.CriticalThreshold);
SetNRPEThreshold(o, CurrentCheck.Name, CurrentCheck.WarningThreshold, CurrentCheck.CriticalThreshold);
}
}
RestartNRPE(_clone);
RestartNRPE(o);
}
private void SetNRPEConfigureForPool()
{
List<Host> hostList = null;
if (_clone is Pool p)
{
hostList = p.Connection.Cache.Hosts.ToList();
}
List<Host> hostList = ((Pool) _clone).Connection.Cache.Hosts.ToList();
hostList.ForEach(host =>
{
// Enable/Disable NRPE
SetNRPEStatus(host, _nrpeHostConfiguration.EnableNRPE);
if (!_nrpeHostConfiguration.EnableNRPE) // If disable, return
{
return;
}
// NRPE General Configuration
SetNRPEGeneralConfiguration(host, _nrpeHostConfiguration.AllowHosts, _nrpeHostConfiguration.Debug, _nrpeHostConfiguration.SslLogging);
// NRPE Check Threshold
foreach (KeyValuePair<string, NRPEHostConfiguration.Check> kvp in _nrpeHostConfiguration.CheckDict)
{
NRPEHostConfiguration.Check CurrentCheck = kvp.Value;
_nrpeOriginalConfig.GetNRPECheck(kvp.Key, out NRPEHostConfiguration.Check OriginalCheck);
if (CurrentCheck != null)
{
SetNRPEThreshold(host, CurrentCheck.Name, CurrentCheck.WarningThreshold, CurrentCheck.CriticalThreshold);
}
}
RestartNRPE(host);
SetNRPEConfigureForHost(host);
});
}