Add usage more than 80
This commit is contained in:
+7
-1
@@ -1,8 +1,14 @@
|
|||||||
# Ignore all .log files
|
# Ignore all .log files
|
||||||
*.log
|
*.log
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
# Ignore the node_modules directory
|
# Ignore the node_modules directory
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# Ignore all files in the temp directory
|
# Ignore all files in the temp directory
|
||||||
temp/
|
temp/
|
||||||
|
|
||||||
|
/bin/
|
||||||
|
/obj/
|
||||||
|
/publish/publish/
|
||||||
|
|
||||||
|
|||||||
@@ -66,12 +66,47 @@ namespace ResourceMonitorService
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetCpuUsage()
|
private object GetCpuUsage()
|
||||||
{
|
{
|
||||||
var cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
|
var cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
|
||||||
cpuCounter.NextValue();
|
cpuCounter.NextValue();
|
||||||
Thread.Sleep(1000); // Wait a second to get a valid reading
|
Thread.Sleep(1000); // Wait a second to get a valid reading
|
||||||
return cpuCounter.NextValue();
|
|
||||||
|
var usage = cpuCounter.NextValue();
|
||||||
|
if (usage > 80)
|
||||||
|
{
|
||||||
|
// Get the current processes and sort them by CPU usage in descending order
|
||||||
|
var processes = Process.GetProcesses().OrderByDescending(p => p.TotalProcessorTime);
|
||||||
|
|
||||||
|
// Create a new anonymous type containing the CPU usage, RAM usage, and the top 3 highest CPU-using processes
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
Usage = usage,
|
||||||
|
Process1 = new
|
||||||
|
{
|
||||||
|
Name = processes.ElementAt(0).ProcessName,
|
||||||
|
TotalProcessorTime = processes.ElementAt(0).TotalProcessorTime,
|
||||||
|
WorkingSet64 = processes.ElementAt(0).WorkingSet64 / (1024 * 1024) // Convert to MB
|
||||||
|
},
|
||||||
|
Process2 = new
|
||||||
|
{
|
||||||
|
Name = processes.ElementAt(1).ProcessName,
|
||||||
|
TotalProcessorTime = processes.ElementAt(1).TotalProcessorTime,
|
||||||
|
WorkingSet64 = processes.ElementAt(1).WorkingSet64 / (1024 * 1024) // Convert to MB
|
||||||
|
},
|
||||||
|
Process3 = new
|
||||||
|
{
|
||||||
|
Name = processes.ElementAt(2).ProcessName,
|
||||||
|
TotalProcessorTime = processes.ElementAt(2).TotalProcessorTime,
|
||||||
|
WorkingSet64 = processes.ElementAt(2).WorkingSet64 / (1024 * 1024) // Convert to MB
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
Usage = usage
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetRamUsage()
|
private float GetRamUsage()
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://localhost:5000"
|
"Url": "http://*:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://localhost:5000"
|
"Url": "http://*:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:5000"
|
"Url": "http://localhost:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:5000"
|
"Url": "http://localhost:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f16578d19a39c4688f17fdac49af6472a49fec57")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7dc90104512834ceb810324f20a2b5d12de354c0")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyProductAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
50d6f72955ce0876a69442b6c335ff08ea368766fc97b2037cc37144294afbbe
|
1212cb7eab016db3876a66a85bc18562ffabead52c3b48120f48f729d68cf190
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\
|
|||||||
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
D:\din\dev\vmsvc\ResourceMonitorService\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f16578d19a39c4688f17fdac49af6472a49fec57")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7dc90104512834ceb810324f20a2b5d12de354c0")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyProductAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
775fabb90a6c4c2ade72fe6bb97d7187c0bca0ffc636f7a7f1f46fc245002ac5
|
608e465b7ba84317d117e2f91b1dd0cbc27eb989794e186fbb1d28e072618ae2
|
||||||
|
|||||||
@@ -62,3 +62,11 @@ D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publi
|
|||||||
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Release\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,10 +1,8 @@
|
|||||||
# PowerShell script to create a new inbound rule in Windows Firewall
|
# PowerShell script to create a new inbound rule in Windows Firewall
|
||||||
|
|
||||||
# Define the port number
|
|
||||||
$port = 5000
|
$port = 5000
|
||||||
|
|
||||||
# Define the rule name
|
|
||||||
$ruleName = "ResourceMonitorService"
|
$ruleName = "ResourceMonitorService"
|
||||||
|
if (Get-NetFirewallRule -DisplayName $ruleName) {
|
||||||
# Create a new inbound rule
|
Write-Host "Rule already exists, not creating a new one"
|
||||||
New-NetFirewallRule -DisplayName $ruleName -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow -Profile Any
|
} else {
|
||||||
|
New-NetFirewallRule -DisplayName $ruleName -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow -Profile Any
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://localhost:5000"
|
"Url": "http://*:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://localhost:5000"
|
"Url": "http://*:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:5000"
|
"Url": "http://localhost:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:5000"
|
"Url": "http://localhost:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user