Пример #1
0
        private void Action(object sender, ElapsedEventArgs e)
        {
            var dtnow         = DateTime.Now;
            var pk            = Encoding.ASCII.GetString(_asymmetricKeys.PublicKey);
            var internalIp    = "";
            var externalIp    = WhatIsMyIp.Get();
            var machineInfo   = new MachineInfo();
            var ut            = machineInfo.GetUptime();
            var uptime        = ut.Uptime;
            var loadAverage   = ut.LoadAverage;
            var du            = new DiskUsage().GetInfo().FirstOrDefault(_ => _.MountedOn == "/mnt/cdrom");
            var diskUsage     = du?.UsePercentage;
            var hostnamectl   = _launcher.Launch("hostnamectl").ToList();
            var hostname      = hostnamectl.First(_ => _.Contains("Static hostname:")).Split(new[] { ":" }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
            var antdVersion   = GetVersionDateFromFile(_bash.Execute("file /mnt/cdrom/Apps/Anthilla_Antd/active-version"));
            var systemVersion = GetVersionDateFromFile(_bash.Execute("file /mnt/cdrom/System/active-system"));
            var kernelVersion = GetVersionDateFromFile(_bash.Execute("file /mnt/cdrom/Kernel/active-kernel"));
            var dict          = new Dictionary <string, string> {
                { "AppName", "Antd" },
                { "MachineUid", _machineId },
                { "KeyValue", pk },
                { "InternalIp", internalIp },
                { "ExternalIp", externalIp },
                { "Uptime", uptime },
                { "DiskUsage", diskUsage },
                { "LoadAverage", loadAverage },
                { "Hostname", hostname },
                { "AntdVersion", antdVersion },
                { "SystemVersion", systemVersion },
                { "KernelVersion", kernelVersion }
            };

            _api.Post($"{Parameter.Cloud}repo/assetinfo/save", dict);
            ConsoleLogger.Log($"[cloud-uptime] info sent to cloud - data gathered in {DateTime.Now - dtnow}");
        }
Пример #2
0
        public void AssignData(DiskUsage data, SortingOption initialSorting)
        {
            DataStore = data;
            Sorting   = initialSorting;

            SetChartOptions(Mode, Sorting);
        }
        protected override void Dispose(bool disposing)
        {
            if (this.disposed)
            {
                return;
            }

            if (disposing)
            {
                if (this.perfCounters != null)
                {
                    this.perfCounters.Dispose();
                    this.perfCounters = null;
                }

                if (this.diskUsage != null)
                {
                    this.diskUsage.Dispose();
                    this.diskUsage = null;
                }

                // Data lists.
                this.processWatchList?.Clear();
                this.allCpuData?.Clear();
                this.allMemData?.Clear();
                this.evtRecordList?.Clear();

                this.disposed = true;
            }
        }
Пример #4
0
 public DiskUsageData(DiskUsage du)
 {
     dataID    = collectorID = -1;
     timeStamp = DateTimeOffset.MinValue;
     capacity  = du.CapacityNum;
     free      = du.FreeNum;
 }
Пример #5
0
        public MonitorModule()
        {
            Get["/monitor/resources"] = x => {
                var hostname    = File.ReadAllText("/etc/hostname");
                var machineInfo = new MachineInfo();
                var uptime      = machineInfo.GetUptime();
                var memoryUsage = 0;
                var memory      = machineInfo.GetFree().FirstOrDefault();
                if (memory != null)
                {
                    var tot  = memory.Total;
                    var used = memory.Used;
                    int resultTot;
                    int.TryParse(new string(tot?.SkipWhile(_ => !char.IsDigit(_)).TakeWhile(char.IsDigit).ToArray()), out resultTot);
                    int resultPart;
                    int.TryParse(new string(used?.SkipWhile(_ => !char.IsDigit(_)).TakeWhile(char.IsDigit).ToArray()), out resultPart);
                    memoryUsage = GetPercentage(resultTot, resultPart);
                }
                var du    = new DiskUsage().GetInfo().FirstOrDefault(_ => _.MountedOn == "/mnt/cdrom");
                var model = new PageMonitorModel {
                    Hostname    = hostname,
                    Uptime      = uptime.Uptime.SplitToList("up").Last().Trim(),
                    LoadAverage = uptime.LoadAverage.Replace(" load average:", "").Trim(),
                    MemoryUsage = memoryUsage.ToString(),
                    DiskUsage   = du?.UsePercentage
                };
                return(JsonConvert.SerializeObject(model));
            };

            Get["/configured"] = x => {
                var hostConfiguration = new HostConfiguration();
                var host = hostConfiguration.Host;
                return(JsonConvert.SerializeObject(host.IsConfigured));
            };
        }
Пример #6
0
        public void Interpret(Data d, SQLiteConnection conn)
        {
            if (d.Type != ECollectorType.Disk)
            {
                return;
            }

            if (d is GenericDictionaryData <DiskUsage> )
            {
                Dictionary <string, DiskUsage> value = ((GenericDictionaryData <DiskUsage>)d).Data;

                // Don't alert on drives that aren't being monitored
                MonitoredDrivesRequest request = new MonitoredDrivesRequest(d.Name);
                RequestBus.Instance.MakeRequest(request);

                DiskSpaceLowAlert           low_level            = new DiskSpaceLowAlert();
                DiskSpaceCriticallyLowAlert critically_low_level = new DiskSpaceCriticallyLowAlert();
                double low            = low_level.GetValueAsDouble(conn) ?? 80.0;
                double critically_low = critically_low_level.GetValueAsDouble(conn) ?? 90.0;

                EStatusType     status    = EStatusType.AdequateDiskSpace;
                List <string>   messages  = new List <string>();
                DiskSpaceStatus ds_status = new DiskSpaceStatus(low, critically_low);

                foreach (string drive in value.Keys)
                {
                    if (request.IsHandled && request.DriveManager.IsDriveMonitored(drive) == false)
                    {
                        continue;
                    }

                    DiskUsage data = value[drive];
                    Tuple <EStatusType, double> drive_status = ds_status.GetStatus(data.UsedNum, data.CapacityNum);
                    status = status.DiskSpaceCompare(drive_status.Item1);

                    if (drive_status.Item1 == EStatusType.CriticallyLowOnDiskSpace || drive_status.Item1 == EStatusType.LowOnDiskSpace)
                    {
                        messages.Add($"{drive} -- {drive_status.Item2:0.0} %");
                    }
                }

                string message   = messages.JoinStrings(", ");
                long   device_id = GetDeviceID(d, conn);
                if (device_id >= 0)
                {
                    SetDeviceStatus(device_id, status, DiskSpaceStatus.Types, message, conn);
                }
                else
                {
                    ApplicationEventLog log = new ApplicationEventLog();
                    log.LogError($"DiskSpaceInterpreter: unable to get device id for {d.Context.Name}");
                }
            }
            else
            {
                throw new Exception("DiskSpaceInterpreter: data type is wrong");
            }
        }
Пример #7
0
        /// <inheritdoc/>
        public override async Task ObserveAsync(CancellationToken token)
        {
            // If set, this observer will only run during the supplied interval.
            // See Settings.xml, CertificateObserverConfiguration section, RunInterval parameter for an example.
            if (RunInterval > TimeSpan.MinValue &&
                DateTime.Now.Subtract(LastRunDateTime) < RunInterval)
            {
                return;
            }

            bool initialized = Initialize();

            Token = token;

            if (!initialized)
            {
                HealthReporter.ReportFabricObserverServiceHealth(
                    FabricServiceContext.ServiceName.OriginalString,
                    ObserverName,
                    HealthState.Warning,
                    "This observer was unable to initialize correctly due to missing configuration info.");

                return;
            }

            try
            {
                perfCounters = new WindowsPerfCounters();
                diskUsage    = new DiskUsage();

                foreach (var app in targetList)
                {
                    Token.ThrowIfCancellationRequested();

                    if (string.IsNullOrWhiteSpace(app.Target) &&
                        string.IsNullOrWhiteSpace(app.TargetType))
                    {
                        continue;
                    }

                    await MonitorAppAsync(app).ConfigureAwait(true);
                }

                await ReportAsync(token).ConfigureAwait(true);

                LastRunDateTime = DateTime.Now;
            }
            finally
            {
                // Clean up.
                diskUsage?.Dispose();
                diskUsage = null;
                perfCounters?.Dispose();
                perfCounters = null;
            }
        }
Пример #8
0
        /// <summary>
        /// Logs out the directory structure of the apps dir. This produces both a summary
        /// (top level view) of the directory, as well as a detailed view.
        /// </summary>
        /// <param name="appsDirectory">The directory to be analyzed.</param>
        public void DumpAppsDirDiskUsage(string appsDirectory)
        {
            string tsig         = DateTime.Now.ToString("yyyyMMdd_hhmm", CultureInfo.InvariantCulture);
            string summary_file = Path.Combine(this.AppsDumpDirectory, string.Format(CultureInfo.InvariantCulture, Strings.AppsDuSummary, tsig));
            string details_file = Path.Combine(this.AppsDumpDirectory, string.Format(CultureInfo.InvariantCulture, Strings.AppsDuDetails, tsig));

            // todo: vladi: removed max depth level (6) from call
            DiskUsage.WriteDiskUsageToFile(summary_file, appsDirectory, true);
            DiskUsage.WriteDiskUsageToFile(details_file, appsDirectory, false);
        }
Пример #9
0
 public AntdDiskUsageModule()
 {
     Get["/diskusage"] = x => {
         var diskUsage = new DiskUsage();
         var model     = new PageDiskUsageModel {
             DisksUsage = diskUsage.GetInfo()
         };
         return(JsonConvert.SerializeObject(model));
     };
 }
Пример #10
0
        public static DiskUsage ToDiskUsage(this AccountInfoResult data)
        {
            var res = new DiskUsage
            {
                Total     = data.body.cloud.space.total * 1024 * 1024,
                Used      = data.body.cloud.space.used * 1024 * 1024,
                OverQuota = data.body.cloud.space.overquota
            };

            return(res);
        }
Пример #11
0
        public void TestC(DiskUsage c)
        {
            Assert.Equal(CCapacity.ToString(), c.Capacity);
            Assert.Equal(CFree.ToString(), c.Free);
            Assert.Equal(CUsed.ToString(), c.Used);
            Assert.Equal(CCapacity, c.CapacityNum);
            Assert.Equal(CFree, c.FreeNum);
            Assert.Equal(CUsed, c.UsedNum);

            // Make sure the math didn't get messed up somehow
            Assert.Equal(CCapacity - CFree, c.UsedNum);
        }
Пример #12
0
        public void TestE(DiskUsage e)
        {
            Assert.Equal(ECapacity.ToString(), e.Capacity);
            Assert.Equal(EFree.ToString(), e.Free);
            Assert.Equal(EUsed.ToString(), e.Used);
            Assert.Equal(ECapacity, e.CapacityNum);
            Assert.Equal(EFree, e.FreeNum);
            Assert.Equal(EUsed, e.UsedNum);

            // Make sure the math didn't get messed up somehow
            Assert.Equal(ECapacity - EFree, e.UsedNum);
        }
Пример #13
0
        public void ProperlySeeNoFDrive()
        {
            var definition = new { Value = new Dictionary <string, DiskUsage>() };
            var value      = JsonConvert.DeserializeAnonymousType(_fixture.Value, definition);
            Dictionary <string, DiskUsage> map = value.Value;

            Assert.Equal(2, map.Count);
            DiskUsage f = null;

            Assert.False(map.TryGetValue("F:", out f));
            Assert.Null(f);
        }
Пример #14
0
        public ChartDialogForm(DiskUsage dataStore, SortingOption initialSort)
        {
            InitializeComponent();

            if (dataStore != null)
            {
                diskChart.AssignData(dataStore, initialSort);

                sortingCombo.AddEnumDescriptionItems(new SortingOption(), (int)initialSort);
            }

            displayModeCombo.SelectedIndex = 0;
        }
Пример #15
0
        public void ConstructFromUInt64Properly()
        {
            DiskUsage c = new DiskUsage()
            {
                CapacityNum = _fixture.CCapacity, FreeNum = _fixture.CFree
            };
            DiskUsage e = new DiskUsage()
            {
                CapacityNum = _fixture.ECapacity, FreeNum = _fixture.EFree
            };

            _fixture.TestC(c);
            _fixture.TestE(e);
        }
Пример #16
0
        public void ConstructFromStringsProperly()
        {
            DiskUsage c = new DiskUsage()
            {
                Capacity = _fixture.CCapacity.ToString(), Free = _fixture.CFree.ToString()
            };
            DiskUsage e = new DiskUsage()
            {
                Capacity = _fixture.ECapacity.ToString(), Free = _fixture.EFree.ToString()
            };

            _fixture.TestC(c);
            _fixture.TestE(e);
        }
        public NotificationAreaForm()
        {
            InitializeComponent();
            PositionForm();
            _core = new DiskUsage();

            HideForm(_core.SettingsFileWasGenerated);

            orderByCombo.AddEnumDescriptionItems(new SortingOption(), ComboIndex);

            //do an update now
            _core.RequestUpdateFromAll();
            NotificationTime          = DateTime.Now.AddSeconds(10);
            notificationTimer.Enabled = true;
        }
        public DiskUsage ComputeUsedSpace(Dictionary <string, FileInfo> files)
        {
            var du = new DiskUsage()
            {
                TotalSize = base.MaxByte
            };

            foreach (var f in files)
            {
                du.TotalUsed += f.Value.Length;
            }
            du.TotalSectorUsed = (FAT_END_ADDR + du.TotalUsed) / PAGE_SIZE;
            du.RemainingFree   = base.MaxByte - du.TotalSectorUsed;
            return(du);
        }
        public DiskUsage ComputeUsedSpace()
        {
            var du = new DiskUsage()
            {
                TotalSize = GetFATWriterReader().DiskMaxByte
            };

            du.FileCount = this.FileInfos.Count;
            foreach (var f in this.FileInfos)
            {
                du.TotalUsed += f.Length;
            }
            du.TotalSectorUsed = (FAT_END_ADDR + du.TotalUsed) / GetFATWriterReader().SectorSize;
            du.RemainingFree   = GetFATWriterReader().DiskMaxByte - du.TotalUsed;
            return(du);
        }
Пример #20
0
        public DiskUsage ComputeUsedSpace()
        {
            var du = new DiskUsage()
            {
                TotalSize = base.MaxByte
            };

            du.FileCount = this.FileInfos.Count;
            foreach (var f in this.FileInfos)
            {
                du.TotalUsed += f.Length;
            }
            du.TotalSectorUsed = (FAT_END_ADDR + du.TotalUsed) / PAGE_SIZE;
            du.RemainingFree   = base.MaxByte - du.TotalUsed;
            return(du);
        }
Пример #21
0
        public void SeeCorrectValuesInCAndEDrives()
        {
            var definition = new { Value = new Dictionary <string, DiskUsage>() };
            var value      = JsonConvert.DeserializeAnonymousType(_fixture.Value, definition);
            Dictionary <string, DiskUsage> map = value.Value;

            DiskUsage c = null;

            Assert.True(map.TryGetValue("C:", out c));
            DiskUsage e = null;

            Assert.True(map.TryGetValue("E:", out e));

            _fixture.TestC(c);
            _fixture.TestE(e);
        }
Пример #22
0
        public void ProperlyReadCAndEDrives()
        {
            var definition = new { Value = new Dictionary <string, DiskUsage>() };
            var value      = JsonConvert.DeserializeAnonymousType(_fixture.Value, definition);
            Dictionary <string, DiskUsage> map = value.Value;

            Assert.Equal(2, map.Count);
            DiskUsage c = null;

            Assert.True(map.TryGetValue("C:", out c));
            DiskUsage e = null;

            Assert.True(map.TryGetValue("E:", out e));
            Assert.NotNull(c);
            Assert.NotNull(e);
        }
Пример #23
0
        void Check()
        {
            float readSpeed;
            float writeSpeed;

            try
            {
                readSpeed  = m_ReadSpeedCounter.Read();
                writeSpeed = m_WriteSpeedCounter.Read();
            }
            catch (InvalidOperationException e)
            {
                m_Log.Warn(e, $"Could not determine disk usage of {InstanceName}. Maybe you closed the application?. Please restart the application '{InstanceName}'.");
                DiskUsage.OnNext(DiskUsageEventArgs.Zero);
                return;
            }
            DiskUsage.OnNext(new DiskUsageEventArgs(readSpeed, writeSpeed));
        }
Пример #24
0
        /// <inheritdoc/>
        public override async Task ObserveAsync(CancellationToken token)
        {
            bool initialized = this.Initialize();

            this.Token = token;

            if (!initialized || token.IsCancellationRequested)
            {
                this.Token.ThrowIfCancellationRequested();

                this.HealthReporter.ReportFabricObserverServiceHealth(
                    this.FabricServiceContext.ServiceName.OriginalString,
                    this.ObserverName,
                    HealthState.Warning,
                    "This observer was unable to initialize correctly due to missing configuration info...");

                return;
            }

            try
            {
                this.perfCounters = new WindowsPerfCounters();
                this.diskUsage    = new DiskUsage();

                foreach (var app in this.targetList)
                {
                    this.Token.ThrowIfCancellationRequested();

                    await this.MonitorAppAsync(app).ConfigureAwait(true);
                }

                await this.ReportAsync(token).ConfigureAwait(true);

                this.LastRunDateTime = DateTime.Now;
            }
            finally
            {
                // Clean up...
                this.diskUsage?.Dispose();
                this.diskUsage = null;
                this.perfCounters?.Dispose();
                this.perfCounters = null;
            }
        }
Пример #25
0
 public override void DoJob()
 {
     try {
         var pk            = Encoding.ASCII.GetString(_asymmetricKeys.PublicKey);
         var internalIp    = "";
         var externalIp    = WhatIsMyIp.Get();
         var ut            = MachineInfo.GetUptime();
         var uptime        = ut.Uptime;
         var loadAverage   = ut.LoadAverage;
         var du            = new DiskUsage().GetInfo().FirstOrDefault(_ => _.MountedOn == "/mnt/cdrom");
         var diskUsage     = du?.UsePercentage;
         var hostnamectl   = CommandLauncher.Launch("hostnamectl").ToList();
         var hostname      = hostnamectl.First(_ => _.Contains("Static hostname:")).Split(new[] { ":" }, 2, StringSplitOptions.RemoveEmptyEntries)[1];
         var antdVersion   = GetVersionDateFromFile(Bash.Execute("file /mnt/cdrom/Apps/Anthilla_Antd/active-version"));
         var systemVersion = GetVersionDateFromFile(Bash.Execute("file /mnt/cdrom/System/active-system"));
         var kernelVersion = GetVersionDateFromFile(Bash.Execute("file /mnt/cdrom/Kernel/active-kernel"));
         var dict          = new Dictionary <string, string> {
             { "AppName", "Antd" },
             { "PartNumber", _machineId.PartNumber },
             { "SerialNumber", _machineId.SerialNumber },
             { "Uid", _machineId.MachineUid },
             { "KeyValue", pk },
             { "InternalIp", internalIp },
             { "ExternalIp", externalIp },
             { "Uptime", uptime },
             { "DiskUsage", diskUsage },
             { "LoadAverage", loadAverage },
             { "Hostname", hostname },
             { "AntdVersion", antdVersion },
             { "SystemVersion", systemVersion },
             { "KernelVersion", kernelVersion }
         };
         if (Parameter.Cloud.Contains("localhost"))
         {
             return;
         }
         _api.Post($"{Parameter.Cloud}repo/assetinfo/save", dict);
         //ConsoleLogger.Log($"[cloud-uptime] info sent to cloud - data gathered in {DateTime.Now - dtnow}");
     }
     catch (Exception ex) {
         //ConsoleLogger.Error(ex.Message);
     }
 }
Пример #26
0
        protected override void Dispose(bool disposing)
        {
            if (this.disposed || !disposing)
            {
                return;
            }

            if (this.perfCounters != null)
            {
                this.perfCounters.Dispose();
                this.perfCounters = null;
            }

            if (this.diskUsage != null)
            {
                this.diskUsage.Dispose();
                this.diskUsage = null;
            }

            this.disposed = true;
        }
Пример #27
0
        public void CreateAndAddPath()
        {
            var list = new DiskUsage(saveToDisk: false);

            Assert.AreEqual(0, list.Paths.Count);

            list.AddPathToList("C:\\", "C");

            Assert.AreEqual(1, list.Paths.Count);

            //dont add duplicates

            list.AddPathToList("C:\\", "C");

            Assert.AreEqual(1, list.Paths.Count);

            //now remove

            list.RemovePathFromList("C:\\");

            Assert.AreEqual(0, list.Paths.Count);
        }
Пример #28
0
        public void SerializeToStringProperly()
        {
            DiskUsage c = new DiskUsage()
            {
                CapacityNum = _fixture.CCapacity, FreeNum = _fixture.CFree
            };
            DiskUsage e = new DiskUsage()
            {
                CapacityNum = _fixture.ECapacity, FreeNum = _fixture.EFree
            };
            Dictionary <string, DiskUsage> m = new Dictionary <string, DiskUsage>();

            m["C:"] = c;
            m["E:"] = e;
            var value = new { Value = m };

            string serialized = JsonConvert.SerializeObject(value, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings {
                StringEscapeHandling = StringEscapeHandling.EscapeHtml
            });

            Assert.Equal(_fixture.Value, serialized);
        }
Пример #29
0
        public void CheckLocation()
        {
            var list = new DiskUsage(saveToDisk: false);

            var local = new PathRecord {
                FriendlyName = "F", Path = "F:\\"
            };

            Assert.AreEqual(PathLocation.Local, local.Location());

            var remote = new PathRecord {
                FriendlyName = "Share", Path = "\\\\Server\\Share"
            };

            Assert.AreEqual(PathLocation.Remote, remote.Location());

            var os = new PathRecord {
                FriendlyName = "OS Disk", Path = $"{Windows.InstallDirectory}"
            };

            Assert.AreEqual(PathLocation.Os, os.Location());
        }
Пример #30
0
        // Windows process dmp creator.
        internal bool DumpServiceProcess(int processId, DumpType dumpType = DumpType.Full)
        {
            if (string.IsNullOrEmpty(this.dumpsPath))
            {
                return(false);
            }

            string processName = string.Empty;

            NativeMethods.MINIDUMP_TYPE miniDumpType;

            switch (dumpType)
            {
            case DumpType.Full:
                miniDumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemory |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithHandleData |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithUnloadedModules;
                break;

            case DumpType.MiniPlus:
                miniDumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithPrivateReadWriteMemory |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithDataSegs |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithHandleData |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpWithUnloadedModules;
                break;

            case DumpType.Mini:
                miniDumpType = NativeMethods.MINIDUMP_TYPE.MiniDumpWithIndirectlyReferencedMemory |
                               NativeMethods.MINIDUMP_TYPE.MiniDumpScanMemory;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(dumpType), dumpType, null);
            }

            try
            {
                // This is to ensure friendly-name of resulting dmp file.
                processName = Process.GetProcessById(processId).ProcessName;

                if (string.IsNullOrEmpty(processName))
                {
                    return(false);
                }

                IntPtr processHandle = Process.GetProcessById(processId).Handle;

                processName += "_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".dmp";

                // Check disk space availability before writing dump file.
                using (var diskUsage = new DiskUsage(this.dumpsPath.Substring(0, 1)))
                {
                    if (diskUsage.PercentUsedSpace >= 90)
                    {
                        this.HealthReporter.ReportFabricObserverServiceHealth(
                            this.FabricServiceContext.ServiceName.OriginalString,
                            this.ObserverName,
                            HealthState.Warning,
                            "Not enough disk space available for dump file creation.");
                        return(false);
                    }
                }

                using (var file = File.Create(Path.Combine(this.dumpsPath, processName)))
                {
                    if (!NativeMethods.MiniDumpWriteDump(
                            processHandle,
                            (uint)processId,
                            file.SafeFileHandle,
                            miniDumpType,
                            IntPtr.Zero,
                            IntPtr.Zero,
                            IntPtr.Zero))
                    {
                        throw new Win32Exception(Marshal.GetLastWin32Error());
                    }
                }

                return(true);
            }
            catch (Exception e) when(e is ArgumentException || e is InvalidOperationException || e is Win32Exception)
            {
                this.ObserverLogger.LogInfo(
                    $"Unable to generate dump file {processName} with error{Environment.NewLine}{e}");
            }

            return(false);
        }