Пример #1
0
        //---------------------------------------------------------------------
        private void DisplayAlertDescriptionIfApplicable(ManagementPackElement element)
        {
            if (!(element is ManagementPackMonitor))
            {
                return;
            }

            ManagementPackMonitor monitor = (ManagementPackMonitor)element;

            m_alertDescriptionTextBox.DocumentText = @"<HTML></HTML>";

            if (monitor.AlertSettings != null && monitor.AlertSettings.AlertMessage != null)
            {
                string alertDescription;

                alertDescription = m_managementPack.GetStringResource(monitor.AlertSettings.AlertMessage.Name).Description;

                if (alertDescription == null)
                {
                    return;
                }

                if (alertDescription.IndexOf("\r\n") == 0)
                {
                    alertDescription = alertDescription.Remove(0, 2);
                    alertDescription = alertDescription.TrimStart(new char[] { ' ' });
                }

                m_alertDescriptionTextBox.DocumentText = string.Format(@"<HTML><BODY>{0}</BODY></HTML>", alertDescription);
            }
        }
        /// <summary>
        /// Using the static ManagementGroupConnector this method pulls the monitoring state
        /// for the Community Pack Update Monitor
        /// </summary>
        /// <returns>The <see cref="MonitoringState"/> object that represents the Community Pack Update Monitor.</returns>
        private MonitoringState GetPackUpdateMonitorState()
        {
            // Filter to the Root Management Server Emulator role, there is only one instance of this class so the criteria can be simple.
            ManagementPackClass              rootManagementServerClass = ManagementGroupConnector.CurrentManagementGroup.EntityTypes.GetClass(Guid.Parse("1a9387f0-6fe5-5527-a2cb-73f2f6be6bc7"));
            MonitoringObjectGenericCriteria  monitoringObjectCriteria  = new MonitoringObjectGenericCriteria("FullName like 'Microsoft.SystemCenter%'");
            IObjectReader <MonitoringObject> monitoringObjects         = ManagementGroupConnector.CurrentManagementGroup.EntityObjects.GetObjectReader <MonitoringObject>(monitoringObjectCriteria, rootManagementServerClass, ObjectQueryOptions.Default);
            MonitoringObject rootManagementServerInstance = monitoringObjects.GetData(0);

            // For the instance of the Root Management Server Emulator we need to cross that with the Monitor to get the exact monitoring state item
            ManagementPackMonitorCriteria monitorsCriteria            = new ManagementPackMonitorCriteria("Name = 'Community.ManagementPackCatalog.PackStatusMonitor'");
            ManagementPackMonitor         updateManagementPackMonitor = ManagementGroupConnector.CurrentManagementGroup.Monitoring.GetMonitors(monitorsCriteria)[0];

            // Creating a list of one item we pull the current monitoring state of the Update Status monitor
            var monitorList = new List <ManagementPackMonitor>();

            monitorList.Add(updateManagementPackMonitor);
            MonitoringState packStatus = rootManagementServerInstance.GetMonitoringStates((IEnumerable <ManagementPackMonitor>)monitorList)[0];

            return(packStatus);
        }
Пример #3
0
 //---------------------------------------------------------------------
 internal static bool DoesMonitorHaveNonCategoryOverride(
     ManagementPackMonitor monitor
     )
 {
     if (monitor is UnitMonitor)
     {
         return(((UnitMonitor)monitor).HasNonCategoryOverride);
     }
     else if (monitor is InternalRollupMonitor)
     {
         return(((InternalRollupMonitor)monitor).HasNonCategoryOverride);
     }
     else if (monitor is ExternalRollupMonitor)
     {
         return(((ExternalRollupMonitor)monitor).HasNonCategoryOverride);
     }
     else
     {
         throw new ApplicationException("Unknown monitor type " + monitor.GetType());
     }
 }
Пример #4
0
 //---------------------------------------------------------------------
 internal static bool DoesMonitorHaveNonCategoryOverride(
     ManagementPackMonitor monitor
     )
 {
     if(monitor is UnitMonitor)
     {
         return ((UnitMonitor)monitor).HasNonCategoryOverride;
     }
     else if(monitor is InternalRollupMonitor)
     {
         return ((InternalRollupMonitor)monitor).HasNonCategoryOverride;
     }
     else if (monitor is ExternalRollupMonitor)
     {
         return ((ExternalRollupMonitor)monitor).HasNonCategoryOverride;
     }
     else
     {
         throw new ApplicationException("Unknown monitor type " + monitor.GetType());
     }
 }