mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +01:00
Resolve NRPE code review comments from Tina.
This commit is contained in:
parent
7dfe809c66
commit
2ad5fd8792
213
XenAdmin/SettingsPanels/NRPEEditPage.CheckGroup.cs
Normal file
213
XenAdmin/SettingsPanels/NRPEEditPage.CheckGroup.cs
Normal file
@ -0,0 +1,213 @@
|
||||
/* Copyright (c) Cloud Software Group, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace XenAdmin.SettingsPanels
|
||||
{
|
||||
public partial class NRPEEditPage
|
||||
{
|
||||
public class CheckGroup
|
||||
{
|
||||
private const decimal THRESHOLD_MINIMUM = 0.01M;
|
||||
private const decimal THRESHOLD_MAXIMUM = 100M;
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public DataGridViewRow CheckThresholdRow { get; }
|
||||
|
||||
public DataGridViewTextBoxCell NameCell { get; }
|
||||
|
||||
public DataGridViewTextBoxCell WarningThresholdCell { get; }
|
||||
|
||||
public DataGridViewTextBoxCell CriticalThresholdCell { get; }
|
||||
|
||||
public CheckGroup(string name, string labelName)
|
||||
{
|
||||
Name = name;
|
||||
NameCell = new DataGridViewTextBoxCell { Value = labelName };
|
||||
WarningThresholdCell = new DataGridViewTextBoxCell();
|
||||
CriticalThresholdCell = new DataGridViewTextBoxCell();
|
||||
CheckThresholdRow = new DataGridViewRow();
|
||||
CheckThresholdRow.Cells.AddRange(NameCell, WarningThresholdCell, CriticalThresholdCell);
|
||||
CheckThresholdRow.DefaultCellStyle.Format = "N2";
|
||||
CheckThresholdRow.DefaultCellStyle.NullValue = 0;
|
||||
WarningThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
|
||||
CriticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
|
||||
}
|
||||
|
||||
public void UpdateThreshold(string warningThreshold, string criticalThreshold)
|
||||
{
|
||||
WarningThresholdCell.Value = warningThreshold;
|
||||
CriticalThresholdCell.Value = criticalThreshold;
|
||||
WarningThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
|
||||
CriticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
|
||||
}
|
||||
|
||||
public virtual bool CheckValue()
|
||||
{
|
||||
WarningThresholdCell.ErrorText = "";
|
||||
CriticalThresholdCell.ErrorText = "";
|
||||
|
||||
return CheckEachValue(WarningThresholdCell) &&
|
||||
CheckEachValue(CriticalThresholdCell) &&
|
||||
CompareWarningAndCritical();
|
||||
}
|
||||
|
||||
protected virtual bool CheckEachValue(DataGridViewTextBoxCell cell)
|
||||
{
|
||||
string thresholdStr = cell.Value.ToString().Trim();
|
||||
if (thresholdStr.Equals(""))
|
||||
{
|
||||
cell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_SHOULD_NOT_BE_EMPTY);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!decimal.TryParse(thresholdStr, out decimal threshold))
|
||||
{
|
||||
cell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_SHOULD_BE_NUMBER);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (threshold < THRESHOLD_MINIMUM || threshold > THRESHOLD_MAXIMUM)
|
||||
{
|
||||
cell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_RANGE_ERROR, THRESHOLD_MINIMUM,
|
||||
THRESHOLD_MAXIMUM);
|
||||
return false;
|
||||
}
|
||||
|
||||
cell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool CompareWarningAndCritical()
|
||||
{
|
||||
decimal.TryParse(WarningThresholdCell.Value.ToString().Trim(), out decimal warningDecimal);
|
||||
decimal.TryParse(CriticalThresholdCell.Value.ToString().Trim(), out decimal criticalDecimal);
|
||||
if (warningDecimal < criticalDecimal)
|
||||
{
|
||||
WarningThresholdCell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningThresholdCell.ErrorText =
|
||||
string.Format(Messages.NRPE_THRESHOLD_WARNING_SHOULD_LESS_THAN_CRITICAL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FreeCheckGroup : CheckGroup
|
||||
{
|
||||
public FreeCheckGroup(string name, string labelName)
|
||||
: base(name, labelName)
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool CompareWarningAndCritical()
|
||||
{
|
||||
decimal.TryParse(WarningThresholdCell.Value.ToString().Trim(), out decimal warningDecimal);
|
||||
decimal.TryParse(CriticalThresholdCell.Value.ToString().Trim(), out decimal criticalDecimal);
|
||||
if (warningDecimal > criticalDecimal)
|
||||
{
|
||||
WarningThresholdCell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningThresholdCell.ErrorText =
|
||||
string.Format(Messages.NRPE_THRESHOLD_WARNING_SHOULD_BIGGER_THAN_CRITICAL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class HostLoadCheckGroup : CheckGroup
|
||||
{
|
||||
public HostLoadCheckGroup(string name, string labelName)
|
||||
: base(name, labelName)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class Dom0LoadCheckGroup : CheckGroup
|
||||
{
|
||||
public Dom0LoadCheckGroup(string name, string labelName)
|
||||
: base(name, labelName)
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool CompareWarningAndCritical()
|
||||
{
|
||||
string[] warningArray = WarningThresholdCell.Value.ToString().Split(',');
|
||||
string[] criticalArray = CriticalThresholdCell.Value.ToString().Split(',');
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
decimal.TryParse(warningArray[i].Trim(), out decimal warningDecimal);
|
||||
decimal.TryParse(criticalArray[i].Trim(), out decimal criticalDecimal);
|
||||
if (warningDecimal > criticalDecimal)
|
||||
{
|
||||
WarningThresholdCell.ErrorText =
|
||||
string.Format(Messages.NRPE_THRESHOLD_WARNING_SHOULD_LESS_THAN_CRITICAL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
WarningThresholdCell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool CheckEachValue(DataGridViewTextBoxCell cell)
|
||||
{
|
||||
cell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_SHOULD_BE_3_NUMBERS);
|
||||
string[] loadArray = cell.Value.ToString().Split(',');
|
||||
if (loadArray.Length != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (string load in loadArray)
|
||||
{
|
||||
bool isDecimal = decimal.TryParse(load, out _);
|
||||
if (!isDecimal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
cell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
XenAdmin/SettingsPanels/NRPEEditPage.Designer.cs
generated
44
XenAdmin/SettingsPanels/NRPEEditPage.Designer.cs
generated
@ -40,12 +40,12 @@ namespace XenAdmin.SettingsPanels
|
||||
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.CheckColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.WarningThresholdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.CriticalThresholdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.RetrieveNRPEPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.RetrieveNRPELabel = new System.Windows.Forms.Label();
|
||||
this.RetrieveNRPEPicture = new System.Windows.Forms.PictureBox();
|
||||
this.NRPETableLayoutPanel.SuspendLayout();
|
||||
this.GeneralConfigureGroupBox.SuspendLayout();
|
||||
this.GeneralConfigTableLayoutPanel.SuspendLayout();
|
||||
@ -136,24 +136,8 @@ namespace XenAdmin.SettingsPanels
|
||||
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");
|
||||
this.RetrieveNRPEPanel.Controls.Add(this.RetrieveNRPELabel, 1, 0);
|
||||
this.RetrieveNRPEPanel.Controls.Add(this.RetrieveNRPEPicture, 0, 0);
|
||||
this.RetrieveNRPEPanel.Name = "RetrieveNRPEPanel";
|
||||
//
|
||||
// RetrieveNRPELabel
|
||||
//
|
||||
resources.ApplyResources(this.RetrieveNRPELabel, "RetrieveNRPELabel");
|
||||
this.RetrieveNRPELabel.Name = "RetrieveNRPELabel";
|
||||
//
|
||||
// RetrieveNRPEPicture
|
||||
//
|
||||
resources.ApplyResources(this.RetrieveNRPEPicture, "RetrieveNRPEPicture");
|
||||
this.RetrieveNRPEPicture.Name = "RetrieveNRPEPicture";
|
||||
this.RetrieveNRPEPicture.TabStop = false;
|
||||
this.CheckDataGridView.ShowCellErrors = true;
|
||||
this.CheckDataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.CheckDataGridView_EndEdit);
|
||||
//
|
||||
// CheckColumn
|
||||
//
|
||||
@ -174,6 +158,24 @@ namespace XenAdmin.SettingsPanels
|
||||
resources.ApplyResources(this.CriticalThresholdColumn, "CriticalThresholdColumn");
|
||||
this.CriticalThresholdColumn.Name = "CriticalThresholdColumn";
|
||||
//
|
||||
// RetrieveNRPEPanel
|
||||
//
|
||||
resources.ApplyResources(this.RetrieveNRPEPanel, "RetrieveNRPEPanel");
|
||||
this.RetrieveNRPEPanel.Controls.Add(this.RetrieveNRPELabel, 1, 0);
|
||||
this.RetrieveNRPEPanel.Controls.Add(this.RetrieveNRPEPicture, 0, 0);
|
||||
this.RetrieveNRPEPanel.Name = "RetrieveNRPEPanel";
|
||||
//
|
||||
// RetrieveNRPELabel
|
||||
//
|
||||
resources.ApplyResources(this.RetrieveNRPELabel, "RetrieveNRPELabel");
|
||||
this.RetrieveNRPELabel.Name = "RetrieveNRPELabel";
|
||||
//
|
||||
// RetrieveNRPEPicture
|
||||
//
|
||||
resources.ApplyResources(this.RetrieveNRPEPicture, "RetrieveNRPEPicture");
|
||||
this.RetrieveNRPEPicture.Name = "RetrieveNRPEPicture";
|
||||
this.RetrieveNRPEPicture.TabStop = false;
|
||||
//
|
||||
// NRPEEditPage
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
|
@ -37,15 +37,11 @@ using XenAdmin.Actions;
|
||||
using XenAdmin.Core;
|
||||
using XenAdmin.Actions.NRPE;
|
||||
using XenAPI;
|
||||
using System.Linq;
|
||||
using XenAdmin.Network;
|
||||
|
||||
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,})$");
|
||||
@ -119,8 +115,6 @@ namespace XenAdmin.SettingsPanels
|
||||
{
|
||||
_invalidParamToolTipText = "";
|
||||
_invalidParamToolTip.ToolTipTitle = "";
|
||||
CheckDataGridView.ShowCellToolTips = false;
|
||||
CheckDataGridView.ShowCellErrors = false;
|
||||
|
||||
if (!EnableNRPECheckBox.Checked)
|
||||
{
|
||||
@ -129,15 +123,23 @@ namespace XenAdmin.SettingsPanels
|
||||
|
||||
bool valid = IsAllowHostsValid();
|
||||
|
||||
DataGridViewTextBoxCell focusCellWhenErrorOccurs = null;
|
||||
foreach (CheckGroup checkGroup in _checkGroupList)
|
||||
{
|
||||
if (!checkGroup.CheckValue())
|
||||
{
|
||||
CheckDataGridView.ShowCellToolTips = true;
|
||||
CheckDataGridView.ShowCellErrors = true;
|
||||
valid = false;
|
||||
if (focusCellWhenErrorOccurs == null)
|
||||
{
|
||||
focusCellWhenErrorOccurs = checkGroup.NameCell;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (focusCellWhenErrorOccurs != null)
|
||||
{
|
||||
CheckDataGridView.CurrentCell = CheckDataGridView.Rows[0].Cells[0];
|
||||
CheckDataGridView.CurrentCell = focusCellWhenErrorOccurs;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
}
|
||||
@ -190,7 +192,7 @@ namespace XenAdmin.SettingsPanels
|
||||
UpdateRetrievingNRPETip(NRPEHostConfiguration.RetrieveNRPEStatus.Retrieving);
|
||||
DisableAllComponent();
|
||||
|
||||
NRPERetrieveAction action = new NRPERetrieveAction(_clone, _nrpeOriginalConfig, _checkGroupDictByName, true);
|
||||
NRPERetrieveAction action = new NRPERetrieveAction(_clone, _nrpeOriginalConfig, true);
|
||||
action.Completed += ActionCompleted;
|
||||
action.RunAsync();
|
||||
}
|
||||
@ -250,6 +252,12 @@ namespace XenAdmin.SettingsPanels
|
||||
Color.FromKnownColor(KnownColor.ControlDark) : AllowHostsTextBox.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
|
||||
DebugLogCheckBox.Checked = _nrpeOriginalConfig.Debug;
|
||||
SslDebugLogCheckBox.Checked = _nrpeOriginalConfig.SslLogging;
|
||||
|
||||
foreach (KeyValuePair<string, NRPEHostConfiguration.Check> check in _nrpeOriginalConfig.CheckDict)
|
||||
{
|
||||
_checkGroupDictByName.TryGetValue(check.Key, out CheckGroup cg);
|
||||
cg?.UpdateThreshold(check.Value.WarningThreshold, check.Value.CriticalThreshold);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateComponentStatusBasedEnableNRPECheckBox()
|
||||
@ -272,13 +280,14 @@ namespace XenAdmin.SettingsPanels
|
||||
checkGroup.CriticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
|
||||
}
|
||||
}
|
||||
CheckDataGridView.ShowCellToolTips = EnableNRPECheckBox.Checked;
|
||||
CheckDataGridView.ShowCellErrors = EnableNRPECheckBox.Checked;
|
||||
}
|
||||
|
||||
private bool IsAllowHostsValid()
|
||||
{
|
||||
_invalidParamToolTip.ToolTipTitle = Messages.NRPE_ALLOW_HOSTS_ERROR_TITLE;
|
||||
_invalidParamToolTip.Tag = AllowHostsTextBox;
|
||||
CheckDataGridView.ShowCellToolTips = true;
|
||||
|
||||
string str = AllowHostsTextBox.Text;
|
||||
if (str.Trim().Length == 0 || str.Trim().Equals(NRPEHostConfiguration.ALLOW_HOSTS_PLACE_HOLDER))
|
||||
@ -316,7 +325,6 @@ namespace XenAdmin.SettingsPanels
|
||||
return false;
|
||||
}
|
||||
}
|
||||
CheckDataGridView.ShowCellToolTips = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -341,14 +349,14 @@ namespace XenAdmin.SettingsPanels
|
||||
_nrpeCurrentConfig = new NRPEHostConfiguration
|
||||
{
|
||||
EnableNRPE = EnableNRPECheckBox.Checked,
|
||||
AllowHosts = AllowHostsTextBox.Text,
|
||||
AllowHosts = AllowHostsTextBox.Text.Replace(" ", string.Empty),
|
||||
Debug = DebugLogCheckBox.Checked,
|
||||
SslLogging = SslDebugLogCheckBox.Checked
|
||||
};
|
||||
foreach (KeyValuePair<string, CheckGroup> item in _checkGroupDictByName)
|
||||
{
|
||||
_nrpeCurrentConfig.AddNRPECheck(new NRPEHostConfiguration.Check(item.Key,
|
||||
item.Value.WarningThresholdCell.Value.ToString(), item.Value.CriticalThresholdCell.Value.ToString()));
|
||||
item.Value.WarningThresholdCell.Value.ToString().Trim(), item.Value.CriticalThresholdCell.Value.ToString().Trim()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,5 +382,13 @@ namespace XenAdmin.SettingsPanels
|
||||
AllowHostsTextBox.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckDataGridView_EndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
foreach (CheckGroup checkGroup in _checkGroupList)
|
||||
{
|
||||
checkGroup.CheckValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>XenAdmin</RootNamespace>
|
||||
<AssemblyName>XenCenter</AssemblyName>
|
||||
<AssemblyName>[XenCenter]</AssemblyName>
|
||||
<ApplicationIcon>..\Branding\Images\AppIcon.ico</ApplicationIcon>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
@ -483,6 +483,10 @@
|
||||
<Compile Include="SettingsPanels\NRPEEditPage.Designer.cs">
|
||||
<DependentUpon>NRPEEditPage.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SettingsPanels\NRPEEditPage.CheckGroup.cs">
|
||||
<DependentUpon>NRPEEditPage.cs</DependentUpon>
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SettingsPanels\PoolAdvancedEditPage.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -1,267 +0,0 @@
|
||||
/* Copyright (c) Cloud Software Group, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace XenAdmin.Actions.NRPE
|
||||
{
|
||||
public class CheckGroup
|
||||
{
|
||||
private static readonly string DEFAULT_CHECK_WARNING_THRESHOLD = "80";
|
||||
private static readonly string DEFAULT_CHECK_CRITICAL_THRESHOLD = "90";
|
||||
|
||||
private readonly decimal THRESHOLD_MINIMUM = 0.01M;
|
||||
private readonly decimal THRESHOLD_MAXIMUM = 100M;
|
||||
|
||||
private string name;
|
||||
private string warningThresholdDefault;
|
||||
private string criticalThresholdDefault;
|
||||
private bool changed;
|
||||
|
||||
protected DataGridViewRow checkThresholdRow;
|
||||
protected DataGridViewTextBoxCell nameCell;
|
||||
protected DataGridViewTextBoxCell warningThresholdCell;
|
||||
protected DataGridViewTextBoxCell criticalThresholdCell;
|
||||
|
||||
public string Name { get => name; set => name = value; }
|
||||
public string WarningThresholdDefault { get => warningThresholdDefault; set => warningThresholdDefault = value; }
|
||||
public string CriticalThresholdDefault { get => criticalThresholdDefault; set => criticalThresholdDefault = value; }
|
||||
public bool Changed { get => changed; set => changed = value; }
|
||||
public DataGridViewRow CheckThresholdRow { get => checkThresholdRow; set => checkThresholdRow = value; }
|
||||
public DataGridViewTextBoxCell NameCell { get => nameCell; set => nameCell = value; }
|
||||
public DataGridViewTextBoxCell WarningThresholdCell { get => warningThresholdCell; set => warningThresholdCell = value; }
|
||||
public DataGridViewTextBoxCell CriticalThresholdCell { get => criticalThresholdCell; set => criticalThresholdCell = value; }
|
||||
|
||||
public CheckGroup(string name, string labelName, string warningThresholdDefaultValue, string criticalThresholdDefaultValue)
|
||||
{
|
||||
InitCheckGroup(name, labelName, warningThresholdDefaultValue, criticalThresholdDefaultValue);
|
||||
}
|
||||
|
||||
public CheckGroup(string name, string labelName)
|
||||
{
|
||||
InitCheckGroup(name, labelName, DEFAULT_CHECK_WARNING_THRESHOLD, DEFAULT_CHECK_CRITICAL_THRESHOLD);
|
||||
}
|
||||
|
||||
private void InitCheckGroup(string name, string labelName, string warningThresholdDefaultValue, string criticalThresholdDefaultValue)
|
||||
{
|
||||
Name = name;
|
||||
nameCell = new DataGridViewTextBoxCell { Value = labelName };
|
||||
warningThresholdDefault = warningThresholdDefaultValue;
|
||||
criticalThresholdDefault = criticalThresholdDefaultValue;
|
||||
warningThresholdCell = new DataGridViewTextBoxCell { Value = warningThresholdDefaultValue };
|
||||
criticalThresholdCell = new DataGridViewTextBoxCell { Value = criticalThresholdDefaultValue };
|
||||
checkThresholdRow = new DataGridViewRow();
|
||||
checkThresholdRow.Cells.AddRange(nameCell, warningThresholdCell, criticalThresholdCell);
|
||||
checkThresholdRow.DefaultCellStyle.Format = "N2";
|
||||
checkThresholdRow.DefaultCellStyle.NullValue = 0;
|
||||
warningThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
|
||||
criticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlDark);
|
||||
}
|
||||
|
||||
public void UpdateThreshold(string warningThreshold, string criticalThreshold)
|
||||
{
|
||||
warningThresholdCell.Value = warningThreshold;
|
||||
criticalThresholdCell.Value = criticalThreshold;
|
||||
warningThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
|
||||
criticalThresholdCell.Style.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
|
||||
}
|
||||
|
||||
public virtual bool CheckValue()
|
||||
{
|
||||
warningThresholdCell.ErrorText = "";
|
||||
criticalThresholdCell.ErrorText = "";
|
||||
|
||||
if (IsEmptyForPool())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CheckEachValue(warningThresholdCell) &&
|
||||
CheckEachValue(criticalThresholdCell) &&
|
||||
CompareWarningAndCritical() &&
|
||||
CheckModifyAllForPool())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsEmptyForPool()
|
||||
{
|
||||
return warningThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlDark))
|
||||
&& criticalThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlDark));
|
||||
}
|
||||
|
||||
protected virtual bool CheckEachValue(DataGridViewTextBoxCell cell)
|
||||
{
|
||||
string thresholdStr = cell.Value.ToString().Trim();
|
||||
if (thresholdStr.Equals(""))
|
||||
{
|
||||
cell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_SHOULD_NOT_BE_EMPTY);
|
||||
return false;
|
||||
}
|
||||
if (!decimal.TryParse(thresholdStr, out decimal threshold))
|
||||
{
|
||||
cell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_SHOULD_BE_NUMBER);
|
||||
return false;
|
||||
}
|
||||
if (threshold < THRESHOLD_MINIMUM || threshold > THRESHOLD_MAXIMUM)
|
||||
{
|
||||
cell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_RANGE_ERROR, THRESHOLD_MINIMUM, THRESHOLD_MAXIMUM);
|
||||
return false;
|
||||
}
|
||||
cell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool CompareWarningAndCritical()
|
||||
{
|
||||
decimal.TryParse(warningThresholdCell.Value.ToString().Trim(), out decimal warningDecimal);
|
||||
decimal.TryParse(criticalThresholdCell.Value.ToString().Trim(), out decimal criticalDecimal);
|
||||
if (warningDecimal < criticalDecimal)
|
||||
{
|
||||
warningThresholdCell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
warningThresholdCell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_WARNING_SHOULD_LESS_THAN_CRITICAL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckModifyAllForPool()
|
||||
{
|
||||
if (warningThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlText))
|
||||
&& criticalThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlDark)))
|
||||
{
|
||||
criticalThresholdCell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_SHOULD_NOT_BE_EMPTY);
|
||||
return false;
|
||||
}
|
||||
else if (warningThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlDark))
|
||||
&& criticalThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlText)))
|
||||
{
|
||||
warningThresholdCell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_SHOULD_NOT_BE_EMPTY);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class FreeCheckGroup : CheckGroup
|
||||
{
|
||||
private static readonly string DEFAULT_CHECK_WARNING_THRESHOLD = "20";
|
||||
private static readonly string DEFAULT_CHECK_CRITICAL_THRESHOLD = "10";
|
||||
|
||||
public FreeCheckGroup(string name, string labelName)
|
||||
: base(name, labelName, DEFAULT_CHECK_WARNING_THRESHOLD, DEFAULT_CHECK_CRITICAL_THRESHOLD)
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool CompareWarningAndCritical()
|
||||
{
|
||||
decimal.TryParse(warningThresholdCell.Value.ToString().Trim(), out decimal warningDecimal);
|
||||
decimal.TryParse(criticalThresholdCell.Value.ToString().Trim(), out decimal criticalDecimal);
|
||||
if (warningDecimal > criticalDecimal)
|
||||
{
|
||||
warningThresholdCell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
warningThresholdCell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_WARNING_SHOULD_BIGGER_THAN_CRITICAL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class HostLoadCheckGroup : CheckGroup
|
||||
{
|
||||
private static readonly string DEFAULT_CHECK_WARNING_THRESHOLD = "3";
|
||||
private static readonly string DEFAULT_CHECK_CRITICAL_THRESHOLD = "4";
|
||||
|
||||
public HostLoadCheckGroup(string name, string labelName)
|
||||
: base(name, labelName, DEFAULT_CHECK_WARNING_THRESHOLD, DEFAULT_CHECK_CRITICAL_THRESHOLD)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class Dom0LoadCheckGroup : CheckGroup
|
||||
{
|
||||
private static readonly string DEFAULT_CHECK_WARNING_THRESHOLD = "2.7,2.6,2.5";
|
||||
private static readonly string DEFAULT_CHECK_CRITICAL_THRESHOLD = "3.2,3.1,3";
|
||||
|
||||
public Dom0LoadCheckGroup(string name, string labelName)
|
||||
: base(name, labelName, DEFAULT_CHECK_WARNING_THRESHOLD, DEFAULT_CHECK_CRITICAL_THRESHOLD)
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool CompareWarningAndCritical()
|
||||
{
|
||||
string[] warningArray = warningThresholdCell.Value.ToString().Split(',');
|
||||
string[] criticalArray = criticalThresholdCell.Value.ToString().Split(',');
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
decimal.TryParse(warningArray[i].Trim(), out decimal warningDecimal);
|
||||
decimal.TryParse(criticalArray[i].Trim(), out decimal criticalDecimal);
|
||||
if (warningDecimal > criticalDecimal)
|
||||
{
|
||||
warningThresholdCell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_WARNING_SHOULD_LESS_THAN_CRITICAL);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
warningThresholdCell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool CheckEachValue(DataGridViewTextBoxCell cell)
|
||||
{
|
||||
checkThresholdRow.DataGridView.ShowCellToolTips = true;
|
||||
cell.ErrorText = string.Format(Messages.NRPE_THRESHOLD_SHOULD_BE_3_NUMBERS);
|
||||
string[] loadArray = cell.Value.ToString().Split(',');
|
||||
if (loadArray.Length != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (string load in loadArray)
|
||||
{
|
||||
bool isDecimal = decimal.TryParse(load, out _);
|
||||
if (!isDecimal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
cell.ErrorText = "";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -29,7 +29,6 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using XenAdmin.Core;
|
||||
using XenAPI;
|
||||
|
||||
@ -41,16 +40,14 @@ namespace XenAdmin.Actions.NRPE
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private readonly NRPEHostConfiguration _nrpeCurrentConfig;
|
||||
private readonly Dictionary<string, CheckGroup> _checkGroupDictByName;
|
||||
|
||||
private readonly IXenObject _clone;
|
||||
|
||||
public NRPERetrieveAction(IXenObject host, NRPEHostConfiguration nrpeHostConfiguration, Dictionary<string, CheckGroup> checkGroupDictByName, bool suppressHistory)
|
||||
public NRPERetrieveAction(IXenObject host, NRPEHostConfiguration nrpeHostConfiguration, bool suppressHistory)
|
||||
: base(host.Connection, Messages.NRPE_ACTION_RETRIEVING, Messages.NRPE_ACTION_RETRIEVING, suppressHistory)
|
||||
{
|
||||
_clone = host;
|
||||
_nrpeCurrentConfig = nrpeHostConfiguration;
|
||||
_checkGroupDictByName = checkGroupDictByName;
|
||||
}
|
||||
|
||||
protected override void Run()
|
||||
@ -65,7 +62,7 @@ namespace XenAdmin.Actions.NRPE
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.ErrorFormat("Execute NRPE plugin failed, failed reason: {0}", e.Message);
|
||||
log.ErrorFormat("Run NRPE plugin failed, failed reason: {0}", e.Message);
|
||||
_nrpeCurrentConfig.Status = NRPEHostConfiguration.RetrieveNRPEStatus.Failed;
|
||||
}
|
||||
}
|
||||
@ -74,12 +71,12 @@ namespace XenAdmin.Actions.NRPE
|
||||
{
|
||||
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);
|
||||
log.InfoFormat("Run NRPE {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_STATUS, status);
|
||||
_nrpeCurrentConfig.EnableNRPE = status.Trim().Equals("active enabled");
|
||||
|
||||
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);
|
||||
log.InfoFormat("Run NRPE {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_GET_CONFIG, nrpeConfig);
|
||||
|
||||
string[] nrpeConfigArray = nrpeConfig.Split('\n');
|
||||
foreach (string nrpeConfigItem in nrpeConfigArray)
|
||||
@ -106,21 +103,15 @@ namespace XenAdmin.Actions.NRPE
|
||||
{
|
||||
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);
|
||||
log.InfoFormat("Run NRPE {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_GET_THRESHOLD, nrpeThreshold);
|
||||
|
||||
string[] nrpeThresholdArray = nrpeThreshold.Split('\n');
|
||||
foreach (string nrpeThresholdItem in nrpeThresholdArray)
|
||||
{
|
||||
// Return string format for each line: check_cpu warning threshold - 50 critical threshold - 80
|
||||
string[] thresholdRtnArray = nrpeThresholdItem.Split(' ');
|
||||
string checkName = thresholdRtnArray[0];
|
||||
if (_checkGroupDictByName.TryGetValue(thresholdRtnArray[0], out CheckGroup thresholdCheck))
|
||||
{
|
||||
string warningThreshold = thresholdRtnArray[4];
|
||||
string criticalThreshold = thresholdRtnArray[8];
|
||||
thresholdCheck.UpdateThreshold(warningThreshold, criticalThreshold);
|
||||
_nrpeCurrentConfig.AddNRPECheck(new NRPEHostConfiguration.Check(checkName, warningThreshold, criticalThreshold));
|
||||
}
|
||||
_nrpeCurrentConfig.AddNRPECheck(new NRPEHostConfiguration.Check(thresholdRtnArray[0],
|
||||
thresholdRtnArray[4], thresholdRtnArray[8]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using XenAPI;
|
||||
|
||||
|
||||
@ -60,7 +61,8 @@ namespace XenAdmin.Actions.NRPE
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNRPEConfigureForPool();
|
||||
List<Host> hostList = ((Pool) _clone).Connection.Cache.Hosts.ToList();
|
||||
hostList.ForEach(SetNRPEConfigureForHost);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,10 +90,10 @@ namespace XenAdmin.Actions.NRPE
|
||||
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 && OriginalCheck != null
|
||||
&& (!currentCheck.WarningThreshold.Equals(OriginalCheck.WarningThreshold)
|
||||
|| !currentCheck.CriticalThreshold.Equals(OriginalCheck.CriticalThreshold)))
|
||||
_nrpeOriginalConfig.GetNRPECheck(kvp.Key, out NRPEHostConfiguration.Check originalCheck);
|
||||
if (currentCheck != null && originalCheck != null
|
||||
&& (!currentCheck.WarningThreshold.Equals(originalCheck.WarningThreshold)
|
||||
|| !currentCheck.CriticalThreshold.Equals(originalCheck.CriticalThreshold)))
|
||||
{
|
||||
SetNRPEThreshold(o, currentCheck.Name, currentCheck.WarningThreshold, currentCheck.CriticalThreshold);
|
||||
}
|
||||
@ -100,22 +102,13 @@ namespace XenAdmin.Actions.NRPE
|
||||
RestartNRPE(o);
|
||||
}
|
||||
|
||||
private void SetNRPEConfigureForPool()
|
||||
{
|
||||
List<Host> hostList = ((Pool) _clone).Connection.Cache.Hosts.ToList();
|
||||
hostList.ForEach(host =>
|
||||
{
|
||||
SetNRPEConfigureForHost(host);
|
||||
});
|
||||
}
|
||||
|
||||
private void SetNRPEStatus(IXenObject host, bool enableNRPE)
|
||||
{
|
||||
string nrpeUpdateStatusMethod = enableNRPE ?
|
||||
NRPEHostConfiguration.XAPI_NRPE_ENABLE : NRPEHostConfiguration.XAPI_NRPE_DISABLE;
|
||||
string result = Host.call_plugin(host.Connection.Session, host.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
|
||||
nrpeUpdateStatusMethod, null);
|
||||
log.InfoFormat("Execute nrpe {0}, return: {1}", nrpeUpdateStatusMethod, result);
|
||||
log.InfoFormat("Run NRPE {0}, return: {1}", nrpeUpdateStatusMethod, result);
|
||||
}
|
||||
|
||||
private void SetNRPEGeneralConfiguration(IXenObject host, string allowHosts, bool debug, bool sslLogging)
|
||||
@ -128,7 +121,7 @@ namespace XenAdmin.Actions.NRPE
|
||||
};
|
||||
string result = Host.call_plugin(host.Connection.Session, host.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
|
||||
NRPEHostConfiguration.XAPI_NRPE_SET_CONFIG, configArgDict);
|
||||
log.InfoFormat("Execute nrpe {0}, allowed_hosts={1}, debug={2}, ssl_logging={3}, return: {4}",
|
||||
log.InfoFormat("Run NRPE {0}, allowed_hosts={1}, debug={2}, ssl_logging={3}, return: {4}",
|
||||
NRPEHostConfiguration.XAPI_NRPE_SET_CONFIG,
|
||||
_nrpeHostConfiguration.AllowHosts,
|
||||
_nrpeHostConfiguration.Debug,
|
||||
@ -146,7 +139,7 @@ namespace XenAdmin.Actions.NRPE
|
||||
};
|
||||
string result = Host.call_plugin(host.Connection.Session, host.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
|
||||
NRPEHostConfiguration.XAPI_NRPE_SET_THRESHOLD, thresholdArgDict);
|
||||
log.InfoFormat("Execute nrpe {0}, check={1}, w={2}, c={3}, return: {4}",
|
||||
log.InfoFormat("Run NRPE {0}, check={1}, w={2}, c={3}, return: {4}",
|
||||
NRPEHostConfiguration.XAPI_NRPE_SET_THRESHOLD,
|
||||
checkName,
|
||||
warningThreshold,
|
||||
@ -159,7 +152,7 @@ namespace XenAdmin.Actions.NRPE
|
||||
{
|
||||
string result = Host.call_plugin(host.Connection.Session, host.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME,
|
||||
NRPEHostConfiguration.XAPI_NRPE_RESTART, null);
|
||||
log.InfoFormat("Execute nrpe {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_RESTART, result);
|
||||
log.InfoFormat("Run NRPE {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_RESTART, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
XenModel/Messages.Designer.cs
generated
4
XenModel/Messages.Designer.cs
generated
@ -29151,7 +29151,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please remove duplicated address.
|
||||
/// Looks up a localized string similar to Please remove duplicate addresses.
|
||||
/// </summary>
|
||||
public static string NRPE_ALLOW_HOSTS_SAME_ADDRESS {
|
||||
get {
|
||||
@ -29286,7 +29286,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Retrieve NRPE configuration failed, please check XenCenter logs..
|
||||
/// Looks up a localized string similar to Failed to retrieve NRPE configuration, please check XenCenter logs..
|
||||
/// </summary>
|
||||
public static string NRPE_RETRIEVE_FAILED {
|
||||
get {
|
||||
|
@ -10117,7 +10117,7 @@ When you configure an NFS storage repository, you simply provide the host name o
|
||||
<value>Comma separated IP address or domain list, e.g. 192.168.1.1, test.domain.com</value>
|
||||
</data>
|
||||
<data name="NRPE_ALLOW_HOSTS_SAME_ADDRESS" xml:space="preserve">
|
||||
<value>Please remove duplicated address</value>
|
||||
<value>Please remove duplicate addresses</value>
|
||||
</data>
|
||||
<data name="NRPE_BATCH_CONFIGURATION" xml:space="preserve">
|
||||
<value>NRPE batch configuration</value>
|
||||
@ -10162,7 +10162,7 @@ When you configure an NFS storage repository, you simply provide the host name o
|
||||
<value>NRPE service is inactive</value>
|
||||
</data>
|
||||
<data name="NRPE_RETRIEVE_FAILED" xml:space="preserve">
|
||||
<value>Retrieve NRPE configuration failed, please check XenCenter logs.</value>
|
||||
<value>Failed to retrieve NRPE configuration, please check XenCenter logs.</value>
|
||||
</data>
|
||||
<data name="NRPE_RETRIEVING_CONFIGURATION" xml:space="preserve">
|
||||
<value>Retrieving NRPE configuration...</value>
|
||||
|
@ -57,7 +57,6 @@
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -89,7 +88,6 @@
|
||||
<Compile Include="Actions\Host\HostAbstractAction.cs" />
|
||||
<Compile Include="Actions\Host\RebootHostAction.cs" />
|
||||
<Compile Include="Actions\Host\RestartToolstackAction.cs" />
|
||||
<Compile Include="Actions\NRPE\CheckGroup.cs" />
|
||||
<Compile Include="Actions\NRPE\NRPERetrieveAction.cs" />
|
||||
<Compile Include="Actions\NRPE\NRPEUpdateAction.cs" />
|
||||
<Compile Include="Actions\Host\ShutdownHostAction.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user