Exemplo n.º 1
0
 private MonitoringObject FindActionPoint(MonitoringObject instance)
 {
     if (_seedClass.Hosted)
     {
         // if it is hosted, then myActionPoints contains lists of all hosts, so instead of querying SCOM, let's search in this list
         int lastPathPortionIndex = instance.Path.LastIndexOf(';');
         MonitoringObject result  = null;
         if (lastPathPortionIndex > 0) // ??
         {
             string hostName = instance.Path.Substring(lastPathPortionIndex + 1);
             string hostPath = instance.Path.Substring(0, lastPathPortionIndex);
             result = _actionPoints.Where(x => x.Name == hostName && x.Path == hostPath).FirstOrDefault();
         }
         else
         {
             result = _actionPoints.Where(x => x.Name == instance.Path).FirstOrDefault();
         }
         if (result != null)
         {
             return(result);
         }
         else if (_relHosting != null)
         {
             // backup way if myActionPointClass defined incorrectly
             return(_managementGroup.EntityObjects.GetRelationshipObjectsWhereTarget <MonitoringObject>(instance.Id, _relHosting, DerivedClassTraversalDepth.Recursive, TraversalDepth.OneLevel, ObjectQueryOptions.Default).Where(x => !x.IsDeleted).FirstOrDefault().SourceObject);
         }
         else
         {
             return(result);
         }
     }
     else
     {
         if (_relMapManagesEntity == null && _relHsShouldManageEntity == null)
         {
             return(null); // don't try to find Action Point for truly unhosted class
         }
         var allMAPs = instance.ManagementGroup.EntityObjects.GetRelationshipObjectsWhereTarget <MonitoringObject>(instance.Id, _relMapManagesEntity, DerivedClassTraversalDepth.Recursive, TraversalDepth.OneLevel, ObjectQueryOptions.Default).Where(x => !x.IsDeleted);
         if (allMAPs.Count() == 1)
         {
             var draftResult = allMAPs.First().SourceObject;
             if (draftResult.LeastDerivedNonAbstractManagementPackClassId == SystemMonitoringClass.ManagementService.Id)
             {
                 return(_managementGroup.EntityObjects.GetObject <MonitoringObject>((Guid)draftResult[_healthServicePropertyId].Value, ObjectQueryOptions.Default));
             }
             else
             {
                 return(draftResult);
             }
         }
         else if (allMAPs.Count() == 0)
         {
             return(null);
         }
         else
         {
             throw new Exception("Unexpected result from GetRelationshipObjectsWhereTarget");
         }
     }
 }
Exemplo n.º 2
0
        public ScomMonitoringInstance(MonitoringObject monitoringObject = null, MonitoringObject actionPoint = null)
        {
            ActionPoint      = actionPoint;
            MonitoringObject = monitoringObject;

            if (monitoringObject == null)
            {
                return;
            }

            //Map attribute Guid to actual property value
            foreach (var property in GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static))
            {
                var scomAttributeProperty = (ScomClassPropertyAttribute)property.GetCustomAttributes(typeof(ScomClassPropertyAttribute), true).FirstOrDefault();
                if (scomAttributeProperty == null)
                {
                    continue;
                }

                object instanceValue = monitoringObject[scomAttributeProperty.PropertyId]?.Value;

                if (instanceValue == null)
                {
                    continue;
                }

                property.SetValue(this, instanceValue);
            }
        }
Exemplo n.º 3
0
        public MonitoringDeviceObject Reload()
        {
            MonitoringDeviceObject monitoringDeviceObject = BaseConnector.GetDeviceByObjectId(this.MpClazz, this.DeviceId);

            this.Device = monitoringDeviceObject.Device;
            return(this);
        }
