diff --git a/XenAdmin/Images.cs b/XenAdmin/Images.cs index 8d74e5df1..ea8e5dc0c 100644 --- a/XenAdmin/Images.cs +++ b/XenAdmin/Images.cs @@ -701,6 +701,7 @@ public static class StaticImages public static Bitmap _000_NewStorage_h32bit_32 = Properties.Resources._000_NewStorage_h32bit_32; public static Bitmap _000_NewVirtualAppliance_h32bit_16 = Properties.Resources._000_NewVirtualAppliance_h32bit_16; public static Bitmap _000_NewVirtualAppliance_h32bit_32 = Properties.Resources._000_NewVirtualAppliance_h32bit_32; + public static Bitmap _000_NRPE_h32bit_16 = Properties.Resources._000_NRPE_h32bit_16; public static Bitmap _000_Optimize_h32bit_16 = Properties.Resources._000_Optimize_h32bit_16; public static Bitmap _000_Patch_h32bit_16 = Properties.Resources._000_Patch_h32bit_16; public static Bitmap _000_Patch_h32bit_32 = Properties.Resources._000_Patch_h32bit_32; diff --git a/XenAdmin/Images/000_NRPE_h32bit_16.png b/XenAdmin/Images/000_NRPE_h32bit_16.png new file mode 100644 index 000000000..ca16fb916 Binary files /dev/null and b/XenAdmin/Images/000_NRPE_h32bit_16.png differ diff --git a/XenAdmin/Properties/Resources.Designer.cs b/XenAdmin/Properties/Resources.Designer.cs index d0f382452..27f802c70 100755 --- a/XenAdmin/Properties/Resources.Designer.cs +++ b/XenAdmin/Properties/Resources.Designer.cs @@ -780,6 +780,16 @@ internal static System.Drawing.Bitmap _000_NewVirtualAppliance_h32bit_32 { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _000_NRPE_h32bit_16 { + get { + object obj = ResourceManager.GetObject("_000_NRPE_h32bit_16", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/XenAdmin/Properties/Resources.resx b/XenAdmin/Properties/Resources.resx index 58f0396a1..d42c7ce36 100755 --- a/XenAdmin/Properties/Resources.resx +++ b/XenAdmin/Properties/Resources.resx @@ -1159,4 +1159,7 @@ ..\Images\rpm_package.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Images\000_NRPE_h32bit_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.CheckGroup.cs b/XenAdmin/SettingsPanels/NRPEEditPage.CheckGroup.cs index 2d8a64997..4133c3120 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.CheckGroup.cs +++ b/XenAdmin/SettingsPanels/NRPEEditPage.CheckGroup.cs @@ -28,7 +28,6 @@ * SUCH DAMAGE. */ -using System; using System.Drawing; using System.Windows.Forms; diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.cs b/XenAdmin/SettingsPanels/NRPEEditPage.cs index 2a3890627..65192e52d 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.cs +++ b/XenAdmin/SettingsPanels/NRPEEditPage.cs @@ -43,7 +43,6 @@ public partial class NRPEEditPage : UserControl, IEditPage { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private static readonly string ALLOW_HOSTS_PLACE_HOLDER = Messages.NRPE_ALLOW_HOSTS_PLACE_HOLDER; 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]))?$"); @@ -59,43 +58,44 @@ public partial class NRPEEditPage : UserControl, IEditPage private readonly Dictionary CheckGroupDictByName = new Dictionary(); private readonly Dictionary CheckGroupDictByLabel = new Dictionary(); - private readonly NRPEHostConfiguration NRPEOriginalConfig = new NRPEHostConfiguration(); - + private NRPEHostConfiguration NRPEOriginalConfig; + private NRPEHostConfiguration NRPECurrentConfig; public string SubText { get { - return Messages.NRPE_EDIT_PAGE_TEXT; + if (IsHost) + { + return EnableNRPECheckBox.Checked ? Messages.NRPE_ACTIVE : Messages.NRPE_INACTIVE; + } + else + { + return Messages.NRPE_BATCH_CONFIGURATION; + } } } - public Image Image => Images.StaticImages._000_Network_h32bit_16; + public Image Image => Images.StaticImages._000_NRPE_h32bit_16; public NRPEEditPage(bool isHost) { IsHost = isHost; InitializeComponent(); - Text = Messages.NRPE_EDIT_PAGE_TEXT; - EnableNRPECheckBox.Checked = false; - UpdateOtherComponentBasedEnableNRPECheckBox(false); + Text = "NRPE"; - AllowHostsTextBox.Text = ALLOW_HOSTS_PLACE_HOLDER; - AllowHostsTextBox.ForeColor = Color.FromKnownColor(KnownColor.ControlDark); - AllowHostsTextBox.GotFocus += AllowHostsTextBox_GotFocus; - AllowHostsTextBox.LostFocus += AllowHostsTextBox_LostFocus; - - if (isHost) - { - PoolTipsPicture.Hide(); - PoolTipsLabel.Hide(); - } - InvalidParamToolTip = new ToolTip + NRPECurrentConfig = new NRPEHostConfiguration { - IsBalloon = true, - ToolTipIcon = ToolTipIcon.Warning, - ToolTipTitle = Messages.INVALID_PARAMETER, - Tag = AllowHostsTextBox + EnableNRPE = false, + AllowHosts = NRPEHostConfiguration.ALLOW_HOSTS_PLACE_HOLDER, + Debug = false, + SslLogging = false }; + NRPEOriginalConfig = (NRPEHostConfiguration) NRPECurrentConfig.Clone(); + + EnableNRPECheckBox.DataBindings.Add("Checked", NRPECurrentConfig, "enableNRPE"); + AllowHostsTextBox.DataBindings.Add("Text", NRPECurrentConfig, "allowHosts"); + DebugLogCheckBox.DataBindings.Add("Checked", NRPECurrentConfig, "debug"); + SslDebugLogCheckBox.DataBindings.Add("Checked", NRPECurrentConfig, "sslLogging"); CheckGroupList.Add(new HostLoadCheckGroup("check_host_load", Messages.NRPE_CHECK_HOST_LOAD)); CheckGroupList.Add(new CheckGroup("check_host_cpu", Messages.NRPE_CHECK_HOST_CPU)); @@ -115,6 +115,25 @@ public NRPEEditPage(bool isHost) CheckGroupDictByName.Add(checkGroup.Name, checkGroup); CheckGroupDictByLabel.Add(checkGroup.NameCell.Value.ToString(), checkGroup); } + + UpdateOtherComponentBasedEnableNRPECheckBox(false); + + AllowHostsTextBox.ForeColor = Color.FromKnownColor(KnownColor.ControlDark); + AllowHostsTextBox.GotFocus += AllowHostsTextBox_GotFocus; + AllowHostsTextBox.LostFocus += AllowHostsTextBox_LostFocus; + + if (isHost) + { + PoolTipsPicture.Hide(); + PoolTipsLabel.Hide(); + } + InvalidParamToolTip = new ToolTip + { + IsBalloon = true, + ToolTipIcon = ToolTipIcon.Warning, + ToolTipTitle = Messages.INVALID_PARAMETER, + Tag = AllowHostsTextBox + }; } public bool ValidToSave @@ -191,36 +210,26 @@ public void SetXenObjects(IXenObject orig, IXenObject clone) public AsyncAction SaveSettings() { - NRPEHostConfiguration NRPEHostConfiguration = new NRPEHostConfiguration - { - EnableNRPE = EnableNRPECheckBox.Checked, - AllowHosts = AllowHostsTextBox.Text, - Debug = DebugLogCheckBox.Checked ? NRPEHostConfiguration.DEBUG_ENABLE : NRPEHostConfiguration.DEBUG_DISABLE, - SslLogging = SslDebugLogCheckBox.Checked ? NRPEHostConfiguration.SSL_LOGGING_ENABLE : NRPEHostConfiguration.SSL_LOGGING_DISABLE - }; - foreach (KeyValuePair item in CheckGroupDictByName) { if (item.Value.WarningThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlText)) && item.Value.CriticalThresholdCell.Style.ForeColor.Equals(Color.FromKnownColor(KnownColor.ControlText))) { - NRPEHostConfiguration.AddNRPECheck(new NRPEHostConfiguration.Check(item.Key, + NRPECurrentConfig.AddNRPECheck(new NRPEHostConfiguration.Check(item.Key, item.Value.WarningThresholdCell.Value.ToString(), item.Value.CriticalThresholdCell.Value.ToString())); } } - return new NRPEUpdateAction(Clone, NRPEHostConfiguration, NRPEOriginalConfig, false); + return new NRPEUpdateAction(Clone, NRPECurrentConfig, NRPEOriginalConfig, false); } private void InitNRPEGeneralConfiguration() { - string status = Host.call_plugin(Clone.Connection.Session, Clone.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME, + string status = Host.call_plugin(Clone.Connection.Session, Clone.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME, NRPEHostConfiguration.XAPI_NRPE_STATUS, null); log.InfoFormat("Execute nrpe {0}, return: {1}", NRPEHostConfiguration.XAPI_NRPE_STATUS, status); - EnableNRPECheckBox.Checked = status.Trim().Equals("active enabled"); - NRPEOriginalConfig.EnableNRPE = EnableNRPECheckBox.Checked; - UpdateOtherComponentBasedEnableNRPECheckBox(EnableNRPECheckBox.Checked); + 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(Clone.Connection.Session, Clone.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); @@ -230,27 +239,24 @@ private void InitNRPEGeneralConfiguration() if (nrpeConfigItem.Trim().StartsWith("allowed_hosts:")) { string allowHosts = nrpeConfigItem.Replace("allowed_hosts:", "").Trim(); - if (!allowHosts.Equals("")) - { - AllowHostsTextBox.Text = AllowHostsWithoutLocalAddress(allowHosts); - AllowHostsTextBox.ForeColor = AllowHostsTextBox.Text.Equals(ALLOW_HOSTS_PLACE_HOLDER) ? - Color.FromKnownColor(KnownColor.ControlDark) : Color.FromKnownColor(KnownColor.ControlText); - NRPEOriginalConfig.AllowHosts = AllowHostsTextBox.Text; - } + NRPECurrentConfig.AllowHosts = AllowHostsWithoutLocalAddress(allowHosts); + AllowHostsTextBox.ForeColor = AllowHostsTextBox.Text.Equals(NRPEHostConfiguration.ALLOW_HOSTS_PLACE_HOLDER) ? + Color.FromKnownColor(KnownColor.ControlDark) : Color.FromKnownColor(KnownColor.ControlText); } else if (nrpeConfigItem.Trim().StartsWith("debug:")) { string enableDebug = nrpeConfigItem.Replace("debug:", "").Trim(); - DebugLogCheckBox.Checked = enableDebug.Equals(NRPEHostConfiguration.DEBUG_ENABLE); - NRPEOriginalConfig.Debug = DebugLogCheckBox.Checked ? NRPEHostConfiguration.DEBUG_ENABLE : NRPEHostConfiguration.DEBUG_DISABLE; + NRPECurrentConfig.Debug = enableDebug.Equals(NRPEHostConfiguration.DEBUG_ENABLE); } else if (nrpeConfigItem.Trim().StartsWith("ssl_logging:")) { string enableSslLogging = nrpeConfigItem.Replace("ssl_logging:", "").Trim(); - SslDebugLogCheckBox.Checked = enableSslLogging.Equals(NRPEHostConfiguration.SSL_LOGGING_ENABLE); - NRPEOriginalConfig.SslLogging = SslDebugLogCheckBox.Checked ? NRPEHostConfiguration.SSL_LOGGING_ENABLE : NRPEHostConfiguration.SSL_LOGGING_DISABLE; + NRPECurrentConfig.SslLogging = enableSslLogging.Equals(NRPEHostConfiguration.SSL_LOGGING_ENABLE); } } + NRPEOriginalConfig = (NRPEHostConfiguration) NRPECurrentConfig.Clone(); + + UpdateOtherComponentBasedEnableNRPECheckBox(EnableNRPECheckBox.Checked); } private void InitNRPEThreshold() @@ -282,7 +288,7 @@ private bool IsAllowHostsValid() CheckDataGridView.ShowCellToolTips = true; string str = AllowHostsTextBox.Text; - if (str.Trim().Length == 0 || str.Trim().Equals(ALLOW_HOSTS_PLACE_HOLDER)) + if (str.Trim().Length == 0 || str.Trim().Equals(NRPEHostConfiguration.ALLOW_HOSTS_PLACE_HOLDER)) { InvalidParamToolTipText = Messages.NRPE_ALLOW_HOSTS_EMPTY_ERROR; return false; @@ -315,7 +321,7 @@ private string AllowHostsWithoutLocalAddress(string allowHosts) UpdatedAllowHosts += allowHost + ","; } } - return UpdatedAllowHosts.Length == 0 ? ALLOW_HOSTS_PLACE_HOLDER : + return UpdatedAllowHosts.Length == 0 ? NRPEHostConfiguration.ALLOW_HOSTS_PLACE_HOLDER : UpdatedAllowHosts.Substring(0, UpdatedAllowHosts.Length - 1); } @@ -350,7 +356,7 @@ private void EnableNRPECheckBox_CheckedChanged(object sender, EventArgs e) private void AllowHostsTextBox_GotFocus(object sender, EventArgs e) { - if (ALLOW_HOSTS_PLACE_HOLDER.Equals(AllowHostsTextBox.Text)) + if (AllowHostsTextBox.Text.Equals(NRPEHostConfiguration.ALLOW_HOSTS_PLACE_HOLDER)) { AllowHostsTextBox.Text = ""; AllowHostsTextBox.ForeColor = Color.FromKnownColor(KnownColor.ControlText); @@ -361,7 +367,7 @@ private void AllowHostsTextBox_LostFocus(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(AllowHostsTextBox.Text)) { - AllowHostsTextBox.Text = ALLOW_HOSTS_PLACE_HOLDER; + AllowHostsTextBox.Text = NRPEHostConfiguration.ALLOW_HOSTS_PLACE_HOLDER; AllowHostsTextBox.ForeColor = Color.FromKnownColor(KnownColor.ControlDark); } } diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.resx b/XenAdmin/SettingsPanels/NRPEEditPage.resx index e515bffad..1359a1cf6 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.resx +++ b/XenAdmin/SettingsPanels/NRPEEditPage.resx @@ -262,7 +262,7 @@ 5 - 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. + 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. DescLabel @@ -576,21 +576,6 @@ <?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> - - 0, 0 - - - 200, 100 - - - 0 - - - EnableNRPEFlowLayoutPanel - - - System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - True diff --git a/XenAdmin/XenAdmin.csproj b/XenAdmin/XenAdmin.csproj index d0338e5fc..44ee636f7 100755 --- a/XenAdmin/XenAdmin.csproj +++ b/XenAdmin/XenAdmin.csproj @@ -4442,6 +4442,7 @@ + diff --git a/XenModel/Actions/Host/NRPEUpdateAction.cs b/XenModel/Actions/Host/NRPEUpdateAction.cs index 148a630f9..38eefe94b 100644 --- a/XenModel/Actions/Host/NRPEUpdateAction.cs +++ b/XenModel/Actions/Host/NRPEUpdateAction.cs @@ -58,9 +58,9 @@ protected override void Run() { SetNRPEConfigureForHost(); } - else - { - SetNRPEConfigureForPool(); + else + { + SetNRPEConfigureForPool(); } } @@ -96,6 +96,8 @@ private void SetNRPEConfigureForHost() SetNRPEThreshold(Clone, CurrentCheck.Name, CurrentCheck.WarningThreshold, CurrentCheck.CriticalThreshold); } } + + RestartNRPE(Clone); } private void SetNRPEConfigureForPool() @@ -128,6 +130,8 @@ private void SetNRPEConfigureForPool() SetNRPEThreshold(host, CurrentCheck.Name, CurrentCheck.WarningThreshold, CurrentCheck.CriticalThreshold); } } + + RestartNRPE(host); }); } @@ -140,13 +144,13 @@ private void SetNRPEStatus(IXenObject host, bool enableNRPE) log.InfoFormat("Execute nrpe {0}, return: {1}", nrpeUpdateStatusMethod, result); } - private void SetNRPEGeneralConfiguration(IXenObject host, string allowHosts, string debug, string sslLogging) + private void SetNRPEGeneralConfiguration(IXenObject host, string allowHosts, bool debug, bool sslLogging) { Dictionary ConfigArgDict = new Dictionary { - { "allowed_hosts", "127.0.0.1,::1," + allowHosts }, - { "debug", debug }, - { "ssl_logging", sslLogging } + { "allowed_hosts", "127.0.0.1,::1," + (allowHosts.Equals(NRPEHostConfiguration.ALLOW_HOSTS_PLACE_HOLDER) ? "" : allowHosts) }, + { "debug", debug ? NRPEHostConfiguration.DEBUG_ENABLE : NRPEHostConfiguration.DEBUG_DISABLE }, + { "ssl_logging", sslLogging ? NRPEHostConfiguration.SSL_LOGGING_ENABLE : NRPEHostConfiguration.SSL_LOGGING_DISABLE} }; string result = Host.call_plugin(host.Connection.Session, host.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME, NRPEHostConfiguration.XAPI_NRPE_SET_CONFIG, ConfigArgDict); @@ -175,5 +179,13 @@ private void SetNRPEThreshold(IXenObject host, string checkName, string warningT criticalThreshold, result); } + + // After modified NRPE configuration, we need to restart NRPE to take effect + private void RestartNRPE(IXenObject host) + { + 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); + } } } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 8d6ee3081..4640a32ae 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -29087,6 +29087,15 @@ public static string NRPE_ACTION_CHANGING { } } + /// + /// Looks up a localized string similar to NRPE service is active. + /// + public static string NRPE_ACTIVE { + get { + return ResourceManager.GetString("NRPE_ACTIVE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Allow hosts should not be empty.. /// @@ -29123,6 +29132,15 @@ public static string NRPE_ALLOW_HOSTS_PLACE_HOLDER { } } + /// + /// Looks up a localized string similar to NRPE batch configuration. + /// + public static string NRPE_BATCH_CONFIGURATION { + get { + return ResourceManager.GetString("NRPE_BATCH_CONFIGURATION", resourceCulture); + } + } + /// /// Looks up a localized string similar to Dom0 CPU Usage (%). /// @@ -29231,6 +29249,15 @@ public static string NRPE_EDIT_PAGE_TEXT { } } + /// + /// Looks up a localized string similar to NRPE service is inactive. + /// + public static string NRPE_INACTIVE { + get { + return ResourceManager.GetString("NRPE_INACTIVE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Threshold value should range from {0} to {1}.. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index b872bea81..6277783e5 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -10095,6 +10095,9 @@ When you configure an NFS storage repository, you simply provide the host name o Changing NRPE configuration... + + NRPE service is active + Allow hosts should not be empty. @@ -10107,6 +10110,9 @@ When you configure an NFS storage repository, you simply provide the host name o Comma separated IP address or domain list, e.g. 192.168.1.1, test.domain.com + + NRPE batch configuration + Dom0 CPU Usage (%) @@ -10143,6 +10149,9 @@ When you configure an NFS storage repository, you simply provide the host name o NRPE Configuration + + NRPE service is inactive + Threshold value should range from {0} to {1}. diff --git a/XenModel/NRPE/NRPEHostConfiguration.cs b/XenModel/NRPE/NRPEHostConfiguration.cs index 14b6508cf..597556aac 100644 --- a/XenModel/NRPE/NRPEHostConfiguration.cs +++ b/XenModel/NRPE/NRPEHostConfiguration.cs @@ -28,11 +28,12 @@ * SUCH DAMAGE. */ +using System; using System.Collections.Generic; namespace XenAdmin { - public class NRPEHostConfiguration + public class NRPEHostConfiguration : ICloneable { public static readonly string XAPI_NRPE_PLUGIN_NAME = "nrpe"; public static readonly string XAPI_NRPE_STATUS = "status"; @@ -42,6 +43,7 @@ public class NRPEHostConfiguration 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"; @@ -49,16 +51,18 @@ public class NRPEHostConfiguration public static readonly string SSL_LOGGING_ENABLE = "0xff"; public static readonly 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 string debug; - private string sslLogging; + 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 string Debug { get => debug; set => debug = value; } - public string SslLogging { get => sslLogging; set => sslLogging = value; } + public bool Debug { get => debug; set => debug = value; } + public bool SslLogging { get => sslLogging; set => sslLogging = value; } public Dictionary CheckDict { get => checkDict; } public class Check @@ -89,5 +93,17 @@ public bool GetNRPECheck(string name, out Check check) { return checkDict.TryGetValue(name, out check); } + + public object Clone() + { + NRPEHostConfiguration cloned = new NRPEHostConfiguration + { + enableNRPE = enableNRPE, + allowHosts = allowHosts, + debug = debug, + sslLogging = sslLogging + }; + return cloned; + } } }