SiddiqSoft.WinProcessInfo
1.0.4
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SiddiqSoft.WinProcessInfo --version 1.0.4
NuGet\Install-Package SiddiqSoft.WinProcessInfo -Version 1.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SiddiqSoft.WinProcessInfo" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SiddiqSoft.WinProcessInfo --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SiddiqSoft.WinProcessInfo, 1.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SiddiqSoft.WinProcessInfo as a Cake Addin #addin nuget:?package=SiddiqSoft.WinProcessInfo&version=1.0.4 // Install SiddiqSoft.WinProcessInfo as a Cake Tool #tool nuget:?package=SiddiqSoft.WinProcessInfo&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WinProcessInfo : Sample Windows process information
Objective
Provide for a simple "stats" for a daemon/service without the heft of the full process information library.
- Minimal footprint
- Serializer for nlohmann::json (you must include the library prior to this header file)
- Serializer for std::format (if supported by your compiler)
Requirements
- We use
nlohmann::json
only in our tests and the library is aware to provide a conversion operator if library is detected. - We use
std::format
if present
Usage
- Use the nuget SiddiqSoft.WinProcessInfo
- Copy paste..whatever works.
Interface
WinProcessInfo
- uptime()
- snapshot()
- serializer for nlohmann::json
- serializer for std::format
Example
#include "gtest/gtest.h"
#include <format>
#include "nlohmann/json.hpp"
#include "siddiqsoft/WinProcessInfo.hpp"
TEST(examples, Example2)
{
try {
siddiqsoft::WinProcessInfo procInfo;
// We must perform the snapshot to obtain memory and thread usage
procInfo.snapshot();
// tip: do not use brace-init/assignment as it will create an array instead of object!
nlohmann::json info(procInfo);
std::cerr << info.dump() << std::endl;
EXPECT_EQ(GetCurrentProcessId(), info.value("processId", 0));
}
catch (std::exception& e) {
EXPECT_TRUE(false) << e.what(); // if we throw then the test fails.
}
}
Output
Member Field | json Field | Comments |
---|---|---|
cpuCores | cpuCount |
Number of cores/cpu |
cpuHandles | cpuHandles |
Handle count |
cpuThreads | cpuThreads |
Thread count. This is expensive. |
memPeakWorkingSet | memPeakWorkingSet |
Peak virtual working memory in Kbytes. |
memWorkingSet | memWorkingSet |
Current working set in Kbytes. |
memPrivate | memPrivate |
Current physically allocated memory for this process in Kbytes. |
nameHostname | hostname |
The local hostname |
nameDomainName | domain |
The fully qualified domain portion |
nameHostnamePhysical | localFqdn |
The local physical hostname |
nameFqdn | fqdn |
The fully qualified dns name |
processId | processId |
The process id |
timeStartup | timeStartup |
The startup timestamp as ISO 8601 format. This is the time of instance of this object. |
timeCurrent |
The current timestamp as ISO 8601 format when the serialization took place. | |
uptime |
The number of microseconds between the timeStartup and timeCurrent .<br/>Use the method uptime() and duration_cast<> to your desired ratio. |
{
"cpuCores": 8,
"cpuHandles": 48,
"cpuThreads": 4,
"domain": "",
"fqdn": "istanbul",
"hostname": "istanbul",
"localFqdn": "istanbul",
"memPeakWorkingSet": 42960, // KBytes
"memPrivateBytes": 84452, // Kbytes
"memWorkingSet": 42584, // Kbytes
"processId": 10828,
"timeCurrent": "2021-07-30T06:43:54.8649027Z",
"timeStartup": "2021-07-30T06:43:54.8599558Z",
"uptime": 5124 // Microseconds
}
<small align="right">
© 2021 Siddiq Software LLC. All rights reserved.
</small>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
native | native is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.