Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ffiirree/probe

Hardware and OS information for C++
https://github.com/ffiirree/probe

cpu-info disk-info graphics-info hardware-info media-info network-info system-info

Last synced: 5 days ago
JSON representation

Hardware and OS information for C++

Awesome Lists containing this project

README

        

Porbe


Hardware and OS information library for C++

## Usage

**Probe** contains several modules to probe the *hardware & software information*, including `system`, `cpu`, `graphics`, `process`, `network`, `disk`, `media device` and so on, it is simple to use like:

```C++
#include "probe/system.h"

#include "probe/memory.h"
#include "probe/util.h"

#include

int main()
{
const auto mem = probe::memory::status();

std::cout << "Operating System:\n"
<< " System Name : " << probe::system::name() << '\n'
<< " System Version : " << probe::to_string(probe::system::version()) << '\n'
<< " Kernel Name : " << probe::system::kernel::name() << '\n'
<< " Kernel Version : " << probe::to_string(probe::system::kernel::version()) << '\n'
<< " Device Name : " << probe::system::hostname() << '\n'
<< " Theme : " << probe::to_string(probe::system::theme()) << '\n'
<< " Desktop ENV : " << probe::to_string(probe::system::desktop_environment()) << " ("
<< probe::to_string(probe::system::desktop_environment_version()) << ")\n"
<< " Windowing System : " << probe::to_string(probe::system::windowing_system()) << '\n'
<< " Memory : " << probe::util::GB(mem.avail) << " / "
<< probe::util::GB(mem.total) << " GB\n";
return 0;
}
```

Output:

```yaml
Operating System: Operating System:
System Name : Windows 11 Pro | System Name : Ubuntu 22.04.3 LTS
System Version : 10.0.26058-1000 (24H2) | System Version : 22.4.3 (jammy)
Kernel Name : Windows NT | Kernel Name : Linux
Kernel Version : 10.0.26058-1000 | Kernel Version : 6.5.0-18 (generic)
Device Name : EVA-0 | Device Name : EVA-2204
Theme : dark | Theme : light
Desktop ENV : Windows Shell (10.0.26058-1000 (24H2)) | Desktop ENV : GNOME (42.9.0)
Windowing System : Desktop Window Manager | Windowing System : X11
Memory : 4.62131 / 31.9358 GB | Memory : 11.8134 / 15.5742 GB
```

## Details

### System

| properties | Windows | Linux | commments |
| ------------------- | :----------------: | :------------: | -------------------------------------------- |
| os name | ✔ | ✔ | Windows 11 Pro |
| os version | ✔ | ✔ | 10.0.25346.1001(22H2) |
| kernel name | ✔ | ✔ | Windows NT |
| kernel version | ✔ | ✔ | 10.0.25346.1001 |
| hostname | ✔ | ✔ | Device Name/Computer Name |
| username | ✔ | ✔ | Name of Current User |
| dark/light mode | ✔ | `Ubuntu 22.04` | dark |
| desktop environment | `Windows Shell` | ✔ | GNOME / Unity / Cinnamon / KDE / Xfce / MATE |
| DE version | same as os version | ✔ | GNOME (3.28.2.0) / Unity / Cinnamon / KDE |
| windowing system | `DWM` | ✔ | DWM / X11 / Wayland |
| memory | ✔ | ✔ | 15.29 / 31.94 GB |

### CPU

| properties | Windows | Linux | commments |
| -------------- | :------: | :------: | ---------------------------------------- |
| name | ✔ | ✔ | Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz |
| vendor | ✔ | ✔ | GenuineIntel |
| sockets | ✔ | ✔ | 1 |
| cores | ✔ | ✔ | 8 |
| logical cores | ✔ | ✔ | 8 |
| base frequency | ✔ | ✔ | 3.6 GHz |
| architecture | ✔ | ✔ | x64 |
| endianness | ✔ | ✔ | little |
| CPUID/features | ✔ | ✔ | check features of CPU by cpuid |
| L1 Data cache | ✔ | ✔ | 8 x 32 KB |
| L1 Inst. cache | ✔ | ✔ | 8 x 32 KB |
| L2 cache | ✔ | ✔ | 8 x 256 KB |
| L3 cache | ✔ | ✔ | 12 MB |

### Graphics

#### GPU

| properties | Windows | Linux | commments |
| ---------------- | :------: | :------: | ----------------------- |
| name | ✔ | ✔ | NVIDIA GeForce RTX 2080 |
| vendor | ✔ | ✔ | NVIDIA Corporation |
| dedicated memory | ✔ | | 8390705152 B |
| shared memory | ✔ | | 17146988544 B |
| frequency | | | |

