public void GetAllAlert() { OM12Connection.HuaweiESightConnector.GetMonitoringAlerts(); // OM12Connection.HuaweiESightMG.GetMonitoringAlert(); var objects = OM12Connection.All <EnterpriseManagementObject>(EntityTypeConst.ESight.HuaweiServer).ToList(); MonitoringClass mpClass = (MonitoringClass)OM12Connection.GetManagementPackClass(EntityTypeConst.ESight.HuaweiServer); OM12Connection.HuaweiESightMG.GetMonitoringAlertReader(mpClass); Console.WriteLine(objects.Count); }
//--------------------------------------------------------------------- private string GetImageKey( MonitoringClass monitoringClass ) { ReadOnlyCollection <MonitoringImageReference> imageRefs; if (m_classIdToMonitoringImageReferences.ContainsKey(monitoringClass.Id)) { imageRefs = m_classIdToMonitoringImageReferences[monitoringClass.Id]; } else { imageRefs = monitoringClass.GetMonitoringImageReferences(); m_classIdToMonitoringImageReferences.Add(monitoringClass.Id, imageRefs); } string imageKey = string.Empty; foreach (ManagementPackImageReference imageRef in imageRefs) { MonitoringImageObject imageObj; if (m_imageIdToImageMap.ContainsKey(imageRef.ImageID.Id)) { imageObj = m_imageIdToImageMap[imageRef.ImageID.Id]; } else { imageObj = m_managementGroup.GetMonitoringImageObject(imageRef.ImageID.Id); m_imageIdToImageMap.Add(imageRef.ImageID.Id, imageObj); } Bitmap classImage = new Bitmap(imageObj.ImageData); if (classImage.Height == 16 && classImage.Width == 16) { imageKey = imageRef.ImageID.Id.ToString(); break; } } if (imageKey == string.Empty) { if (monitoringClass.Base == null) { return(imageKey); } MonitoringClass parentMonitoringClass = m_managementGroup.GetMonitoringClass(monitoringClass.Base.Id); imageKey = GetImageKey(parentMonitoringClass); } return(imageKey); }
//--------------------------------------------------------------------- private static List <MPOverride> GenerateEffectiveOverrrideList( PartialMonitoringObject monitoringObject, ReadOnlyCollection <ManagementPackMonitor> monitors, Dictionary <Guid, MonitoringClass> typeLookupTable ) { List <MPOverride> overrides = new List <MPOverride>(); foreach (ManagementPackMonitor monitor in monitors) { // if we do this check which I commented out, it only works for Windows computer, not for linux ones... // I am not sure why the check was done in the first place... what was it preventing from doing? // was it just an optimization to speed things up, or was it protecting the UI from dealing with some weird monitors? //if (!DoesMonitorHaveNonCategoryOverride(monitor)) //{ // continue; //} MonitorResultantOverrideSet overrideSet = monitoringObject.GetResultantOverrides(monitor); MPWorkflow workflow = new MPWorkflow(monitor); foreach (ResultantOverride <MonitorConfigurationOverride> monitorOverride in overrideSet.ResultantConfigurationOverrides.Values) { MonitoringClass target = typeLookupTable[monitor.Target.Id]; workflow.AddOverride(monitorOverride.EffectiveOverride); MPOverride mpOverride = new MPOverride(monitorOverride.EffectiveOverride, workflow, new MPClass(target)); overrides.Add(mpOverride); } foreach (ResultantOverride <ManagementPackOverride> monitorOverride in overrideSet.ResultantPropertyOverrides.Values) { MonitoringClass target = typeLookupTable[monitor.Target.Id]; workflow.AddOverride(monitorOverride.EffectiveOverride); MPOverride mpOverride = new MPOverride(monitorOverride.EffectiveOverride, workflow, new MPClass(target)); overrides.Add(mpOverride); } } return(overrides); }
//--------------------------------------------------------------------- private void CreateGroups() { Dictionary <PartialMonitoringObject, List <ListViewItem> > itemDictionary = new Dictionary <PartialMonitoringObject, List <ListViewItem> >(); ShowGroups = true; foreach (ListViewItem item in Items) { PartialMonitoringObject monitoringObject = ((OverrideInfo)item.Tag).m_monitoringObject; if (!itemDictionary.ContainsKey(monitoringObject)) { itemDictionary.Add(monitoringObject, new List <ListViewItem>()); } itemDictionary[monitoringObject].Add(item); } foreach (KeyValuePair <PartialMonitoringObject, List <ListViewItem> > pair in itemDictionary) { PartialMonitoringObject monitoringObject = pair.Key; MonitoringClass monitoringObjectClass = monitoringObject.GetLeastDerivedNonAbstractMonitoringClass(); string groupName; string instanceName; string className; instanceName = Common.GetBestMonitoringObjectName(monitoringObject); className = Common.GetBestElementName(monitoringObjectClass); groupName = string.Format("{0} ({1})", instanceName, className); ListViewGroup group = new ListViewGroup(groupName); Groups.Add(group); foreach (ListViewItem item in pair.Value) { item.Group = group; } } }
//--------------------------------------------------------------------- private static List <MPOverride> GenerateEffectiveOverrrideList( PartialMonitoringObject monitoringObject, ReadOnlyCollection <MonitoringDiscovery> discoveries, Dictionary <Guid, MonitoringClass> typeLookupTable ) { List <MPOverride> overrides = new List <MPOverride>(); foreach (MonitoringDiscovery discovery in discoveries) { MonitoringDiscoveryResultantOverrideSet overrideSet = monitoringObject.GetResultantOverrides(discovery); MPWorkflow workflow = new MPWorkflow(discovery); foreach (ResultantOverride <MonitoringDiscoveryConfigurationOverride> discoveryOverride in overrideSet.ResultantConfigurationOverrides.Values) { MonitoringClass target = typeLookupTable[discovery.Target.Id]; workflow.AddOverride(discoveryOverride.EffectiveOverride); MPOverride mpOverride = new MPOverride(discoveryOverride.EffectiveOverride, workflow, new MPClass(target)); overrides.Add(mpOverride); } foreach (ResultantOverride <ManagementPackOverride> discoveryOverride in overrideSet.ResultantPropertyOverrides.Values) { MonitoringClass target = typeLookupTable[discovery.Target.Id]; workflow.AddOverride(discoveryOverride.EffectiveOverride); MPOverride mpOverride = new MPOverride(discoveryOverride.EffectiveOverride, workflow, new MPClass(target)); overrides.Add(mpOverride); } } return(overrides); }
//--------------------------------------------------------------------- private void instancesComboBox_DropDown(object sender, EventArgs e) { if (m_monitoringObjects == null) { MonitoringClass monitoringClass = m_managementGroup.GetMonitoringClass(m_managementPackClass.Id); m_monitoringObjects = m_managementGroup.GetPartialMonitoringObjects(monitoringClass); instancesComboBox.Items.Clear(); foreach (PartialMonitoringObject monitoringObject in m_monitoringObjects) { instancesComboBox.Items.Add(monitoringObject); } if (m_currentMonitoringObject != null && m_isContextCurrentlyGroup == false) { instancesComboBox.SelectedItem = m_currentMonitoringObject; } } }