/// <summary>
        /// The get list.
        /// </summary>
        /// <param name="condition">
        /// The condition.
        /// </param>
        /// <returns>
        /// The <see>
        ///         <cref>IList</cref>
        ///     </see>
        ///     .
        /// </returns>
        public IList <HWESightHost> GetList(string condition = "1=1 ")
        {
            IObjectReader <EnterpriseManagementObject> monitoringObjects = OM12Connection.All <EnterpriseManagementObject>(ESightAppliance.EntityClassName);
            IEnumerable <HWESightHost> appliances = monitoringObjects.Select(ConvertMonitoringObjectToESightHost());

            return(appliances.OrderByDescending(x => x.CreateTime).ToList());
        }
Example #2
0
        public void TestMethod1()
        {
            // ISAvailable && AvailableLastModified && LastModified
            var objects = OM12Connection.All <PartialMonitoringObject>(EntityTypeConst.ESight.HuaweiServer).ToList();

            objects.ForEach(obj =>
            {
                var stateLastModified   = obj.StateLastModified.HasValue ? obj.StateLastModified.Value : obj.TimeAdded;
                TimeSpan addedTimeLong  = DateTime.UtcNow - stateLastModified.ToUniversalTime();
                TimeSpan expectTimeLong = TimeSpan.FromMinutes(5) + TimeSpan.FromSeconds(20);
                // the interval of monitor for our object is 5 minutes. So we will wait (5m + 20s).
                if (addedTimeLong <= expectTimeLong)
                {
                    Console.WriteLine($"{expectTimeLong - addedTimeLong}");
                }

                //Console.WriteLine(obj.TimeAdded);
                //PartialMonitoringObject po = (PartialMonitoringObject)obj;
                //Console.WriteLine($"{po.FullName}, {po.HealthState}");
                //po.RecalculateMonitoringState();
                //// obj.ResetMonitoringState();
                //Console.WriteLine($"{po.FullName}, {po.HealthState}");
            });

            //Console.WriteLine(objects.Count);
            //PartialMonitoringObject value = (PartialMonitoringObject) objects.First();
            //var result = value.ResetMonitoringState();

            //var monitors = OM12Connection.HuaweiESightMG.Monitoring.GetMonitorHierarchy(value);
            //ManagementPackMonitor monitor = monitors.Item;

            // var monitor = monitors.ChildNodes.ElementAt(3);


            //var filters = OM12Connection.HuaweiESightMG.Monitoring.GetMonitors(new ManagementPackMonitorCriteria("id = 'ESight.BladeServer.MainMonitor'"));


            //var health = value.HealthState;
            //Console.WriteLine(value.GetMostDerivedClasses());
            //Console.WriteLine(value.GetLeastDerivedNonAbstractClass());
            //Console.WriteLine(value.GetType());
            //Console.WriteLine(value.GetProperties());

            //            4
            //System.Collections.ObjectModel.ReadOnlyCollection`1[Microsoft.EnterpriseManagement.Configuration.ManagementPackClass]
            //ESight.HighdensityServer
            //Microsoft.EnterpriseManagement.Common.EnterpriseManagementObject
            //System.Collections.ObjectModel.ReadOnlyCollection`1[Microsoft.EnterpriseManagement.Configuration.ManagementPackProperty]
            //Rackserver

            //string deviceId = "192.168.0.2-Rack123456c";
            //IObjectReader<EnterpriseManagementObject> objectReader = OM12Connection.Query(EntityTypeConst.ESight.HuaweiServer, $"DN = '{deviceId}'",
            //    new ObjectQueryOptions(ObjectPropertyRetrievalBehavior.None));

            //EnterpriseManagementObject enterpriseManagementObject = objectReader.First();
            //Console.WriteLine(enterpriseManagementObject);
        }
Example #3
0
        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);
        }
Example #4
0
        public void TestGetAllESightApplicanceAsync()
        {
            string clazzName          = EntityTypeConst.BladeServer.Fan;
            ManagementPackClass clazz = OM12Connection.GetManagementPackClass(clazzName);
            var clazzProps            = clazz.GetProperties();
            var list  = OM12Connection.All <PartialMonitoringObject>(clazzName);
            var first = list.FirstOrDefault();

            var props     = OM12Connection.GetManagementPackProperties(first);
            var baseProps = OM12Connection.GetManagementPackProperties(EntityTypeConst.ESight.HuaweiServer);

            var Status = first[props["Status"]].Value;
            var DN     = first[baseProps["DN"]].Value;

            Console.WriteLine(clazz);
        }
        public void TestQueryAlert()
        {
            var objects = OM12Connection.All <PartialMonitoringObject>(EntityTypeConst.BladeServer.MainName).ToList();

            objects.ForEach(monitoringObject =>
            {
                var criteria = $"ResolutionState != '255' and CustomField5 = '16777219' " +
                               $"and CustomField8 = 'Event Subject=CPUMemoryCPU1Memory'";
                ReadOnlyCollection <MonitoringAlert> alerts = monitoringObject.GetMonitoringAlerts(new MonitoringAlertCriteria(criteria));
                Console.WriteLine(alerts.Count);
            });


            //OM12Connection.HuaweiESightMG.GetMonitoringAlert();

            //p.InsertCustomMonitoringEvent
            // We will identify the alert using suppression rule.
        }