Beispiel #1
0
 private void monitorPacksToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (lvwRemoteHosts.SelectedItems.Count > 0)
     {
         StringBuilder sb        = new StringBuilder();
         bool          anyErrors = false;
         foreach (ListViewItem lvi in lvwRemoteHosts.SelectedItems)
         {
             RemoteAgentInfo ri = (RemoteAgentInfo)lvi.Tag;
             try
             {
                 int packCount = 0;
                 sb.AppendFormat("***{0}:{1}***\r\n", ri.Computer.ToUpper(), ri.PortNumber);
                 foreach (string mpFile in RemoteCollectorHostService.GetCurrentMonitorPacks(ri.Computer, ri.PortNumber))
                 {
                     sb.AppendLine("  " + mpFile.Replace(' ', ' ').TrimEnd());
                     packCount++;
                 }
                 if (packCount == 0)
                 {
                     sb.AppendLine("  No Monitor packs found.");
                 }
             }
             catch (Exception ex)
             {
                 anyErrors = true;
                 if (ex.Message.Contains("ContractFilter mismatch"))
                 {
                     sb.AppendFormat("  The service on {0}:{1} does not yet support this functionality.\r\n  Please check the version number!\r\n", ri.Computer, ri.PortNumber);
                 }
                 else
                 {
                     sb.AppendLine("  " + ex.Message);
                 }
             }
         }
         MessageBox.Show(sb.ToString(), "Monitor packs", MessageBoxButtons.OK, anyErrors ? MessageBoxIcon.Warning : MessageBoxIcon.Information);
     }
 }
Beispiel #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());
            }
        }