コード例 #1
0
 private void AddAndStartMonitorPack(string monitorPackPath)
 {
     try
     {
         StringBuilder sbNotifiers = new StringBuilder();
         MonitorPack   monitorPack = new MonitorPack();
         EventLog.WriteEntry(serviceEventSource, string.Format("Starting QuickMon MonitorPack '{0}'", monitorPackPath), EventLogEntryType.Information, 0);
         monitorPack.Load(monitorPackPath);
         if (monitorPack.Notifiers != null && monitorPack.Notifiers.Count > 0)
         {
             foreach (var notifier in monitorPack.Notifiers)
             {
                 sbNotifiers.AppendLine("\t" + notifier.Name);
             }
         }
         EventLog.WriteEntry(serviceEventSource, string.Format("MonitorPack '{0}' has the following notifiers\r\n{1}", monitorPack.Name, sbNotifiers.ToString()), EventLogEntryType.Information, 0);
         monitorPack.RaiseNotifierError                  += new RaiseNotifierErrorDelegare(monitorPack_RaiseNotifierError);
         monitorPack.RaiseCollectorError                 += new RaiseCollectorErrorDelegare(monitorPack_RaiseCollectorError);
         monitorPack.CollectorExecutionTimeEvent         += new CollectorExecutionTimeDelegate(monitorPack_CollectorExecutionTimeEvent);
         monitorPack.RunCollectorCorrectiveWarningScript += new RaiseCollectorCalledDelegate(monitorPack_RunCollectorCorrectiveWarningScript);
         monitorPack.RunCollectorCorrectiveErrorScript   += new RaiseCollectorCalledDelegate(monitorPack_RunCollectorCorrectiveErrorScript);
         monitorPack.PollingFreq      = Properties.Settings.Default.PollingFreqSec * 1000;
         monitorPack.ConcurrencyLevel = concurrencyLevel;
         packs.Add(monitorPack);
         monitorPack.StartPolling();
         PCSetMonitorPacksLoaded(packs.Count);
     }
     catch (Exception ex)
     {
         EventLog.WriteEntry(serviceEventSource, string.Format("Error loading/starting MonitorPack '{0}'\r\n{1}", monitorPackPath, ex.Message), EventLogEntryType.Error, 11);
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: utobe/QuickMon
        static void Main(string[] args)
        {
            if (Properties.Settings.Default.NewVersion)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.NewVersion = false;
                Properties.Settings.Default.Save();
            }

            MonitorPack monitorPack = new MonitorPack();

            if (args.Length > 0 && args[0].ToLower().EndsWith(".qmconfig"))
            {
                if (File.Exists(args[0]))
                {
                    monitorPack.Load(args[0]);
                }
            }
            else
            {
                if (Properties.Settings.Default.LastMonitorPackPath != null && File.Exists(Properties.Settings.Default.LastMonitorPackPath))
                {
                    monitorPack.Load(Properties.Settings.Default.LastMonitorPackPath);
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Management.MonitorPackManagement monitorPackManagement = new Management.MonitorPackManagement();
            if (monitorPackManagement.ShowMonitorPack(monitorPack) == DialogResult.OK)
            {
                Properties.Settings.Default.LastMonitorPackPath = monitorPackManagement.MonitorPackPath;
                Properties.Settings.Default.Save();
            }
        }
コード例 #3
0
ファイル: QuickMonService.cs プロジェクト: utobe/QuickMon
 private void AddAndStartMonitorPack(string monitorPackPath)
 {
     try
     {
         StringBuilder sbNotifiers = new StringBuilder();
         MonitorPack   monitorPack = new MonitorPack();
         EventLog.WriteEntry(Globals.ServiceEventSourceName, string.Format("Starting QuickMon MonitorPack '{0}'", monitorPackPath), EventLogEntryType.Information, (int)QuickMonServiceEventIDs.MonitorPack);
         monitorPack.Load(monitorPackPath);
         monitorPack.ApplicationUserNameCacheMasterKey = Properties.Settings.Default.ApplicationMasterKey;
         monitorPack.ApplicationUserNameCacheFilePath  = Properties.Settings.Default.ApplicationUserNameCacheFilePath;
         monitorPack.CollectorStateHistorySize         = 0; //For service history is always disabled!!
         if (monitorPack.NotifierHosts != null && monitorPack.NotifierHosts.Count > 0)
         {
             foreach (var notifier in monitorPack.NotifierHosts)
             {
                 sbNotifiers.AppendLine("\t" + notifier.Name);
             }
         }
         EventLog.WriteEntry(Globals.ServiceEventSourceName, string.Format("MonitorPack '{0}' has the following notifiers\r\n{1}", monitorPack.Name, sbNotifiers.ToString()), EventLogEntryType.Information, (int)QuickMonServiceEventIDs.MonitorPack);
         monitorPack.OnNotifierError  += new NotifierHostWithMessageDelegate(monitorPack_NotifierError);
         monitorPack.OnCollectorError += new CollectorHostWithMessageDelegate(monitorPack_RaiseCollectorError);
         monitorPack.CollectorHostAllAgentsExecutionTime          += new CollectorHostExecutionTimeDelegate(monitorPack_CollectorHostAllAgentsExecutionTime);
         monitorPack.CollectorHostRestorationScriptExecuted       += MonitorPack_CollectorHostRestorationScriptExecuted;
         monitorPack.CollectorHostRestorationScriptFailed         += MonitorPack_CollectorHostRestorationScriptFailed;
         monitorPack.CollectorHostWarningCorrectiveScriptExecuted += MonitorPack_CollectorHostWarningCorrectiveScriptExecuted;
         monitorPack.CollectorHostWarningCorrectiveScriptFailed   += MonitorPack_CollectorHostWarningCorrectiveScriptFailed;
         monitorPack.CollectorHostErrorCorrectiveScriptExecuted   += MonitorPack_CollectorHostErrorCorrectiveScriptExecuted;
         monitorPack.CollectorHostErrorCorrectiveScriptFailed     += MonitorPack_CollectorHostErrorCorrectiveScriptFailed;
         monitorPack.MonitorPackEventReported += monitorPack_MonitorPackEventReported;
         monitorPack.PollingFreq      = Properties.Settings.Default.PollingFreqSec * 1000;
         monitorPack.ConcurrencyLevel = concurrencyLevel;
         monitorPack.RunningAttended  = AttendedOption.OnlyUnAttended;
         packs.Add(monitorPack);
         monitorPack.StartPolling();
         PCSetMonitorPacksLoaded(packs.Count);
     }
     catch (Exception ex)
     {
         EventLog.WriteEntry(Globals.ServiceEventSourceName, string.Format("Error loading/starting MonitorPack '{0}'\r\n{1}", monitorPackPath, ex.Message), EventLogEntryType.Error, (int)QuickMonServiceEventIDs.MonitorPack);
     }
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: utobe/QuickMon
        private void LoadMonitorPack(string monitorPackPath)
        {
            if (System.IO.File.Exists(monitorPackPath))
            {
                mainRefreshTimer.Enabled = false;
                try
                {
                    monitorPack.RaiseCurrentState           -= new RaiseCurrentStateDelegate(monitorPack_RaiseCurrentState);
                    monitorPack.RaiseNotifierError          -= new RaiseNotifierErrorDelegare(monitorPack_RaiseNotifierError);
                    monitorPack.CollectorCalled             -= new RaiseCollectorCalledDelegate(monitorPack_CollectorCalled);
                    monitorPack.CollectorExecutionTimeEvent -= new CollectorExecutionTimeDelegate(monitorPack_CollectorExecutionTimeEvent);
                    monitorPack.ClosePerformanceCounters();
                    monitorPack = null;
                }
                catch { }
                TreeNode root = tvwCollectors.Nodes[0];
                root.Nodes.Clear();
                monitorPack = new MonitorPack();
                monitorPack.Load(monitorPackPath);
                monitorPack.ConcurrencyLevel = Properties.Settings.Default.ConcurrencyLevel;
                if (monitorPack.AgentLoadingErrors != null && monitorPack.AgentLoadingErrors.Length > 0)
                {
                    MessageBox.Show(monitorPack.AgentLoadingErrors, "Loading errors", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                SetEnableDisablePolling();

                List <CollectorEntry> noDependantCollectors = (from c in monitorPack.Collectors
                                                               where c.ParentCollectorId.Length == 0
                                                               select c).ToList();
                foreach (CollectorEntry collector in noDependantCollectors)
                {
                    LoadCollectorNode(root, collector);
                }
                root.Expand();

                monitorPack.RaiseCurrentState                   += new RaiseCurrentStateDelegate(monitorPack_RaiseCurrentState);
                monitorPack.RaiseNotifierError                  += new RaiseNotifierErrorDelegare(monitorPack_RaiseNotifierError);
                monitorPack.CollectorCalled                     += new RaiseCollectorCalledDelegate(monitorPack_CollectorCalled);
                monitorPack.CollectorExecutionTimeEvent         += new CollectorExecutionTimeDelegate(monitorPack_CollectorExecutionTimeEvent);
                monitorPack.RunCollectorCorrectiveWarningScript += new RaiseCollectorCalledDelegate(monitorPack_RunCollectorCorrectiveWarningScript);
                monitorPack.RunCollectorCorrectiveErrorScript   += new RaiseCollectorCalledDelegate(monitorPack_RunCollectorCorrectiveErrorScript);
                monitorPack.MonitorPackPathChanged              += new MonitorPackPathChangedDelegate(monitorPack_MonitorPackPathChanged);
                globalState = MonitorStates.NotAvailable;

                UpdateAppTitle();
                try
                {
                    defaultNotifierViewerToolStripMenuItem.Enabled = false;
                    if (monitorPack != null)
                    {
                        toolStripStatusLabelStatus.Text = string.Format("{0} collectors, {1} notifiers",
                                                                        monitorPack.Collectors.Count,
                                                                        monitorPack.Notifiers.Count);
                        defaultNotifierViewerToolStripMenuItem.Enabled = monitorPack.DefaultViewerNotifier != null;
                    }
                }
                catch { }
                tvwCollectors.SelectedNode = root;
                root.EnsureVisible();
                AddMonitorPackFileToRecentList(monitorPackPath);
                mainRefreshTimer.Enabled = true;
            }
        }
コード例 #5
0
        static void Main(string[] args)
        {
            bool   useBackgroundPolling = false;
            bool   showManagement       = false;
            bool   reportOnlyStates     = true;
            string currentPath          = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            string registeredAgentsPath               = currentPath;// +@"\RegisteredAgents.qmral";
            string pingAgentAssembly                  = currentPath + @"\QMPing.dll";
            string fileCountAgentAssembly             = currentPath + @"\QMFileCount.dll";
            string serviceStateAgentAssembly          = currentPath + @"\QMServiceState.dll";
            string bizTalkSuspendedCountAgentAssembly = currentPath + @"\QMBizTalkSuspendedCount.dll";
            string logFileAgentAssembly               = currentPath + @"\QMLogFile.dll";
            string configurationFile                  = currentPath + @"\workConfig.qmconfig";

            MonitorPack monitorPack = new MonitorPack();

            #region Agent registrations
            try
            {
                monitorPack.AgentsAssemblyPath = registeredAgentsPath;
            }
            catch
            {
                monitorPack.AgentRegistrations = new List <AgentRegistration>();
                monitorPack.AgentRegistrations.AddRange(new AgentRegistration[]
                {
                    new AgentRegistration()
                    {
                        Name         = "Ping",
                        AssemblyPath = pingAgentAssembly,
                        ClassName    = "QuickMon.Ping",
                        IsCollector  = true,
                        IsNotifier   = false
                    },
                    new AgentRegistration()
                    {
                        Name         = "FileCount",
                        AssemblyPath = fileCountAgentAssembly,
                        ClassName    = "QuickMon.FileCount",
                        IsCollector  = true,
                        IsNotifier   = false
                    },
                    new AgentRegistration()
                    {
                        Name         = "ServiceState",
                        AssemblyPath = serviceStateAgentAssembly,
                        ClassName    = "QuickMon.ServiceState",
                        IsCollector  = true,
                        IsNotifier   = false
                    },
                    new AgentRegistration()
                    {
                        Name         = "BizTalkSuspendedCount",
                        AssemblyPath = bizTalkSuspendedCountAgentAssembly,
                        ClassName    = "QuickMon.BizTalkSuspendedCount",
                        IsCollector  = true,
                        IsNotifier   = false
                    },
                    new AgentRegistration()
                    {
                        Name         = "LogFile",
                        AssemblyPath = logFileAgentAssembly,
                        ClassName    = "QuickMon.LogFile",
                        IsCollector  = false,
                        IsNotifier   = true
                    }
                }
                                                        );
                //SerializationUtils.SerializeXMLToFile<List<AgentRegistration>>(registeredAgentsFile, monitorPack.AgentRegistrations);
            }
            #endregion


            monitorPack.Load(configurationFile);

            if (useBackgroundPolling)
            {
                //monitorPack.RaiseAlert += new RaiseAlertDelegate(monitorPack_RaiseAlert);
                monitorPack.PollingFreq = 10000;
                monitorPack.StartPolling();
                Console.WriteLine("Press any key to stop polling");
                Console.ReadKey();
                monitorPack.IsPolling = false;
                Console.WriteLine("Done");
            }
            else if (showManagement)
            {
                Management.MonitorPackManagement monitorPackManagement = new Management.MonitorPackManagement();
                monitorPackManagement.ShowMonitorPack(monitorPack);
            }
            else if (reportOnlyStates)
            {
                ConsoleKeyInfo cki = new ConsoleKeyInfo(' ', ConsoleKey.Spacebar, false, false, false);
                monitorPack.RaiseCurrentState += new RaiseCurrentStateDelegate(monitorPack_RaiseCurrentState);
                while (cki.Key != ConsoleKey.Escape)
                {
                    Console.WriteLine(new string('-', 79));
                    MonitorStates globalState = monitorPack.RefreshStates();
                    Console.WriteLine("Global state: {0}", globalState);
                    Console.WriteLine("Last time: {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    Console.WriteLine(new string('-', 79));
                    Console.WriteLine("Press ESC to end");
                    cki = ConsoleHelper.ReadKeyWithTimeOut(20000);
                }
            }
            else
            {
                //monitorPack.RaiseAlert += new RaiseAlertDelegate(monitorPack_RaiseAlert);
                MonitorStates globalState = monitorPack.RefreshStates();
                Console.WriteLine(new string('-', 79));
                Console.WriteLine(string.Format("Current global state: {0}", globalState));
                string level = "  ";
                foreach (CollectorEntry ce in (from c in monitorPack.Collectors
                                               where c.ParentCollectorId.Length == 0
                                               select c))
                {
                    ShowCollectorEntryStatus(monitorPack.Collectors, ce, level);
                }
                Console.WriteLine("Press any key to continue or wait 30 seconds");
                ConsoleKeyInfo cki = ConsoleHelper.ReadKeyWithTimeOut(30000);
                if (cki.Key == ConsoleKey.S)
                {
                    monitorPack.Save(currentPath + @"\Test.qmconfig");
                }
            }
        }
コード例 #6
0
ファイル: MonitorUnitTests.cs プロジェクト: utobe/QuickMon
        public void SaveAndLoadBlankMonitorPack()
        {
            MonitorPack m       = new MonitorPack();
            string      mconfig = "<monitorPack version=\"4.0.0\" name=\"Test\" typeName=\"TestType\" enabled=\"True\" " +
                                  "defaultNotifier=\"In Memory\" runCorrectiveScripts=\"True\" " +
                                  "stateHistorySize=\"101\" pollingFreqSecOverride=\"12\">\r\n" +
                                  "<configVars />" +
                                  "<collectorHosts />" +
                                  "<notifierHosts />" +
                                  "</monitorPack>";

            m.LoadXml(mconfig);
            Assert.IsNotNull(m, "Monitor pack is null");
            if (m != null)
            {
                string outputFileName = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "QuickMon4SaveTest.qmp");
                if (System.IO.File.Exists(outputFileName))
                {
                    System.IO.File.Delete(outputFileName);
                }
                m.Save(outputFileName);
                Assert.AreEqual("Test", m.Name, "Name is not set");
                Assert.AreEqual(true, System.IO.File.Exists(outputFileName));
                Assert.AreEqual("4.0.0", m.Version, "Version is not set");
                Assert.AreEqual("TestType", m.TypeName, "Type is not set");
                Assert.AreEqual(true, m.Enabled, "Enabled is not set");
                Assert.AreEqual(true, m.RunCorrectiveScripts, "runCorrectiveScripts is not set");
                Assert.AreEqual(101, m.CollectorStateHistorySize, string.Format("CollectorStateHistorySize is not set: {0}", m.CollectorStateHistorySize));
                Assert.AreEqual(12, m.PollingFrequencyOverrideSec, string.Format("PollingFrequencyOverrideSec is not set: {0}", m.PollingFrequencyOverrideSec));
                Assert.IsNotNull(m.ConfigVariables, "ConfigVariables is null");
                if (m.ConfigVariables != null)
                {
                    Assert.AreEqual(0, m.ConfigVariables.Count, "ConfigVariables count should be 0");
                }
                Assert.IsNotNull(m.CollectorHosts, "CollectorHosts is null");
                if (m.CollectorHosts != null)
                {
                    Assert.AreEqual(0, m.CollectorHosts.Count, "CollectorHosts count should be 0");
                }
                Assert.IsNotNull(m.NotifierHosts, "NotifierHosts is null");
                if (m.NotifierHosts != null)
                {
                    Assert.AreEqual(0, m.NotifierHosts.Count, "NotifierHosts count should be 0");
                }

                m.Name = "Deliberately change name";
                m.Load(outputFileName);
                Assert.AreEqual("Test", m.Name, "Name is not set (2nd test)");
                Assert.AreEqual(true, System.IO.File.Exists(outputFileName));
                //Assert.AreEqual("4.0.0.0", m.Version, "Version is not set (2nd test)");
                Assert.AreEqual("TestType", m.TypeName, "Type is not set (2nd test)");
                Assert.AreEqual(true, m.Enabled, "Enabled is not set (2nd test)");
                Assert.AreEqual(true, m.RunCorrectiveScripts, "runCorrectiveScripts is not set (2nd test)");
                Assert.AreEqual(101, m.CollectorStateHistorySize, string.Format("CollectorStateHistorySize is not set: {0} (2nd test)", m.CollectorStateHistorySize));
                Assert.AreEqual(12, m.PollingFrequencyOverrideSec, string.Format("PollingFrequencyOverrideSec is not set: {0} (2nd test)", m.PollingFrequencyOverrideSec));
                Assert.IsNotNull(m.ConfigVariables, "ConfigVariables is null (2nd test)");
                if (m.ConfigVariables != null)
                {
                    Assert.AreEqual(0, m.ConfigVariables.Count, "ConfigVariables count should be 0 (2nd test)");
                }
                Assert.IsNotNull(m.CollectorHosts, "CollectorHosts is null (2nd test)");
                if (m.CollectorHosts != null)
                {
                    Assert.AreEqual(0, m.CollectorHosts.Count, "CollectorHosts count should be 0 (2nd test)");
                }
                Assert.IsNotNull(m.NotifierHosts, "NotifierHosts is null (2nd test)");
                if (m.NotifierHosts != null)
                {
                    Assert.AreEqual(0, m.NotifierHosts.Count, "NotifierHosts count should be 0 (2nd test)");
                }
            }
        }
コード例 #7
0
ファイル: MonitorUnitTests.cs プロジェクト: utobe/QuickMon
        public void LoadPingCollectorTest()
        {
            string mconfig = "<monitorPack version=\"4.0.0\" name=\"Test\" typeName=\"TestType\" enabled=\"True\" " +
                             "defaultNotifier=\"Default notifiers\" runCorrectiveScripts=\"True\" " +
                             "stateHistorySize=\"100\" pollingFreqSecOverride=\"12\">\r\n" +
                             "<configVars />\r\n" +
                             "<collectorHosts>\r\n" +
                             "<collectorHost uniqueId=\"123\" name=\"Ping test\" enabled=\"True\" expandOnStart=\"True\" dependOnParentId=\"\" " +
                             "agentCheckSequence=\"All\" childCheckBehaviour=\"OnlyRunOnSuccess\" " +
                             "repeatAlertInXMin=\"0\" alertOnceInXMin=\"0\" delayErrWarnAlertForXSec=\"0\" " +
                             "repeatAlertInXPolls=\"0\" alertOnceInXPolls=\"0\" delayErrWarnAlertForXPolls=\"0\" " +
                             "correctiveScriptDisabled=\"False\" correctiveScriptOnWarningPath=\"\" correctiveScriptOnErrorPath=\"\" " +
                             "restorationScriptPath=\"\" correctiveScriptsOnlyOnStateChange=\"True\" enableRemoteExecute=\"False\" " +
                             "forceRemoteExcuteOnChildCollectors=\"True\" remoteAgentHostAddress=\"\" remoteAgentHostPort=\"48181\" " +
                             "blockParentRemoteAgentHostSettings=\"False\" runLocalOnRemoteHostConnectionFailure=\"False\" " +
                             "enabledPollingOverride=\"False\" onlyAllowUpdateOncePerXSec=\"1\" enablePollFrequencySliding=\"False\" " +
                             "pollSlideFrequencyAfterFirstRepeatSec=\"2\" pollSlideFrequencyAfterSecondRepeatSec=\"5\" " +
                             "pollSlideFrequencyAfterThirdRepeatSec=\"30\">\r\n" +
                             "<collectorAgents>\r\n" +
                             "<collectorAgent type=\"PingCollector\">\r\n" +
                             "<config>\r\n" +
                             "<entries>\r\n" +
                             "<entry pingMethod=\"Ping\" address=\"localhost\" />\r\n" +
                             "</entries>\r\n" +
                             "</config>\r\n" +
                             "</collectorAgent>\r\n" +
                             "</collectorAgents>\r\n" +
                             "</collectorHost>\r\n" +
                             "</collectorHosts>\r\n" +
                             "<notifierHosts>\r\n" +
                             "<notifierHost name=\"Default notifiers\" enabled=\"True\" alertLevel=\"Warning\" detailLevel=\"Detail\" " +
                             "attendedOptionOverride=\"OnlyAttended\">\r\n" +
                             "<notifierAgents>\r\n" +
                             "<notifierAgent type=\"InMemoryNotifier\">\r\n" +
                             "<config><inMemory maxEntryCount=\"99999\" /></config>\r\n" +
                             "</notifierAgent>\r\n" +
                             "</notifierAgents>\r\n" +
                             "</notifierHost>\r\n" +
                             "</notifierHosts>\r\n" +
                             "</monitorPack>";
            MonitorPack m = new MonitorPack();

            m.LoadXml(mconfig);
            Assert.IsNotNull(m, "Monitor pack is null");
            if (m != null)
            {
                string outputFileName = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "QuickMon4SaveTest.qmp");
                if (System.IO.File.Exists(outputFileName))
                {
                    System.IO.File.Delete(outputFileName);
                }
                m.Save(outputFileName);
                m.Load(outputFileName);

                Assert.AreEqual(1, m.CollectorHosts.Count, "1 Collector host is expected");
                if (m.CollectorHosts.Count == 1)
                {
                    Assert.AreEqual(1, m.CollectorHosts[0].CollectorAgents.Count, "1 Collector agent is expected");
                    Assert.AreEqual(m.CollectorHosts[0].CollectorAgents[0].InitialConfiguration, m.CollectorHosts[0].CollectorAgents[0].ActiveConfiguration, "Initial and active config should match");
                }
            }
        }
コード例 #8
0
ファイル: MonitorUnitTests.cs プロジェクト: utobe/QuickMon
        public void LoadBlankCollectorHost()
        {
            string mconfig = "<monitorPack version=\"4.0.0\" name=\"Test\" typeName=\"TestType\" enabled=\"True\" " +
                             "defaultNotifier=\"In Memory\" runCorrectiveScripts=\"True\" " +
                             "stateHistorySize=\"100\" pollingFreqSecOverride=\"12\">\r\n" +
                             "<configVars />\r\n" +
                             "<collectorHosts>\r\n" +
                             "<collectorHost uniqueId=\"123\" name=\"Test name\" enabled=\"True\" expandOnStart=\"Auto\" dependOnParentId=\"\" " +
                             "agentCheckSequence=\"All\" childCheckBehaviour=\"OnlyRunOnSuccess\" " +
                             "repeatAlertInXMin=\"1\" alertOnceInXMin=\"1\" delayErrWarnAlertForXSec=\"1\" " +
                             "repeatAlertInXPolls=\"1\" alertOnceInXPolls=\"1\" delayErrWarnAlertForXPolls=\"1\" " +
                             "correctiveScriptDisabled=\"True\" correctiveScriptOnWarningPath=\"test\" correctiveScriptOnErrorPath=\"test\" " +
                             "restorationScriptPath=\"test\" correctiveScriptsOnlyOnStateChange=\"True\" enableRemoteExecute=\"True\" " +
                             "forceRemoteExcuteOnChildCollectors=\"True\" remoteAgentHostAddress=\"test\" remoteAgentHostPort=\"48182\" " +
                             "blockParentRemoteAgentHostSettings=\"True\" runLocalOnRemoteHostConnectionFailure=\"True\" " +
                             "enabledPollingOverride=\"True\" onlyAllowUpdateOncePerXSec=\"2\" enablePollFrequencySliding=\"True\" " +
                             "pollSlideFrequencyAfterFirstRepeatSec=\"3\" pollSlideFrequencyAfterSecondRepeatSec=\"6\" " +
                             "pollSlideFrequencyAfterThirdRepeatSec=\"31\">\r\n" +
                             "</collectorHost>\r\n" +
                             "</collectorHosts>\r\n" +
                             "<notifierHosts />\r\n" +
                             "</monitorPack>";

            MonitorPack m = new MonitorPack();

            m.LoadXml(mconfig);
            Assert.IsNotNull(m, "Monitor pack is null");
            if (m != null)
            {
                Assert.AreEqual(1, m.CollectorHosts.Count, "1 Collector host is expected");
                if (m.CollectorHosts.Count == 1)
                {
                    Assert.AreEqual("Test name", m.CollectorHosts[0].Name, "Collector host name not set");
                    Assert.AreEqual("123", m.CollectorHosts[0].UniqueId, "Collector host UniqueId not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].Enabled, "Collector host Enabled property not set");
                    Assert.AreEqual(ExpandOnStartOption.Auto, m.CollectorHosts[0].ExpandOnStartOption, "Collector host ExpandOnStart property not set");
                    Assert.AreEqual("", m.CollectorHosts[0].ParentCollectorId, "Collector host ParentCollectorId property not set");
                    Assert.AreEqual(AgentCheckSequence.All, m.CollectorHosts[0].AgentCheckSequence, "Collector host AgentCheckSequence property not set");
                    Assert.AreEqual(ChildCheckBehaviour.OnlyRunOnSuccess, m.CollectorHosts[0].ChildCheckBehaviour, "Collector host ChildCheckBehaviour property not set");
                    Assert.AreEqual(1, m.CollectorHosts[0].RepeatAlertInXMin, "Collector host RepeatAlertInXMin property not set");
                    Assert.AreEqual(1, m.CollectorHosts[0].AlertOnceInXMin, "Collector host AlertOnceInXMin property not set");
                    Assert.AreEqual(1, m.CollectorHosts[0].DelayErrWarnAlertForXSec, "Collector host DelayErrWarnAlertForXSec property not set");
                    Assert.AreEqual(1, m.CollectorHosts[0].RepeatAlertInXPolls, "Collector host RepeatAlertInXPolls property not set");
                    Assert.AreEqual(1, m.CollectorHosts[0].AlertOnceInXPolls, "Collector host AlertOnceInXPolls property not set");
                    Assert.AreEqual(1, m.CollectorHosts[0].DelayErrWarnAlertForXPolls, "Collector host DelayErrWarnAlertForXPolls property not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].CorrectiveScriptDisabled, "Collector host CorrectiveScriptDisabled property not set");
                    Assert.AreEqual("test", m.CollectorHosts[0].CorrectiveScriptOnWarningPath, "Collector host CorrectiveScriptOnWarningPath property not set");
                    Assert.AreEqual("test", m.CollectorHosts[0].CorrectiveScriptOnErrorPath, "Collector host CorrectiveScriptOnErrorPath property not set");
                    Assert.AreEqual("test", m.CollectorHosts[0].RestorationScriptPath, "Collector host RestorationScriptPath property not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].CorrectiveScriptsOnlyOnStateChange, "Collector host CorrectiveScriptsOnlyOnStateChange property not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].EnableRemoteExecute, "Collector host EnableRemoteExecute property not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].ForceRemoteExcuteOnChildCollectors, "Collector host ForceRemoteExcuteOnChildCollectors property not set");
                    Assert.AreEqual("test", m.CollectorHosts[0].RemoteAgentHostAddress, "Collector host RemoteAgentHostAddress property not set");
                    Assert.AreEqual(48182, m.CollectorHosts[0].RemoteAgentHostPort, "Collector host RemoteAgentHostPort property not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].BlockParentOverrideRemoteAgentHostSettings, "Collector host BlockParentOverrideRemoteAgentHostSettings property not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].RunLocalOnRemoteHostConnectionFailure, "Collector host RunLocalOnRemoteHostConnectionFailure property not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].EnabledPollingOverride, "Collector host EnabledPollingOverride property not set");
                    Assert.AreEqual(2, m.CollectorHosts[0].OnlyAllowUpdateOncePerXSec, "Collector host OnlyAllowUpdateOncePerXSec property not set");
                    Assert.AreEqual(true, m.CollectorHosts[0].EnablePollFrequencySliding, "Collector host EnablePollFrequencySliding property not set");
                    Assert.AreEqual(3, m.CollectorHosts[0].PollSlideFrequencyAfterFirstRepeatSec, "Collector host PollSlideFrequencyAfterFirstRepeatSec property not set");
                    Assert.AreEqual(6, m.CollectorHosts[0].PollSlideFrequencyAfterSecondRepeatSec, "Collector host PollSlideFrequencyAfterSecondRepeatSec property not set");
                    Assert.AreEqual(31, m.CollectorHosts[0].PollSlideFrequencyAfterThirdRepeatSec, "Collector host PollSlideFrequencyAfterThirdRepeatSec property not set");

                    string outputFileName = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "QuickMon4SaveTest.qmp");
                    if (System.IO.File.Exists(outputFileName))
                    {
                        System.IO.File.Delete(outputFileName);
                    }
                    m.Save(outputFileName);
                    Assert.AreEqual(true, System.IO.File.Exists(outputFileName));

                    m.Load(outputFileName);
                    Assert.AreEqual(1, m.CollectorHosts.Count, "1 Collector host is expected (2nd test)");
                    if (m.CollectorHosts.Count == 1)
                    {
                        Assert.AreEqual("Test name", m.CollectorHosts[0].Name, "Collector host name not set (2nd test)");
                        Assert.AreEqual("123", m.CollectorHosts[0].UniqueId, "Collector host UniqueId not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].Enabled, "Collector host Enabled property not set (2nd test)");
                        Assert.AreEqual(ExpandOnStartOption.Auto, m.CollectorHosts[0].ExpandOnStartOption, "Collector host ExpandOnStart property not set (2nd test)");
                        Assert.AreEqual("", m.CollectorHosts[0].ParentCollectorId, "Collector host ParentCollectorId property not set (2nd test)");
                        Assert.AreEqual(AgentCheckSequence.All, m.CollectorHosts[0].AgentCheckSequence, "Collector host AgentCheckSequence property not set (2nd test)");
                        Assert.AreEqual(ChildCheckBehaviour.OnlyRunOnSuccess, m.CollectorHosts[0].ChildCheckBehaviour, "Collector host ChildCheckBehaviour property not set (2nd test)");
                        Assert.AreEqual(1, m.CollectorHosts[0].RepeatAlertInXMin, "Collector host RepeatAlertInXMin property not set (2nd test)");
                        Assert.AreEqual(1, m.CollectorHosts[0].AlertOnceInXMin, "Collector host AlertOnceInXMin property not set (2nd test)");
                        Assert.AreEqual(1, m.CollectorHosts[0].DelayErrWarnAlertForXSec, "Collector host DelayErrWarnAlertForXSec property not set (2nd test)");
                        Assert.AreEqual(1, m.CollectorHosts[0].RepeatAlertInXPolls, "Collector host RepeatAlertInXPolls property not set (2nd test)");
                        Assert.AreEqual(1, m.CollectorHosts[0].AlertOnceInXPolls, "Collector host AlertOnceInXPolls property not set (2nd test)");
                        Assert.AreEqual(1, m.CollectorHosts[0].DelayErrWarnAlertForXPolls, "Collector host DelayErrWarnAlertForXPolls property not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].CorrectiveScriptDisabled, "Collector host CorrectiveScriptDisabled property not set (2nd test)");
                        Assert.AreEqual("test", m.CollectorHosts[0].CorrectiveScriptOnWarningPath, "Collector host CorrectiveScriptOnWarningPath property not set (2nd test)");
                        Assert.AreEqual("test", m.CollectorHosts[0].CorrectiveScriptOnErrorPath, "Collector host CorrectiveScriptOnErrorPath property not set (2nd test)");
                        Assert.AreEqual("test", m.CollectorHosts[0].RestorationScriptPath, "Collector host RestorationScriptPath property not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].CorrectiveScriptsOnlyOnStateChange, "Collector host CorrectiveScriptsOnlyOnStateChange property not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].EnableRemoteExecute, "Collector host EnableRemoteExecute property not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].ForceRemoteExcuteOnChildCollectors, "Collector host ForceRemoteExcuteOnChildCollectors property not set (2nd test)");
                        Assert.AreEqual("test", m.CollectorHosts[0].RemoteAgentHostAddress, "Collector host RemoteAgentHostAddress property not set (2nd test)");
                        Assert.AreEqual(48182, m.CollectorHosts[0].RemoteAgentHostPort, "Collector host RemoteAgentHostPort property not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].BlockParentOverrideRemoteAgentHostSettings, "Collector host BlockParentOverrideRemoteAgentHostSettings property not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].RunLocalOnRemoteHostConnectionFailure, "Collector host RunLocalOnRemoteHostConnectionFailure property not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].EnabledPollingOverride, "Collector host EnabledPollingOverride property not set (2nd test)");
                        Assert.AreEqual(2, m.CollectorHosts[0].OnlyAllowUpdateOncePerXSec, "Collector host OnlyAllowUpdateOncePerXSec property not set (2nd test)");
                        Assert.AreEqual(true, m.CollectorHosts[0].EnablePollFrequencySliding, "Collector host EnablePollFrequencySliding property not set (2nd test)");
                        Assert.AreEqual(3, m.CollectorHosts[0].PollSlideFrequencyAfterFirstRepeatSec, "Collector host PollSlideFrequencyAfterFirstRepeatSec property not set (2nd test)");
                        Assert.AreEqual(6, m.CollectorHosts[0].PollSlideFrequencyAfterSecondRepeatSec, "Collector host PollSlideFrequencyAfterSecondRepeatSec property not set (2nd test)");
                        Assert.AreEqual(31, m.CollectorHosts[0].PollSlideFrequencyAfterThirdRepeatSec, "Collector host PollSlideFrequencyAfterThirdRepeatSec property not set (2nd test)");
                    }
                }
            }
        }