public EnvironmentTelemetry(
            string clusterType,
            string serviceFabricVersion,
            string clusterDevType)
        {
            // getting hardware information
            int  processorCount;
            long physicalMemoryInKB;

            EnvironmentTelemetry.GetSystemInfo(out processorCount, out physicalMemoryInKB);

            // getting disk and drive info
            string disks  = "[]";
            string drives = "[]";

            try
            {
#if !DotNetCoreClrLinux && !DotNetCoreClrIOT
                disks  = JsonConvert.SerializeObject(DiskInfoTelemetry.GetAllDisks());
                drives = JsonConvert.SerializeObject(DriveInfoTelemetry.GetAllDrives());
#endif
            }
            catch (Exception e)
            {
                // catching any exception for safety in case it fails for some reason
                // otherwise it will crash DCA everytime and prevent other telemetry to be sent
                EnvironmentTelemetry.traceSource.WriteError(LogSourceId, "Failed trying to get information about disks and drives. {0}", e);
            }

            // getting OS information
            string operatingSystem;
            string operatingSystemVersion;
            EnvironmentTelemetry.GetOperatingSystemInfo(out operatingSystem, out operatingSystemVersion);

            // populating the properties list with arguments
            this.Properties = new Dictionary <string, string>();
            this.Properties.Add(ClusterTypeStr, clusterType);
            this.Properties.Add(ServiceFabricVersionStr, serviceFabricVersion);
            this.Properties.Add(ClusterDevTypeStr, clusterDevType);
            this.Properties.Add(DisksStr, disks);
            this.Properties.Add(DrivesStr, drives);
            this.Properties.Add(OperatingSystemStr, operatingSystem);
            this.Properties.Add(OperatingSystemVersionStr, operatingSystemVersion);

            // populating the metrics list with arguments
            this.Metrics = new Dictionary <string, double>();
            this.Metrics.Add(ProcessorCountStr, (double)processorCount);
            this.Metrics.Add(PhysicalMemoryInKBStr, (double)physicalMemoryInKB);

            this.TraceAggregationCfg = TraceAggregationConfig.CreateSnapshotTraceAggregatorConfig(TaskNameStr, EventNameStr, string.Empty, this.Properties.Keys, this.Metrics.Keys);
        }
Beispiel #2
0
        public static DiskInfoTelemetry[] GetAllDisks()
        {
            List <DiskInfoTelemetry> disksInfo = new List <DiskInfoTelemetry>();
            ManagementObjectSearcher s         = new ManagementObjectSearcher(
                "\\root\\Microsoft\\Windows\\Storage",
                "SELECT * FROM MSFT_PhysicalDisk",
                new EnumerationOptions());

            foreach (ManagementObject drive in s.Get())
            {
                DiskInfoTelemetry disk = new DiskInfoTelemetry(drive);
                disksInfo.Add(disk);
            }

            return(disksInfo.ToArray());
        }
Beispiel #3
0
        private DiskInfoTelemetry(ManagementObject drive)
        {
            string deviceId;

            DiskInfoTelemetry.TryGetString(drive, "DeviceID", out deviceId);
            this.DeviceIdHash = ((uint)deviceId.GetHashCode()).ToString();

            // MediaType
            ushort mediaTypeId;

            if (DiskInfoTelemetry.TryGetUShort(drive, "MediaType", out mediaTypeId))
            {
                this.MediaType = DiskInfoTelemetry.GetDiskMediaTypeName(mediaTypeId);
            }
            else
            {
                this.MediaType = "undefined-MediaType";
            }

            // Size
            ulong size;

            DiskInfoTelemetry.TryGetULong(drive, "Size", out size);
            this.Size = size;

            // Allocated size
            ulong allocatedSize;

            DiskInfoTelemetry.TryGetULong(drive, "AllocatedSize", out allocatedSize);
            this.AllocatedSize = allocatedSize;

            // Spindle Speed
            uint spindleSpeed;

            DiskInfoTelemetry.TryGetUInt(drive, "SpindleSpeed", out spindleSpeed);
            this.SpindleSpeed = spindleSpeed;
        }