#### Display Monitor

| properties | Windows | Linux | commments |
| ------------- | :-----------------: | :----------: | -------------- |
| name | ✔ | ✔ | "AOC2790" |
| id | ✔ | same as name | "\\.\DISPLAY1" |
| primary | ✔ | ✔ | true / false |
| position | ✔ | ✔ | (-2560, -1440) |
| resolution | ✔ | ✔ | 2560 x 1440 |
| refresh rate | ✔ | ✔ | 59.9 Hz |
| BPP | ✔ | ✔ | 32 |
| logical DPI | `>=Windows 10 1607` | ✔ | 96 |
| scale factor | ✔ | | 125% |
| orientation | ✔ | ✔ | Landscape |
| physical size | ✔ | | 60 x 34 cm |
| physical DPI | ✔ | | 108 |

##### Virtual Screen

> the desktop containing all displays

| properties | Windows | Linux | commments |
| ---------- | :------: | :------: | -------------- |
| position | ✔ | ✔ | (-1920, -1080) |
| resolution | ✔ | ✔ | 4480 x 2520 |

> The position of the display can be negative on windows since the primary display always start at (0, 0)

#### Window List

> Z-order: up to down

| properties | Windows | Linux | commments |
| -------------- | :------: | :------: | ---------------------------------------- |
| name | ✔ | ✔ | "README.md - probe - Visual Studio Code" |
| classname | ✔ | ✔ | "Chrome_WidgetWin_1" |
| geometry | ✔ | ✔ | (741, 328), 1568 x 995 |
| navtive handle | ✔ | ✔ | Windows: `HWND`, Linux: `Window` |
| parent handle | ✔ | ✔ | |
| visible | ✔ | ✔ | true / false |
| process id | ✔ | ✔ | |
| process name | ✔ | ✔ | explorer.exe |

### Disk

> Run as Administrator

| properties | Windows | Linux | commments |
| ---------------- | :------: | :------: | ------------------------------------------------------------------------------------------- |
| name | ✔ | ✔ | \\\\.\\PhysicalDrive2 |
| path | ✔ | ✔ | \\\\?\\scsi#disk&ven_phi&prod_h1#6&314c6ca8&0&000000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b} |
| serial number | ✔ | ✔ | 98BB9969766F |
| GUID/signature | ✔ | | {C65630B2-E183-4363-9E18-93CE442B9515} (GPT) or 9BD1A50 (MBR) |
| vendor | ✔ | ✔ | Samsung |
| product | ✔ | ✔ | Samsung SSD 970 EVO Plus |
| bus type | ✔ | ✔ | SATA / NVMe / USB ... |
| removable | ✔ | | true / false |
| writable | ✔ | | true / false |
| trim | ✔ | | true / false |
| cylinders | ✔ | | 121601 |
| tracks/cylinders | ✔ | | 255 |
| sectors/track | ✔ | | 63 |
| bytes/sector | ✔ | | 512 |
| partitions | ✔ | | 6 |

#### Partition

| properties | Windows | Linux | commments |
| ---------- | :------: | :---: | -------------------------------------- |
| name | ✔ | | Microsoft reserved partition |
| style | ✔ | | GPT / MBR / RAW |
| type id | ✔ | | {E3C9E316-0B5C-4DB8-817D-F92DF00215AE} |
| GUID | ✔ | | {733189C5-6252-4F42-9577-151494026B2B} |
| offset | ✔ | | 17408 |
| length | ✔ | | 16759808 |

#### Volume

| properties | Windows | Linux | commments |
| ------------- | :------: | :---: | ----------------------------------------------------- |
| label | ✔ | | New Volume |
| letter | ✔ | | C:\\ |
| filesystem | ✔ | | NTFS |
| serial number | ✔ | | 10194AA9 |
| GUID path | ✔ | | \\\\?\\Volume{803b42f7-bbee-4d30-ad22-2d0fe90072b6}\\ |
| capacity | ✔ | | 1870.54 GB |
| free space | ✔ | | 105.929 GB |

### Audio Devices

| properties | Windows | Linux | commments |
| ----------- | :------: | :---: | ------------------------------------------------------- |
| name | ✔ | | Logi C310 HD WebCam |
| vendor | | | |
| id | ✔ | | {0.0.1.00000000}.{d6224b54-e7f7-49d9-ab10-b2071cb4eea5} |
| description | ✔ | | Microphone |
| type | ✔ | | AudioSource |
| state | ✔ | | Active |

### Process