Exemplo n.º 4
0
 public MonitoringDeviceObject(string deviceId, MonitoringObject Device, ServerTypeEnum serverType, Func <string, MonitoringObject> LoadFunc)
 {
     this.DeviceId   = deviceId;
     this.Device     = Device;
     this.LoadFunc   = LoadFunc;
     this.ServerType = serverType;
 }
        /// <summary>
        /// Updates the fusionDirector collection.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="existObj">The exist object.</param>
        private void UpdateFusionDirectorCollection(FusionDirectorCollection model, MonitoringObject existObj)
        {
            var propertys = this.FusionDirectorCollectionClass.PropertyCollection;

            existObj[propertys["ResourceName"]].Value = model.ResourceName;
            existObj[propertys["Health"]].Value       = model.Health.ToString();
            existObj[this.DisplayNameField].Value     = model.ResourceName;
        }
Exemplo n.º 6
0
        public async Task Monitor([FromBody] UrlMonitoringObjectModel model)
        {
            var mappedModel = new MonitoringObject()
            {
                ServiceName = model.ServiceName,
                Url         = model.Url
            };

            await _monitoringService.MonitorAsync(mappedModel);
        }
        /// <summary>
        /// Updates the appliance.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="existObj">The exist object.</param>
        private void UpdateAppliance(Appliance model, MonitoringObject existObj)
        {
            var propertys = this.ApplianceClass.PropertyCollection;

            existObj[propertys["HostName"]].Value        = model.HostName;
            existObj[propertys["IPAddress"]].Value       = model.IPAddress;
            existObj[propertys["SoftwareVersion"]].Value = model.SoftwareVersion;
            existObj[propertys["Health"]].Value          = model.Health.ToString();
            existObj[this.DisplayNameField].Value        = model.HostName;
        }
