-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the project file and restore dependencies | ||
COPY *.csproj ./ | ||
RUN dotnet restore | ||
|
||
# Copy the remaining source code | ||
COPY . . | ||
|
||
# Build the project | ||
RUN dotnet build -c Release -o out | ||
|
||
# Run unit tests (if any) | ||
# RUN dotnet test | ||
|
||
# Publish the project | ||
RUN dotnet publish -c Release -o out | ||
|
||
# Build runtime image | ||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime | ||
WORKDIR /app | ||
COPY --from=build /app/out . | ||
ENTRYPOINT ["dotnet", "YourAppName.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace YourAppName | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
PrintSystemInfo(); | ||
} | ||
|
||
static void PrintSystemInfo() | ||
{ | ||
Console.WriteLine("System Information:"); | ||
Console.WriteLine("-------------------"); | ||
|
||
// Querying CPU information | ||
Console.WriteLine("CPU:"); | ||
int coreCount = Environment.ProcessorCount; | ||
Console.WriteLine($" Number of Cores: {coreCount}"); | ||
|
||
// Querying memory information | ||
Console.WriteLine("\nMemory:"); | ||
if (File.Exists("/proc/meminfo")) | ||
{ | ||
string[] lines = File.ReadAllLines("/proc/meminfo"); | ||
foreach (string line in lines) | ||
{ | ||
string[] parts = line.Split(':'); | ||
if (parts.Length == 2) | ||
{ | ||
string name = parts[0].Trim(); | ||
string value = parts[1].Trim(); | ||
|
||
if (name == "MemTotal" || name == "MemFree") | ||
{ | ||
long memoryKiB = long.Parse(value.Split(' ')[0]); | ||
double memoryMiB = memoryKiB / 1024.0; | ||
Console.WriteLine($" {name}: {memoryMiB:F2} MiB"); | ||
} | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Memory information retrieval is not supported on this platform."); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
docker build -t s50600822/cgroupcheck:csharp . | ||
docker run --cpus=2 --memory=512m s50600822/cgroupcheck:csharp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters