예제 #1
0
 private void lblComputer_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         if (txtComputer.Text.Length > 0)
         {
             string versionInfo = RemoteCollectorHostService.GetRemoteAgentHostVersion(txtComputer.Text, (int)remoteportNumericUpDown.Value);
             MessageBox.Show("Version Info: " + versionInfo, "Version", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Version", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        private void RefreshItem(object o)
        {
            ListViewItem lvi = (ListViewItem)o;

            try
            {
                try
                {
                    bool            hostExists = false;
                    RemoteAgentInfo ri         = (RemoteAgentInfo)lvi.Tag;
                    string          configXml  = "<collectorHost uniqueId=\"Ping" + ri.Computer.EscapeXml() + "\" name=\"Ping " + ri.Computer.EscapeXml() + " tests\" enabled=\"True\" expandOnStart=\"True\" dependOnParentId=\"\" " +
                                                 "agentCheckSequence=\"All\" childCheckBehaviour=\"OnlyRunOnSuccess\" " +
                                                 "enableRemoteExecute=\"True\" " +
                                                 "forceRemoteExcuteOnChildCollectors=\"False\" remoteAgentHostAddress=\"" + ri.Computer.EscapeXml() + "\" remoteAgentHostPort=\"48191\" " +
                                                 "blockParentRemoteAgentHostSettings=\"False\" runLocalOnRemoteHostConnectionFailure=\"True\" >\r\n" +
                                                 "<collectorAgents>\r\n" +
                                                 "<collectorAgent type=\"PingCollector\">\r\n" +
                                                 "<config>\r\n" +
                                                 "<entries>\r\n" +
                                                 "<entry pingMethod=\"Ping\" address=\"" + ri.Computer.EscapeXml() + "\" />\r\n" +
                                                 "</entries>\r\n" +
                                                 "</config>\r\n" +
                                                 "</collectorAgent>\r\n" +
                                                 "</collectorAgents>\r\n" +
                                                 "</collectorHost>\r\n";
                    CollectorHost ce = CollectorHost.FromXml(configXml);

                    ce.EnableRemoteExecute    = true;
                    ce.RemoteAgentHostAddress = ri.Computer;
                    ce.RemoteAgentHostPort    = ri.PortNumber;
                    try
                    {
                        hostExists = System.Net.Dns.GetHostAddresses(ri.Computer).Count() != 0;
                    }
                    catch { }
                    if (!hostExists)
                    {
                        UpdateListViewItem(lvi, 4, "", "Host not found");
                    }
                    else if (!CanPingHost(ri.Computer))
                    {
                        UpdateListViewItem(lvi, 4, "", "Host not pingable");
                    }
                    else
                    {
                        MonitorState testState = RemoteCollectorHostService.GetCollectorHostState(ce);
                        if (testState.State == CollectorState.Good)
                        {
                            try
                            {
                                string versionInfo = RemoteCollectorHostService.GetRemoteAgentHostVersion(ri.Computer, ri.PortNumber);
                                string packs       = "0";

                                //Pack count
                                try
                                {
                                    packs = RemoteCollectorHostService.GetCurrentMonitorPacks(ri.Computer, ri.PortNumber).Count().ToString();
                                }
                                catch (Exception packsEx)
                                {
                                    packs = packsEx.Message;
                                    if (packsEx.Message.Contains("ContractFilter mismatch"))
                                    {
                                        packs = "Check version!";
                                    }
                                    else
                                    {
                                        packs = packsEx.Message;
                                    }
                                }

                                UpdateListViewItem(lvi, 1, versionInfo, packs);
                            }
                            catch (Exception ex)
                            {
                                if (ex.Message.Contains("ContractFilter"))
                                {
                                    UpdateListViewItem(lvi, 2, "", "Remote host does not support version info query! Check that QuickMon 4.x or later is installed.");
                                }
                                else
                                {
                                    UpdateListViewItem(lvi, 2, "", ex.Message);
                                }
                            }
                        }
                        else
                        {
                            UpdateListViewItem(lvi, 3, "N/A", "N/A");
                        }
                    }
                }
                catch (Exception delegateEx)
                {
                    if (delegateEx.Message.StartsWith("There was no endpoint listening"))
                    {
                        UpdateListViewItem(lvi, 3, "", "Service not running or inaccessible");
                    }
                    else if (delegateEx.Message.Contains("The formatter threw an exception while trying to deserialize the message"))
                    {
                        UpdateListViewItem(lvi, 3, "", "Old version of Remote agent host does not support query or format does not match! Please update remote agent host version.");
                    }
                    else
                    {
                        UpdateListViewItem(lvi, 3, "", delegateEx.Message);
                    }
                }
            }
            catch (Exception riEx)
            {
                UpdateListViewItem(lvi, 1, "", riEx.ToString());
            }
        }