Exemplo n.º 1
0
        public static string CollectorName(this ECollectorType c)
        {
            switch (c)
            {
            case ECollectorType.Memory:
                return(Resources.StringMemory);

            case ECollectorType.Disk:
                return(Resources.StringDisk);

            case ECollectorType.CPUUsage:
                return(Resources.StringCpuUsage);

            case ECollectorType.NICUsage:
                return(Resources.StringNicUsage);

            case ECollectorType.Uptime:
                return(Resources.StringUptime);

            case ECollectorType.LastBootTime:
                return(Resources.StringLastBootTime);

            case ECollectorType.Processes:
                return(Resources.StringProcesses);

            case ECollectorType.Ping:
                return(Resources.StringPing);

            case ECollectorType.InstalledApplications:
                return(Resources.StringInstalledApplications);

            case ECollectorType.Services:
                return(Resources.StringServices);

            case ECollectorType.SystemErrors:
                return(Resources.StringSystemErrors);

            case ECollectorType.ApplicationErrors:
                return(Resources.StringApplicationErrors);

            case ECollectorType.DatabaseSize:
                return(Resources.StringDatabaseSize);

            case ECollectorType.UPS:
                return(Resources.StringUPS);

            case ECollectorType.DiskSpeed:
                return(Resources.StringDiskSpeed);

            case ECollectorType.Unknown:
                return(Resources.StringUnknown);

            default:
                // If we can't get a translated version, use the best thing we have instead of choking
                return(c.ToString());
                //throw new ArgumentOutOfRangeException(nameof(c), c, null);
            }
        }
Exemplo n.º 2
0
        public static bool GetSkipConfiguration(this ECollectorType c)
        {
            bool skip_configuration = false;
            Type type = c.GetType();

            MemberInfo[] memInfo = type.GetMember(c.ToString());
            if (memInfo != null && memInfo.Length > 0)
            {
                object[] attrs = memInfo[0].GetCustomAttributes(typeof(SkipConfigurationAttribute), false);
                if (attrs != null && attrs.Length > 0)
                {
                    skip_configuration = (attrs[0] as SkipConfigurationAttribute).SkipConfiguration;
                }
            }
            return(skip_configuration);
        }
Exemplo n.º 3
0
        public static int GetFrequencyInMinutes(this ECollectorType c)
        {
            int  frequency = 0;
            Type type      = c.GetType();

            MemberInfo[] memInfo = type.GetMember(c.ToString());
            if (memInfo != null && memInfo.Length > 0)
            {
                object[] attrs = memInfo[0].GetCustomAttributes(typeof(DefaultCollectionFrequencyAttribute), false);
                if (attrs != null && attrs.Length > 0)
                {
                    frequency = (attrs[0] as DefaultCollectionFrequencyAttribute).FrequencyInMinutes;
                }
            }
            return(frequency);
        }
Exemplo n.º 4
0
        public static List <EDeviceType> GetDevices(this ECollectorType c)
        {
            List <EDeviceType> types = new List <EDeviceType>();
            Type type = c.GetType();

            MemberInfo[] memInfo = type.GetMember(c.ToString());
            if (memInfo != null && memInfo.Length > 0)
            {
                object[] attrs = memInfo[0].GetCustomAttributes(typeof(DevicesAttribute), false);
                if (attrs != null)
                {
                    foreach (object o in attrs)
                    {
                        DevicesAttribute attr = o as DevicesAttribute;
                        types.AddRange(attr.Devices);
                    }
                }
            }
            return(types);
        }