Beispiel #1
0
        protected override IEnumerable <string> CheckupCore()
        {
            var checkupItems = new Collection <string>();

            var processesToMonitor = Configuration["processes-to-monitor"].Count();

            for (var i = 0; i < processesToMonitor; i++)
            {
                var processName = Configuration["processes-to-monitor"][i]["name"].Value <string>();
                var maxSizeMb   = Configuration["processes-to-monitor"][i]["max-size-mb"].Value <string>();
                var processAboveMaxException = Configuration["process-above-max-exception-html"].Value <string>();
                var processNotFoundException = Configuration["process-not-found-exception-html"].Value <string>();

                var processes = Process.GetProcessesByName(processName);

                foreach (var process in processes)
                {
                    if ((process.WorkingSet64 / 1000000) > double.Parse(maxSizeMb))
                    {
                        checkupItems.Add(processAboveMaxException.Replace("[PROCESS-NAME]", process.ProcessName)
                                         .Replace("[PROCESS-MEMORY]", MiteHelper.GetSize(Convert.ToInt64(process.WorkingSet64)))
                                         .Replace("[PROCESS-MAX-MEMORY]", maxSizeMb));
                    }
                }

                if (processes.Length == 0)
                {
                    checkupItems.Add(processNotFoundException.Replace("[PROCESS-NAME]", processName));
                }
            }

            return(checkupItems);
        }
Beispiel #2
0
        protected override IEnumerable <string> HeartbeatCore()
        {
            var heartbeatItems = new Collection <string>();

            var computerInfo = new ComputerInfo();

            heartbeatItems.Add(Configuration["system-memory-heartbeat-html"].Value <string>()
                               .Replace("[COMPUTER-NAME]", Environment.MachineName).Replace(
                                   "[COMPUTER-MEMORY-FREE]",
                                   MiteHelper.GetSize((long)computerInfo.AvailablePhysicalMemory)));

            return(heartbeatItems);
        }
Beispiel #3
0
        protected override IEnumerable <string> CheckupCore()
        {
            var checkupItems = new Collection <string>();

            var computerInfo = new ComputerInfo();

            if (computerInfo.AvailablePhysicalMemory / 1000000000 <
                double.Parse(Configuration[$"system-memory"]["min-size-gb"].Value <string>()))
            {
                checkupItems.Add(Configuration["system-memory-below-min-exception-html"].Value <string>()
                                 .Replace("[COMPUTER-NAME]", Environment.MachineName).Replace(
                                     "[COMPUTER-MEMORY-FREE]",
                                     MiteHelper.GetSize((long)computerInfo.AvailablePhysicalMemory))
                                 .Replace("[COMPUTER-MIN-MEMORY-FREE]",
                                          Configuration[$"system-memory"]["min-size-gb"].Value <string>()));
            }

            return(checkupItems);
        }
Beispiel #4
0
        protected override bool CustomActionCore(string customAction)
        {
            var usedCustomAction = false;

            if (customAction == "-listprocesses")
            {
                usedCustomAction = true;
                var processes = Process.GetProcesses();

                foreach (var process in processes)
                {
                    Console.WriteLine(Configuration["list-process-text"].Value <string>()
                                      .Replace("[PROCESS-NAME]", process.ProcessName)
                                      .Replace("[PROCESS-MEMORY]", MiteHelper.GetSize(process.WorkingSet64)));
                }
            }

            return(usedCustomAction);
        }
Beispiel #5
0
        protected override IEnumerable <string> HeartbeatCore()
        {
            var heartbeatItems = new Collection <string>();

            foreach (var process in GetMonitoredProcesses())
            {
                try
                {
                    heartbeatItems.Add(Configuration["process-heartbeat-html"].Value <string>()
                                       .Replace("[PROCESS-NAME]", process.ProcessName)
                                       .Replace("[PROCESS-MEMORY]", MiteHelper.GetSize(process.WorkingSet64)));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            return(heartbeatItems);
        }
Beispiel #6
0
        private IEnumerable <string> GetDrivesWithLowDiskSpace()
        {
            var lowSpaceDrives = new Collection <string>();

            // Drives Checkup
            foreach (var drive in GetMonitoredDrives())
            {
                try
                {
                    var drivesToMonitorCount = Configuration["drives-to-monitor"].Count();
                    for (var i = 0; i < drivesToMonitorCount; i++)
                    {
                        var driveName          = Configuration[$"drives-to-monitor"][i]["name"].Value <string>();
                        var minSizeGb          = Configuration[$"drives-to-monitor"][i]["min-size-gb"].Value <string>();
                        var minSizeGbException = Configuration["drive-below-min-exception-html"].Value <string>();

                        if (drive.Name == driveName)
                        {
                            if (drive.AvailableFreeSpace / 1000000000 < double.Parse(minSizeGb))
                            {
                                lowSpaceDrives.Add(minSizeGbException.Replace("[DRIVE-NAME]", driveName)
                                                   .Replace("[DRIVE-FREE-SPACE]",
                                                            MiteHelper.GetSize(Convert.ToInt64(drive.TotalFreeSpace)))
                                                   .Replace("[DRIVE-MIN-FREE-SPACE]", minSizeGb));
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            return(lowSpaceDrives);
        }
Beispiel #7
0
 private void ListDrives()
 {
     foreach (var drive in DriveInfo.GetDrives())
     {
         try
         {
             if (drive.TotalSize > 0 && drive.TotalFreeSpace > 0 && drive.DriveType == DriveType.Fixed)
             {
                 Console.WriteLine(Configuration["list-drive-console-text"].Value <string>()
                                   .Replace("[DRIVE-NAME]", drive.Name).Replace("[DRIVE-FREE-SPACE]",
                                                                                MiteHelper.GetSize(Convert.ToInt64(drive.TotalFreeSpace))));
             }
         }
         catch
         {
             //Eat Exception
         }
     }
 }
Beispiel #8
0
        protected override IEnumerable <string> HeartbeatCore()
        {
            var heartbeatItems = new Collection <string>();

            foreach (var drive in GetMonitoredDrives())
            {
                try
                {
                    if (drive.TotalSize > 0 && drive.TotalFreeSpace > 0 && drive.DriveType == DriveType.Fixed)
                    {
                        heartbeatItems.Add(Configuration["drive-heartbeat-html"].Value <string>()
                                           .Replace("[DRIVE-NAME]", drive.Name).Replace("[DRIVE-FREE-SPACE]",
                                                                                        MiteHelper.GetSize(Convert.ToInt64(drive.TotalFreeSpace))));
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            return(heartbeatItems);
        }