Example #1
0
        public string ToCollectorHostXml()
        {
            string collectorAgentsXml = CollectorHost.GetRemoteCollectorAgentsConfigXml(Agents, AgentCheckSequence);

            return(CollectorHost.ToXml(UniqueId,
                                       Name,
                                       Enabled,
                                       ChildCheckBehaviour.OnlyRunOnSuccess,
                                       RunAsEnabled,
                                       RunAs,
                                       collectorAgentsXml
                                       ));
        }
Example #2
0
        public void SSHConfigTest()
        {
            string mconfig = "<collectorHost uniqueId=\"SSHTest\" dependOnParentId=\"\" name=\"SSH Test\" enabled=\"True\" expandOnStart=\"Auto\" " +
                             " childCheckBehaviour=\"OnlyRunOnSuccess\" runAsEnabled=\"False\" runAs=\"\">" +
                             "     <collectorAgents agentCheckSequence=\"All\">" +
                             "         <collectorAgent name=\"SSH Test\" type=\"QuickMon.Collectors.SSHCommandCollector\" enabled=\"True\">" +
                             "<config>" +
                             "<carvcesEntries>" +
                             "<carvceEntry>" +
                             "<dataSource name=\"SSH Test\" sshSecOpt=\"password\" machine=\"hostName\" sshPort=\"22\" userName=\"user\" password=\"pwd\" privateKeyFile=\"\" passPhrase=\"\" persistent=\"False\">" +
                             "<stateQuery>grep ^Version= /usr/lib/firefox/application.ini</stateQuery>" +
                             "</dataSource>" +
                             "<testConditions testSequence=\"GWE\">" +
                             "<success testType=\"contains\">Version=53.0</success>" +
                             "<warning testType=\"match\">[any]</warning>" +
                             "<error testType=\"match\">[null]</error>" +
                             "</testConditions>" +
                             "</carvceEntry>" +
                             "</carvcesEntries>" +
                             "</config>" +
                             "         </collectorAgent>" +
                             "     </collectorAgents>" +
                             "   </collectorHost>";

            CollectorHost ch = CollectorHost.FromXml(mconfig);

            Assert.AreEqual("SSH Test", ch.Name, "Collector host name not set");
            Assert.AreEqual(1, ch.CollectorAgents.Count, "1 Collector agent expected");
            Assert.AreEqual("SSH Test", ch.CollectorAgents[0].Name, "Agent name not set");
            Assert.IsInstanceOfType(ch.CollectorAgents[0], typeof(Collectors.SSHCommandCollector));

            Collectors.SSHCommandCollector sshCollector = (Collectors.SSHCommandCollector)ch.CollectorAgents[0];
            Assert.AreEqual(1, ((Collectors.SSHCommandCollectorConfig)sshCollector.AgentConfig).Entries.Count, "1 SSH Command expected");

            Collectors.SSHCommandCollectorConfigEntry sshEntry = (Collectors.SSHCommandCollectorConfigEntry)(((Collectors.SSHCommandCollectorConfig)sshCollector.AgentConfig).Entries[0]);
            Assert.AreEqual("hostName", sshEntry.SSHConnection.ComputerName, "SSH server name not found!");
            Assert.AreEqual("Version=53.0", sshEntry.GoodValue, "Good value does not match");

            string savedConfig = ch.ToXml();

            ch = CollectorHost.FromXml(savedConfig);
            Assert.AreEqual("SSH Test", ch.Name, "Collector host name not set (reload)");
            Assert.AreEqual(1, ch.CollectorAgents.Count, "1 Collector agent expected (reload)");
            Assert.AreEqual("SSH Test", ch.CollectorAgents[0].Name, "Agent name not set (reload)");

            //string testValue = sshEntry.ExecuteCommand();
            //MonitorState testState = ch.RefreshCurrentState();
        }
Example #3
0
        public string ToCollectorHostXml()
        {
            string collectorAgentsXml = CollectorHost.GetRemoteCollectorAgentsConfigXml(Agents, AgentCheckSequence);

            return(CollectorHost.ToXml(UniqueId,
                                       Name,
                                       Enabled,
                                       ChildCheckBehaviour.OnlyRunOnSuccess,
                                       RunAsEnabled,
                                       RunAs,
                                       collectorAgentsXml
                                       ));


            //StringBuilder collectorAgentsXml = new StringBuilder();
            //collectorAgentsXml.AppendLine("<collectorAgents>");
            //foreach (RemoteCollectorAgent c in Agents)
            //{
            //    collectorAgentsXml.AppendLine(c.ToXml());
            //}
            //collectorAgentsXml.AppendLine("</collectorAgents>");

            //return CollectorHost.ToXml(UniqueId,
            //    Name,
            //    Enabled,
            //    ExpandOnStartOption.Auto, //true
            //    "", //No parent
            //    AgentCheckSequence,
            //    ChildCheckBehaviour.OnlyRunOnSuccess,
            //    0, 0, 0, 0, 0, 0, //alert suppression
            //    true, "", "", "", false, //Corrective scripts
            //    false, false, "", 48181, false, false, //Remote hosts
            //    false, 0, false, 0, 0, 0, //Polling overides
            //    false, //alerts paused
            //    RunAsEnabled,
            //    RunAs,
            //    collectorAgentsXml.ToString(),
            //    "", //action scripts
            //    "", //Service windows
            //    "", //config vars
            //    "", //categories (blank for the moment)
            //    "", //Notes,
            //    "", //GeneralAlertText,
            //    "", //ErrorAlertText,
            //    "", //WarningAlertText,
            //    ""  //GoodAlertText
            //    );
        }