Exemplo n.º 8
0
        public async Task Ping([FromBody] MonitoringObjectPingModel model)
        {
            var mappedModel = new MonitoringObject()
            {
                ServiceName = model.ServiceName,
                Version     = model.Version,
                LastTime    = DateTime.UtcNow
            };

            await _monitoringService.PingAsync(mappedModel);
        }
        private bool CompareEnclosure(Enclosure model, MonitoringObject existObj)
        {
            var propertys = this.EnclosureClass.PropertyCollection;

            if (existObj[propertys["Name"]].Value.ToString() != model.Name)
            {
                return(true);
            }
            if (existObj[propertys["Type"]].Value.ToString() != model.Type.ToString())
            {
                return(true);
            }
            if (existObj[propertys["FirmwareVersion"]].Value.ToString() != model.FirmwareVersion.ToString())
            {
                return(true);
            }
            if (existObj[propertys["Hostname"]].Value.ToString() != model.Hostname.ToString())
            {
                return(true);
            }
            if (existObj[propertys["SerialNumber"]].Value.ToString() != model.SerialNumber.ToString())
            {
                return(true);
            }
            if (existObj[propertys["PartNumber"]].Value.ToString() != model.PartNumber.ToString())
            {
                return(true);
            }
            if (existObj[propertys["ProductName"]].Value.ToString() != model.ProductName.ToString())
            {
                return(true);
            }
            if (existObj[propertys["EnclosureState"]].Value.ToString() != model.EnclosureState.ToString())
            {
                return(true);
            }
            if (existObj[propertys["StateReason"]].Value.ToString() != model.StateReason.ToString())
            {
                return(true);
            }
            if (existObj[propertys["FanSpeedAdjustmentMode"]].Value.ToString() != model.FanSpeedAdjustmentMode.ToString())
            {
                return(true);
            }
            if (existObj[propertys["HMMFloatIPv4Address"]].Value.ToString() != model.HMMFloatIPv4Address.ToString())
            {
                return(true);
            }
            if (existObj[propertys["Health"]].Value.ToString() != model.Health.ToString())
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Updates the fan.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="oldObject">The old object.</param>
        /// <returns>MPObject.</returns>
        private void UpdateFan(HWFAN model, MonitoringObject oldObject)
        {
            var propertys = this.FanClass.PropertyCollection; // 获取到class的属性

            if (model.HealthState != "-3")
            {
                oldObject[propertys["Status"]].Value = model.HealthStateTxt;
            }
            oldObject[propertys["PresentState"]].Value  = model.PresentState;
            oldObject[propertys["Speed"]].Value         = model.Rotate;
            oldObject[propertys["RotatePercent"]].Value = model.RotatePercent;
            oldObject[this.DisplayNameField].Value      = model.Name;
        }
Exemplo n.º 11
0
 private IEnumerable <MonitoringObject> FindActionPoints(MonitoringObject servedInstance) => servedInstance.ManagementGroup.EntityObjects.GetRelationshipObjectsWhereTarget <MonitoringObject>(servedInstance.Id, relMAPManagesEntity, DerivedClassTraversalDepth.Recursive, TraversalDepth.OneLevel, ObjectQueryOptions.Default)
 .Where(x => !x.IsDeleted)
 .Select(a =>
 {
     if (a.SourceObject.IsInstanceOf(managementServiceClass))
     {
         return(ManagementGroup.EntityObjects.GetObject <MonitoringObject>((Guid)a.SourceObject[SystemCenterId.ManagementServiceClassProperties.HealthServiceIdPropertyId].Value, ObjectQueryOptions.Default));
     }
     else
     {
         return(a.SourceObject);
     }
 });
Exemplo n.º 12
0
        protected MonitoringObject GetFullParentServer(MonitoringObject obj)
        {
            var group = obj.GetParentPartialMonitoringObjects();

            if (group.Any())
            {
                var parent = group.First();
                var t      = parent.GetParentMonitoringObjects();
                if (t.Any())
                {
                    return(t.First());
                }
            }
            return(null);
        }
        /// <summary>
        /// Updates the disk.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="oldObject">The old object.</param>
        /// <returns>The <see cref="MonitoringObject" />.</returns>
        private void UpdateDisk(HWDisk model, MonitoringObject oldObject)
        {
            var propertys = this.PhysicalDiskClass.PropertyCollection; // 获取到class的属性

            // oldObject[propertys["UUID"]].Value = model.UUID;
            if (model.HealthState != "-3")
            {
                oldObject[propertys["Status"]].Value = model.HealthStateTxt;
            }
            oldObject[propertys["Locator"]].Value        = model.Location;
            oldObject[propertys["PresentState"]].Value   = model.PresentState;
            oldObject[propertys["Diskcapacity"]].Value   = string.Empty;
            oldObject[propertys["IndterfaceType"]].Value = string.Empty;
            oldObject[this.DisplayNameField].Value       = model.Name;
        }
 public TestObjectAdapter(MonitoringObject rootEntity, Dictionary <string, Image> mainteanceModeImages, Dictionary <HealthState, Image> healthStateImages, Dictionary <HealthState, string> healthStrings)
 {
     if (rootEntity == null)
     {
         throw new ArgumentNullException(nameof(rootEntity));
     }
     if (!rootEntity.IsInstanceOf(rootEntity.ManagementGroup.EntityTypes.GetClass(IDs.TestBaseClassId)))
     {
         throw new InvalidCastException($"Monitoring object passed in the {nameof(rootEntity)} parameter must be of a child class type of 'Maximus.Connectivity.Monitoring.Test'.");
     }
     entity    = rootEntity;
     mmImages  = mainteanceModeImages;
     hsImages  = healthStateImages;
     hsStrings = healthStrings;
 }
        private void OnDeleteTest(object sender, CommandEventArgs e)
        {
            if (DetailView is TestBrowser tb && tb.Grid.SelectedRows != null && tb.Grid.SelectedRows.Count > 0)
            {
                try
                {
                    TestObjectAdapter firstDataItem = (TestObjectAdapter)tb.Grid.SelectedRows[0].DataBoundItem;

                    bool doDelete = false;
                    if (tb.Grid.SelectedRows.Count == 1)
                    {
                        doDelete = MessageBox.Show($"You're about to delete the {firstDataItem.DisplayName} destination.\r\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
                    }
                    else
                    {
                        doDelete = MessageBox.Show($"You're about to delete multiple destinations.\r\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
                    }
                    if (doDelete)
                    {
                        EnterpriseManagementConnector connector            = ManagementGroup.ConnectorFramework.GetMonitoringConnector();
                        IncrementalDiscoveryData      incrementalDiscovery = new IncrementalDiscoveryData();
                        ManagementPackClass           fqdnClass            = ManagementGroup.EntityTypes.GetClass(IDs.FullyQualifiedDomainNameClassId);

                        foreach (DataGridViewRow gridRow in tb.Grid.SelectedRows)
                        {
                            TestObjectAdapter dataItem      = (TestObjectAdapter)gridRow.DataBoundItem;
                            MonitoringObject  currentObject = ManagementGroup.EntityObjects.GetObject <MonitoringObject>(dataItem.Source.Id, ObjectQueryOptions.Default);
                            CreatableEnterpriseManagementObject oldInstance = new CreatableEnterpriseManagementObject(ManagementGroup, currentObject.GetMostDerivedClasses().First());
                            // host keys
                            oldInstance[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value = currentObject[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value;
                            oldInstance[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value = currentObject[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value;
                            // key
                            oldInstance[IDs.TestBaseClassProperties.TestIdPropertyId].Value = currentObject[IDs.TestBaseClassProperties.TestIdPropertyId].Value;
                            incrementalDiscovery.Remove(oldInstance);
                        }

                        incrementalDiscovery.Commit(connector);
                    }

                    // emulate Refresh command for detail view
                    SendRefreshCommandToDetailView();
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"In {System.Reflection.MethodBase.GetCurrentMethod().Name} {ex.GetType().Name} said {ex.Message} at {ex.StackTrace}");
                }
            }
        }
        /// <summary>
        /// Updates the raid control.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="oldObject">The old object.</param>
        /// <returns>The <see cref="MonitoringObject" />.</returns>
        private void UpdateRaidControl(HWRAID model, MonitoringObject oldObject)
        {
            var propertys = this.RaidClass.PropertyCollection; // 获取到class的属性

            // oldObject[propertys["UUID"]].Value = model.UUID;
            if (model.HealthState != "-3")
            {
                oldObject[propertys["Status"]].Value = model.HealthStateTxt;
            }
            oldObject[propertys["Type"]].Value            = model.RaidType;
            oldObject[propertys["DeviceInterface"]].Value = model.InterfaceType;
            oldObject[propertys["BBUType"]].Value         = model.BbuType;
            oldObject[propertys["FirmwareVersion"]].Value = string.Empty;
            oldObject[propertys["DirverVersion"]].Value   = string.Empty;
            oldObject[this.DisplayNameField].Value        = model.Name;
        }
Exemplo n.º 17
0
        private bool HasMAPChanged(MonitoringObject mapObject)
        {
            if (mapObject == null)
            {
                return(true);
            }
            if (mapObject.IsInstanceOf(poolClass))
            {
                if (rbAgent.Checked) // current MAP type is POOL, but AGENT is selected
                {
                    return(true);
                }
                if (cbResourcePools.SelectedItem == null)
                {
                    return(false);
                }
                if (((MonitoringObject)cbResourcePools.SelectedItem).Id == mapObject.Id)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            if (mapObject.IsInstanceOf(healthServiceClass))
            {
                if (rbPool.Checked) // current MAP type is AGENT, but POOL is selected
                {
                    return(true);
                }
                if (lbAgentList.SelectedItem == null)
                {
                    return(false);
                }
                if (((MonitoringObject)lbAgentList.SelectedItem).Id == mapObject.Id)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
        private void OnDeleteDestination(object sender, CommandEventArgs e)
        {
            if (Grid.SelectedRows != null && Grid.SelectedRows.Count > 0)
            {
                try
                {
                    InstanceState firstDataItem = (InstanceState)(Grid.SelectedRows[0].Cells[0].Tag as GridDataItem).DataItem;

                    bool doDelete = false;
                    if (Grid.SelectedRows.Count == 1)
                    {
                        doDelete = MessageBox.Show($"You're about to delete the {firstDataItem.DisplayName} destination.\r\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
                    }
                    else
                    {
                        doDelete = MessageBox.Show($"You're about to delete multiple destinations.\r\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
                    }
                    if (doDelete)
                    {
                        EnterpriseManagementConnector connector            = ManagementGroup.ConnectorFramework.GetMonitoringConnector();
                        IncrementalDiscoveryData      incrementalDiscovery = new IncrementalDiscoveryData();
                        ManagementPackClass           fqdnClass            = ManagementGroup.EntityTypes.GetClass(IDs.FullyQualifiedDomainNameClassId);

                        foreach (DataGridViewRow gridRow in Grid.SelectedRows)
                        {
                            InstanceState    dataItem      = (InstanceState)(gridRow.Cells[0].Tag as GridDataItem).DataItem;
                            MonitoringObject currentObject = dataItem.GetMonitoringObject(ManagementGroup, ObjectQueryOptions.Default, retrieveAllProperties: true);
                            CreatableEnterpriseManagementObject oldInstance = new CreatableEnterpriseManagementObject(ManagementGroup, fqdnClass);
                            oldInstance[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value = currentObject[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value;
                            oldInstance[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value = currentObject[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value;
                            incrementalDiscovery.Remove(oldInstance);
                        }

                        incrementalDiscovery.Commit(connector);
                    }

                    // emulate Refresh command
                    OnRefreshCommand(sender, e);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"In {System.Reflection.MethodBase.GetCurrentMethod().Name} {ex.GetType().Name} said {ex.Message} at {ex.StackTrace}");
                }
            }
        }
Exemplo n.º 19
0
        public static object GetSCOMClassInstancePropertyValue(MonitoringObject classInstance, string properyName)
        {
            var allClasses = classInstance.GetClasses();
            ManagementPackProperty myProperty = null;

            foreach (var objectClass in allClasses)
            {
                if (objectClass.TryGetProperty(properyName, out myProperty))
                {
                    break;
                }
            }
            if (myProperty == null)
            {
                throw new KeyNotFoundException("Cannot find class property.");
            }
            return(classInstance[myProperty].Value);
        }
        /// <summary>
        /// Updates the power supply.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="oldObject">The old object.</param>
        /// <returns>MPObject.</returns>
        private void UpdatePowerSupply(HWPSU model, MonitoringObject oldObject)
        {
            var propertys = this.PowerSupplyClass.PropertyCollection; // 获取到class的属性

            // oldObject[propertys["UUID"]].Value = model.UUID;
            if (model.HealthState != "-3")
            {
                oldObject[propertys["Status"]].Value = model.HealthStateTxt;
            }
            oldObject[propertys["Manufacturer"]].Value = model.Manufacturer;
            oldObject[propertys["InputMode"]].Value    = model.InputMode;
            oldObject[propertys["Model"]].Value        = model.Model;
            oldObject[propertys["PowerRating"]].Value  = model.RatePower;
            oldObject[propertys["InputPower"]].Value   = model.InputPower;

            oldObject[propertys["PresentState"]].Value = model.PresentState;
            oldObject[this.DisplayNameField].Value     = model.Name;
        }
Exemplo n.º 21
0
 private void OnShowInstanceProperties(object sender, CommandEventArgs e)
 {
     using (InstancePropertiesDialog propertiesDialog = new InstancePropertiesDialog())
     {
         Site.Container.Add(propertiesDialog);
         if (SelectedItem is PartialMonitoringObject pmo)
         {
             MonitoringObject mo = ManagementGroup.EntityObjects.GetObject <MonitoringObject>(pmo.Id, ObjectQueryOptions.Default);
             propertiesDialog.Entity = mo;
             propertiesDialog.Type   = mo.GetMostDerivedClasses().FirstOrDefault();
             if (propertiesDialog.Type == null)
             {
                 return;
             }
             propertiesDialog.ShowDialog();
         }
     }
 }
        private void UpdateEnclosure(Enclosure model, MonitoringObject existObj)
        {
            var propertys = this.EnclosureClass.PropertyCollection;

            existObj[propertys["Name"]].Value                   = model.Name;
            existObj[propertys["Type"]].Value                   = model.Type.ToString();
            existObj[propertys["FirmwareVersion"]].Value        = model.FirmwareVersion;
            existObj[propertys["Hostname"]].Value               = model.Hostname;
            existObj[propertys["SerialNumber"]].Value           = model.SerialNumber;
            existObj[propertys["PartNumber"]].Value             = model.PartNumber;
            existObj[propertys["ProductName"]].Value            = model.ProductName;
            existObj[propertys["EnclosureState"]].Value         = model.EnclosureState.ToString();
            existObj[propertys["StateReason"]].Value            = model.StateReason;
            existObj[propertys["FanSpeedAdjustmentMode"]].Value = model.FanSpeedAdjustmentMode;
            existObj[propertys["HMMFloatIPv4Address"]].Value    = model.HMMFloatIPv4Address;
            existObj[propertys["Health"]].Value                 = model.Health.ToString();
            existObj[this.DisplayNameField].Value               = model.Name;
        }
        /// <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);
        }
        private void UpdateServer(Server model, MonitoringObject existObj)
        {
            var propertys = this.ServerClass.PropertyCollection;

            existObj[propertys["UUID"]].Value                  = model.UUID;
            existObj[propertys["HostName"]].Value              = model.HostName;
            existObj[propertys["Model"]].Value                 = model.Model;
            existObj[propertys["BMCVersion"]].Value            = model.BMCVersion;
            existObj[propertys["BiosVersion"]].Value           = model.BiosVersion;
            existObj[propertys["TotalSystemMemoryGiB"]].Value  = model.TotalSystemMemoryGiB;
            existObj[propertys["TotalSystemStorageGiB"]].Value = model.TotalSystemStorageGiB;
            existObj[propertys["PowerState"]].Value            = model.PowerState;
            existObj[propertys["ProcessorInfo"]].Value         = model.ProcessorInfo;
            existObj[propertys["SerialNumber"]].Value          = model.SerialNumber;
            existObj[propertys["ServerState"]].Value           = model.ServerState;
            existObj[propertys["StateReason"]].Value           = model.StateReason;
            existObj[propertys["iBMCIPv4Address"]].Value       = model.iBMCIPv4Address;
            existObj[propertys["Tag"]].Value          = model.Tag;
            existObj[propertys["ProfileModel"]].Value = model.ProfileModelName;
            existObj[propertys["AssetTag"]].Value     = model.AssetTag;
            existObj[propertys["Health"]].Value       = model.Health.ToString();
            existObj[this.DisplayNameField].Value     = $"{model.FusionDirectorIp}_{model.iBMCIPv4Address}";
        }
Exemplo n.º 25
0
 public ComputerInstance(MonitoringObject mo)
 {
     WindowsComputerObject = mo;
 }
Exemplo n.º 26
0
 public MonitoringObjectTypeDescriptor(MonitoringObject monitoringObject)
 {
     MonitoringObject = monitoringObject;
 }
        public NewTestDialog(ManagementGroup managementGroup, ManagementPackClass managementPackClass, MonitoringObject baseDestinationObject, Guid existingTestObjectId)
        {
            InitializeComponent();
            ManagementGroup = managementGroup;

            if (existingTestObjectId == Guid.Empty)
            {
                if (baseDestinationObject == null)
                {
                    throw new ArgumentNullException(nameof(baseDestinationObject));
                }
                TargetClass = managementPackClass ?? throw new ArgumentNullException(nameof(managementPackClass));
            }
            else
            {
                ExistingObject = ManagementGroup.EntityObjects.GetObject <MonitoringObject>(existingTestObjectId, ObjectQueryOptions.Default);
                TargetClass    = ExistingObject.GetMostDerivedClasses().First();
            }
            rtbDescription.Text = TargetClass.Description;
            try
            {
                ManagementPackKnowledgeArticle kb = TargetClass.GetKnowledgeArticle(Thread.CurrentThread.CurrentUICulture);
                btDocumentation.Enabled = kb != null;
                llLearnMore.Enabled     = kb != null;
            }
            catch (ObjectNotFoundException)
            {
                btDocumentation.Enabled = false;
                llLearnMore.Enabled     = false;
            }

            if (existingTestObjectId == Guid.Empty)
            {
                Text = $"New {(string.IsNullOrWhiteSpace(TargetClass.DisplayName) ? TargetClass.Name : TargetClass.DisplayName)}";
            }
            else
            {
                Text = $"Edit {(string.IsNullOrWhiteSpace(TargetClass.DisplayName) ? TargetClass.Name : TargetClass.DisplayName)}";
            }

            CreatableEnterpriseManagementObject testObject = new CreatableEnterpriseManagementObject(managementGroup, TargetClass);

            // initialize or load other properties
            if (existingTestObjectId == Guid.Empty)
            {
                testObject[IDs.TestBaseClassProperties.TestIdPropertyId].Value         = Guid.NewGuid();
                testObject[SystemId.EntityClassProperties.DisplayNamePropertyId].Value = string.IsNullOrWhiteSpace(TargetClass.DisplayName) ? TargetClass.Name : TargetClass.DisplayName;
                // bind to host object -- from explicit parent
                testObject[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value = baseDestinationObject[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value; // parent key 1
                testObject[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value = baseDestinationObject[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value;                           // parent key 2
            }
            else
            {
                // host object binding will be done automatically as a part of property copying
                foreach (ManagementPackProperty mpProperty in ExistingObject.GetProperties())
                {
                    testObject[mpProperty].Value = ExistingObject[mpProperty].Value;
                }
            }
            CreatableObjectAdapter        = new CreatableObjectAdapter(testObject);
            pgObjectEditor.SelectedObject = CreatableObjectAdapter;
        }
        //-----------------------------------------------------------------------------------
        static string DisplayRelationshipInformation(MonitoringObject mObject, ManagementGroup mg, Guid mObjectID)
        {
            if (mObject.Id == mObjectID)
                        {
            //Получаем список отношений для конкретного обьекта мониторинга
            IList<EnterpriseManagementRelationshipObject<MonitoringObject>> relObjects = mg.EntityObjects.GetRelationshipObjects<MonitoringObject>(mObject.Id, ObjectQueryOptions.Default);

            foreach (EnterpriseManagementRelationshipObject<MonitoringObject> relObject in relObjects)
            {
                //Ищем группу начинающююся на "PS.", так как только обьекты мониторинга в этих группах должны обрабатыватся
                if (relObject.SourceObject.DisplayName.Contains("PS."))                { return relObject.SourceObject.DisplayName; }
             }
            }
            return "";
        }
Exemplo n.º 29
0
        private void PerformRelationshipCleanup(ManagementPackClass seedClass, CreatableEnterpriseManagementObject seedInstance, MonitoringObject monitoringObject)
        {
            // it's so complex, because the new instance may not exist
            EnterpriseManagementObject realSeedInstance;

            string criteriaString = string.Empty;

            foreach (var property in seedInstance.GetProperties())
            {
                if (property.Key)
                {
                    if (criteriaString == string.Empty)
                    {
                        criteriaString = property.Name + "='" + seedInstance[property] + "'";
                    }
                    else
                    {
                        criteriaString += " AND " + property.Name + "='" + seedInstance[property] + "'";
                    }
                }
            }

            var searchQuery          = new EnterpriseManagementObjectCriteria(criteriaString, seedClass);
            var realSeedInstanceList = _managementGroup.EntityObjects.GetObjectReader <EnterpriseManagementObject>(searchQuery, ObjectQueryOptions.Default);

            realSeedInstance = realSeedInstanceList.FirstOrDefault();

            if (realSeedInstance == null)
            {
                return;
            }

            var removalDiscovery = new IncrementalDiscoveryData();

            // Management Point
            bool commitOverwrite = false;
            var  allMAPRelations = _managementGroup.EntityObjects.GetRelationshipObjectsWhereTarget <EnterpriseManagementObject>(realSeedInstance.Id, _relToClearMap, DerivedClassTraversalDepth.Recursive, TraversalDepth.OneLevel, ObjectQueryOptions.Default).Where(x => !x.IsDeleted);
            var  allHSRelations  = _managementGroup.EntityObjects.GetRelationshipObjectsWhereTarget <EnterpriseManagementObject>(realSeedInstance.Id, _relToClearHs, DerivedClassTraversalDepth.Recursive, TraversalDepth.OneLevel, ObjectQueryOptions.Default).Where(x => !x.IsDeleted);

            foreach (var rel in allMAPRelations)
            {
                if (rel.SourceObject.Id != monitoringObject.Id)
                {
                    // remove this relationship
                    removalDiscovery.Remove(rel);
                    commitOverwrite = true;
                }
            }

            foreach (var rel in allHSRelations)
            {
                if (rel.SourceObject.Id != monitoringObject.Id)
                {
                    // remove this relationship
                    removalDiscovery.Remove(rel);
                    commitOverwrite = true;
                }
            }

            if (commitOverwrite)
            {
                removalDiscovery.Overwrite(_managementGroup);
            }
        }
        private void PerformRelationshipCleanup(ManagementPackClass mySeedClass, CreatableEnterpriseManagementObject newSeedInstance, MonitoringObject monitoringObject)
        {
            // it's so complex, because the new instance may not exist
            EnterpriseManagementObject realSeedInstance;
            string criteriaString = "";

            foreach (ManagementPackProperty property in newSeedInstance.GetProperties())
            {
                if (property.Key)
                {
                    if (criteriaString == "")
                    {
                        criteriaString = property.Name + "='" + newSeedInstance[property] + "'";
                    }
                    else
                    {
                        criteriaString += " AND " + property.Name + "='" + newSeedInstance[property] + "'";
                    }
                }
            }
            EnterpriseManagementObjectCriteria         searchQuery          = new EnterpriseManagementObjectCriteria(criteriaString, mySeedClass);
            IObjectReader <EnterpriseManagementObject> realSeedInstanceList = myMG.EntityObjects.GetObjectReader <EnterpriseManagementObject>(searchQuery, ObjectQueryOptions.Default);

            if (realSeedInstanceList.Count == 0)
            {
                return;
            }
            else
            {
                realSeedInstance = realSeedInstanceList.First();
            }

            IncrementalDiscoveryData RemovalDiscovery = new IncrementalDiscoveryData();
            // Management Point
            bool commitOverwrite = false;
            IEnumerable <EnterpriseManagementRelationshipObject <EnterpriseManagementObject> > allMAPRelations = myMG.EntityObjects.GetRelationshipObjectsWhereTarget <EnterpriseManagementObject>(realSeedInstance.Id, relToClearMAP, DerivedClassTraversalDepth.Recursive, TraversalDepth.OneLevel, ObjectQueryOptions.Default).Where(x => !x.IsDeleted);
            IEnumerable <EnterpriseManagementRelationshipObject <EnterpriseManagementObject> > allHSRelations  = myMG.EntityObjects.GetRelationshipObjectsWhereTarget <EnterpriseManagementObject>(realSeedInstance.Id, relToClearHS, DerivedClassTraversalDepth.Recursive, TraversalDepth.OneLevel, ObjectQueryOptions.Default).Where(x => !x.IsDeleted);

            foreach (EnterpriseManagementRelationshipObject <EnterpriseManagementObject> rel in allMAPRelations)
            {
                if (rel.SourceObject.Id != monitoringObject.Id)
                {
                    // remove this relationship
                    RemovalDiscovery.Remove(rel);
                    commitOverwrite = true;
                }
            }
            foreach (EnterpriseManagementRelationshipObject <EnterpriseManagementObject> rel in allHSRelations)
            {
                if (rel.SourceObject.Id != monitoringObject.Id)
                {
                    // remove this relationship
                    RemovalDiscovery.Remove(rel);
                    commitOverwrite = true;
                }
            }
            if (commitOverwrite)
            {
                RemovalDiscovery.Overwrite(myConnector);
            }
        }
 public UrlAddressMonitoringInstance(MonitoringObject monitoringObject = null, MonitoringObject actionPoint = null) : base(monitoringObject, actionPoint)
 {
 }