コード例 #1
0
 public override void LoadDisplayData()
 {
     if (Collector != null && Collector.AgentConfig != null && ((IISAppPoolCollectorConfig)Collector.AgentConfig).Entries != null)
     {
         IISAppPoolCollectorConfig ssc = (IISAppPoolCollectorConfig)Collector.AgentConfig;
         lvwEntries.Groups.Clear();
         lvwEntries.Items.Clear();
         foreach (IISAppPoolMachine serviceDefinition in (from IISAppPoolMachine s in ssc.Entries
                                                          orderby s.MachineName
                                                          select s))
         {
             ListViewGroup group = new ListViewGroup(serviceDefinition.MachineName);
             group.Tag = serviceDefinition;
             lvwEntries.Groups.Add(group);
             foreach (IISAppPoolEntry serviceEntry in (from s in serviceDefinition.SubItems
                                                       orderby s.Description
                                                       select s))
             {
                 ListViewItem lvi = new ListViewItem(serviceEntry.Description);
                 lvi.Group      = group;
                 lvi.ImageIndex = 0;
                 lvi.Tag        = serviceEntry;
                 lvwEntries.Items.Add(lvi);
             }
         }
     }
 }
コード例 #2
0
ファイル: IISAppPoolCollector.cs プロジェクト: utobe/QuickMon
        public override MonitorState GetState()
        {
            MonitorState  returnState         = new MonitorState();
            StringBuilder plainTextDetails    = new StringBuilder();
            StringBuilder htmlTextTextDetails = new StringBuilder();
            string        lastAction          = "";
            int           errors   = 0;
            int           warnings = 0;
            int           success  = 0;

            try
            {
                IISAppPoolCollectorConfig currentConfig = (IISAppPoolCollectorConfig)AgentConfig;
                foreach (IISAppPoolMachine machineEntry in currentConfig.Entries)
                {
                    lastAction = "Checking application pools on " + machineEntry.MachineName;
                    var appPollStates = machineEntry.GetIISAppPoolStates();
                    lastAction = "Checking application pool states of " + machineEntry.MachineName;
                    CollectorState currentState = machineEntry.GetState(appPollStates);

                    if (currentState == CollectorState.Error)
                    {
                        errors++;
                        plainTextDetails.AppendLine(string.Format("Error: {0}", machineEntry.MachineName));
                        htmlTextTextDetails.AppendLine(string.Format("<b>Error</b>: {0}", machineEntry.MachineName));
                    }
                    else if (currentState == CollectorState.Warning)
                    {
                        warnings++;
                        plainTextDetails.AppendLine(string.Format("Warning: {0}", machineEntry.MachineName));
                        htmlTextTextDetails.AppendLine(string.Format("<i>Warning</i>: {0}", machineEntry.MachineName));
                    }
                    else
                    {
                        success++;
                        plainTextDetails.AppendLine(string.Format("Success: {0}", machineEntry.MachineName));
                        htmlTextTextDetails.AppendLine(string.Format("Success: {0}", machineEntry.MachineName));
                    }
                    foreach (IISAppPoolStateInfo appPollEntry in appPollStates)
                    {
                        plainTextDetails.AppendLine(string.Format("\t{0}: {1}", appPollEntry.DisplayName, appPollEntry.Status));
                        htmlTextTextDetails.AppendLine("<ul>");
                        if (appPollEntry.Status != AppPoolStatus.Started)
                        {
                            htmlTextTextDetails.AppendLine(string.Format("<li>{0}: <b>{1}</b></li>", appPollEntry.DisplayName, appPollEntry.Status));
                        }
                        else
                        {
                            htmlTextTextDetails.AppendLine(string.Format("<li>{0}: {1}</li>", appPollEntry.DisplayName, appPollEntry.Status));
                        }
                        htmlTextTextDetails.AppendLine("</ul>");
                    }
                }
                returnState.RawDetails  = plainTextDetails.ToString().TrimEnd('\r', '\n');
                returnState.HtmlDetails = htmlTextTextDetails.ToString();

                if (errors > 0) // any errors
                {
                    returnState.State = CollectorState.Error;
                }
                else if (warnings > 0) //any warnings
                {
                    returnState.State = CollectorState.Warning;
                }
                else
                {
                    returnState.State = CollectorState.Good;
                }
            }
            catch (Exception ex)
            {
                returnState.RawDetails  = ex.Message;
                returnState.HtmlDetails = string.Format("<p><b>Last action:</b> {0}</p><blockquote>{1}</blockquote>", lastAction, ex.Message);
                returnState.State       = CollectorState.Error;
            }

            return(returnState);
        }
コード例 #3
0
ファイル: IISAppPoolCollector.cs プロジェクト: utobe/QuickMon
 public IISAppPoolCollector()
 {
     AgentConfig = new IISAppPoolCollectorConfig();
 }