| properties | Windows | Linux | commments |
| ---------- | :------: | :------: | ---------------------------- |
| pid | ✔ | ✔ | process id |
| ppid | ✔ | ✔ | pid of parent process |
| state | - | ✔ | R, S, D, Z, T, t, X |
| priority | ✔ | ✔ | |
| name | ✔ | ✔ | Win: "xxx.exe", Linux: "xxx" |
| path | ✔ | ✔ | "C:\path\to\file.exe" |
| cmdline | | ✔ | |
| starttime | ✔ | ✔ | unix time, ns |
| nb_threads | ✔ | ✔ | |
| user | ✔ | ✔ | username |

#### Thread

| properties | Windows | Linux | commments |
| ---------- | :------: | :------: | ---------------------- |
| name (get) | ✔ | ✔ | get name of the thread |
| name (set) | ✔ | ✔ | set name of the thread |

#### Linux

Parse the following files:

- /proc/uptime
- /proc/[pid]/exe
- /proc/[pid]/stat
- /proc/[pid]/status
- /proc/[pid]/statm
- /proc/[pid]/cmdline

### Network

| properties | Windows | Linux | commments |
| ---------------------- | :-------: | :------: | ----------------------------------------------------------------- |
| name | ✔ | ✔ | Windows: Intel(R) Ethernet Connection (7) I219-V; Linux: eno1 |
| vendor id | (PCI Bus) | ✔ | 0x0123 |
| product | (PCI Bus) | ✔ | Ethernet Connection (7) I219-V |
| guid | ✔ | - | {FFE7027E-6386-11EB-95F5-806E6F6E6963} |
| interface guid | ✔ | | {653D76BA-C95E-4A46-A3D6-A178841A7AC8} |
| description | ✔ | ✔ | Ethernet |
| manufacturer | ✔ | ✔ | Intel |
| enabled | | ✔ | true/false |
| bus | (PCI Bus) | ✔ | PCI / USB... |
| bus_info | (PCI Bus) | | |
| driver | ✔ | ✔ | |
| driver version | ✔ | ✔ | |
| virtual | ✔ | ✔ | true / false, **guessed** by physical address and the description |
| type | ✔ | ✔ | Ethernet / IEEE 802.11 / ... |
| physical address (MAC) | ✔ | ✔ | 00:50:56:C0:00:01 |
| DHCP Enabled | ✔ | | true |
| MTU | ✔ | ✔ | 1500 |
| ipv4_addresses | ✔ | ✔ | 192.168.189.1 |
| ipv6_addresses | ✔ | ✔ | fe80::22bc:b757:c253:a7c8 |
| dhcpv4_server | ✔ | | |
| dhcpv6_server | ✔ | | |
| ipv4_gateways | ✔ | | |
| ipv6_gateways | ✔ | | |
| dns_suffix | ✔ | | |
| ipv4_dns_servers | ✔ | | |
| ipv6_dns_servers | ✔ | | |

#### Traffic Statistics

| properties | Windows | Linux | commments |
| ---------------- | :------: | :---: | -------------- |
| guid | ✔ | | interface guid |
| ibytes | ✔ | | |
| obytes | ✔ | | |
| unicast ibytes | ✔ | | |
| unicast obytes | ✔ | | |
| broadcast ibytes | ✔ | | |
| broadcast obytes | ✔ | | |
| multicast ibytes | ✔ | | |
| multicast obytes | ✔ | | |

### Serial Ports

| properties | Windows | Linux | commments |
| ------------ | :------: | :---: | --------------------------- |
| name | ✔ | | Windows: COM1 |
| instance id | ✔ | | Windows: Device Instance ID |
| description | ✔ | | |
| manufacturer | ✔ | | |

### Utils

| functions | Windows | Linux | commments |
| --------- | :------: | :------: | ------------- |
| to_utf8 | ✔ | | wchar -> utf8 |
| to_utf16 | ✔ | | utf8 -> wchar |
| trim | ✔ | ✔ | trim string |

#### Windows

| functions / classes | commments |
| -------------------------- | ---------------------------------------- |
| registry::read | read value of the registry key |
| registry::RegistryListener | listen change events of the registry key |

#### Linux

| functions / classes | commments |
| -------------------- | -------------------------------------------------------------- |
| exec_sync | execute a commond and return the standard output |
| pipe_open/pipe_close | execute a commond and redirect the standard output to the pipe |
| PipeListener | listen the pipe of the the executed commond |
| gsettings functions | wrapper to gsettings commond |

### Compilation Requirement

- `C++ 20`
- `CMake >= 3.16`
- `Windows >= 10 1607`
- `Linux` : install `libxrandr-dev`

```bash
mkdir build && cd build
cmake .. -DPROBE_EXAMPLES=ON -DBUILD_SHARED_LIBS=ON
cmake --build . --config Release -j16
```