PHPackages                             danielme85/simple-server-info - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. danielme85/simple-server-info

ActiveLibrary[File &amp; Storage](/categories/file-storage)

danielme85/simple-server-info
=============================

A PHP 8.1+ library for reading server/system information from the Linux /proc virtual filesystem.

v2.1(4mo ago)7215MITPHPPHP &gt;=8.1CI passing

Since Sep 19Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/danielme85/simple-server-info)[ Packagist](https://packagist.org/packages/danielme85/simple-server-info)[ RSS](/packages/danielme85-simple-server-info/feed)WikiDiscussions main Synced 4d ago

READMEChangelog (4)Dependencies (2)Versions (8)Used By (0)

PHP Simple Server Info
======================

[](#php-simple-server-info)

[![GitHub](https://camo.githubusercontent.com/7123c32787e013be5a8a13598ad01f562754637ed6141e89b02e85bf16d3e63e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e7376673f7374796c653d666c61742d737175617265)](https://github.com/danielme85/simple-server-info)[![PHP from Packagist](https://camo.githubusercontent.com/b6910c7f7c60e7609a09b3b297880f6a829fcfece06d303c008ff20e53262853/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616e69656c6d6538352f73696d706c652d7365727665722d696e666f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielme85/simple-server-info)[![GitHub release](https://camo.githubusercontent.com/530a6ad932920a214020df25beeb7e8c15dad402eee9e39604fc97749f815bbf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f64616e69656c6d6538352f73696d706c652d7365727665722d696e666f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielme85/simple-server-info)[![GitHub tag](https://camo.githubusercontent.com/fd04013686f099d7f51c781e98343f1c88d5ba5a05cb10e71d880cc56edc9991/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f64616e69656c6d6538352f73696d706c652d7365727665722d696e666f2e7376673f7374796c653d666c61742d737175617265)](https://github.com/danielme85/simple-server-info)[![Tests](https://github.com/danielme85/simple-server-info/actions/workflows/tests.yml/badge.svg)](https://github.com/danielme85/simple-server-info/actions/workflows/tests.yml)

A PHP 8.1+ library that reads server and system information directly from the Linux [`/proc`](https://en.wikipedia.org/wiki/Procfs) and `/sys` virtual filesystems.

No `exec`, `shell_exec`, or other shell commands are used — all data is read from virtual filesystem files, making this safe, portable, and easy to audit.

---

Requirements
------------

[](#requirements)

- Linux/Unix OS with [Procfs](https://en.wikipedia.org/wiki/Procfs) support (`/proc`).
- PHP 8.1 or later.

---

Installation
------------

[](#installation)

```
composer require danielme85/simple-server-info
```

---

Quick start
-----------

[](#quick-start)

```
use danielme85\Server\Info;

// Instantiate directly
$info = new Info();

// Or use the static factory for method chaining
$cpuLoad = Info::get()->cpuLoad(sampleSec: 1, rounding: 2);
```

---

Architecture
------------

[](#architecture)

The library is organised around small, focused **Collector** classes, each responsible for a single concern. The `Info` class is a **facade** that delegates to the collectors while preserving a clean, unified API.

```
src/
├── Contracts/
│   └── CollectorInterface.php   # Interface implemented by every collector
├── Collectors/
│   ├── AbstractCollector.php    # Shared parsing helpers
│   ├── CpuCollector.php         # CPU info & load
│   ├── DiskCollector.php        # Disk partitions & volumes
│   ├── GpuCollector.php         # GPU info & resource usage
│   ├── MemoryCollector.php      # RAM & swap
│   ├── NetworkCollector.php     # Network interfaces & TCP connections
│   ├── ProcessCollector.php     # Process listing & CPU usage
│   └── SystemCollector.php      # Uptime & kernel version
├── Formatter.php                # Byte-formatting helper
├── Info.php                     # Public facade
├── ProcReader.php               # Low-level /proc file reader
└── SysReader.php                # Low-level /sys file reader

```

Collectors can be used independently:

```
use danielme85\Server\ProcReader;
use danielme85\Server\SysReader;
use danielme85\Server\Collectors\CpuCollector;
use danielme85\Server\Collectors\GpuCollector;

$cpu = new CpuCollector(new ProcReader());
$load = $cpu->load(sampleSec: 1);

$gpu = new GpuCollector(new ProcReader(), new SysReader());
$gpus = $gpu->gpus();
```

Or accessed through the facade:

```
$load = Info::get()->cpu()->load();
```

---

API Reference
-------------

[](#api-reference)

### CPU

[](#cpu)

```
// All cores, all fields
$cpuInfo = Info::get()->cpuInfo();

// Single core, specific fields
$core0 = Info::get()->cpuInfo(core: 0, returnonly: ['processor', 'cpu_mhz', 'cache_size']);

// Load percentage per core (samples over $sampleSec seconds)
$cpuLoad = Info::get()->cpuLoad(sampleSec: 1, rounding: 2);
// Returns: ['cpu' => ['label' => 'CPU', 'load' => 12.5], 'cpu0' => [...], ...]
```

### Memory

[](#memory)

```
// Usage summary with formatted sizes (e.g. "512.00 MB")
$usage = Info::get()->memoryUsage();

// Raw byte values
$usageBytes = Info::get()->memoryUsage(formatSizes: false);

// Percentage load
$load = Info::get()->memoryLoad(rounding: 2);
// Returns: ['load' => 42.5, 'swap_load' => 0.0]

// Full /proc/meminfo dump (bytes)
$all = Info::get()->memoryInfo();
```

### Disk &amp; Volumes

[](#disk--volumes)

```
// Block device information from /proc/partitions
$disks = Info::get()->diskInfo();

// Mounted volume usage (filtered by filesystem type)
$volumes = Info::get()->volumesInfo();

// Customise which filesystem types to include
// Defaults: ext, ext2, ext3, ext4, btrfs, xfs, zfs, fat32, ntfs, tmpfs, vboxsf
$info = new Info(filesystemTypes: ['ext4', 'xfs']);
$volumes = $info->volumesInfo();
```

### Processes

[](#processes)

```
// All processes (stat + status combined)
$all = Info::get()->processes();

// Single process
$proc = Info::get()->process(pid: 1);

// Filtered: specific fields, stat only, running only
$running = Info::get()->processes(
    returnonly: ['pid', 'comm', 'state', 'vsize'],
    returntype: 'stat',
    runningonly: true
);

// Active or running processes with CPU usage
$active = Info::get()->processesActiveOrRunning(
    returnonly: ['comm', 'state', 'pid', 'cpu_usage'],
    returntype: 'stat'
);
```

### Network

[](#network)

```
// Network interface statistics (keyed by interface name)
$interfaces = Info::get()->networks();

// With per-second load calculation (adds a 1s sleep)
$withLoad = Info::get()->networks(returnOnly: ['face', 'bytes', 'bytes_out', 'load', 'load_out']);

// TCP connections
$connections = Info::get()->tcpConnections(includeLocalhost: false);

// Summarised by local IP:port
$summary = Info::get()->tcpConnectionsSummarized();
```

### System / Uptime

[](#system--uptime)

```
$uptime = Info::get()->uptime();
// Returns:
// [
//   'current_unix' => 1700000000,
//   'uptime_unix'  => 86400,
//   'started_unix' => 1699913600,
//   'started'      => '2023-11-13 12:00:00',
//   'current'      => '2023-11-14 12:00:00',
//   'uptime'       => '1:00:00:00',
//   'uptime_text'  => '1 days, 0 hours, 0 minutes and 0 seconds',
// ]

$info = Info::get()->otherInfo();
// Returns: ['version' => '...', 'version_signature' => '...']
```

### GPU

[](#gpu)

Reads GPU hardware info and resource usage from `/sys/class/drm/`. Supports AMD and NVIDIA (open kernel module) GPUs. Available fields depend on the installed driver — absent metrics are simply omitted from the output.

```
$gpus = Info::get()->gpuInfo();
// Returns an array keyed by card name, e.g.:
// [
//   'card0' => [
//     'vendor'             => 'AMD',
//     'vendor_id'          => '0x1002',
//     'device_id'          => '0x687f',
//     'vram_total'         => 8589934592,
//     'vram_total_format'  => '8.00 GB',
//     'vram_used'          => 1073741824,
//     'vram_used_format'   => '1.00 GB',
//     'vram_load'          => 12.5,
//     'gpu_busy_percent'   => 34,
//     'temperature_celsius'=> 62.0,
//   ],
// ]

// Or via the typed collector:
$gpuCollector = Info::get()->gpu();
$gpus = $gpuCollector->gpus();
```

### Formatting helper

[](#formatting-helper)

```
use danielme85\Server\Formatter;

echo Formatter::bytes(1073741824); // "1.00 GB"

// Also available as a static method on Info for backward compatibility:
echo Info::formatBytes(1073741824);
```

---

Extending
---------

[](#extending)

Extend `AbstractCollector` to create a custom collector. `ProcReader` is always injected as `$this->proc`. Pass a `SysReader` as the second constructor argument if your collector needs `/sys` access (`$this->sys`).

```
use danielme85\Server\Contracts\CollectorInterface;
use danielme85\Server\Collectors\AbstractCollector;

class LoadAvgCollector extends AbstractCollector implements CollectorInterface
{
    public function all(): array
    {
        $lines = $this->proc->lines('loadavg');
        $parts = explode(' ', $lines[0] ?? '');

        return [
            '1min'  => (float) ($parts[0] ?? 0),
            '5min'  => (float) ($parts[1] ?? 0),
            '15min' => (float) ($parts[2] ?? 0),
        ];
    }
}
```

---

Running Tests
-------------

[](#running-tests)

```
composer install
./vendor/bin/phpunit
```

Tests require a Linux environment with `/proc` available. CI runs automatically via GitHub Actions on PHP 8.1, 8.2, 8.3, and 8.4.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance77

Regular maintenance activity

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 96.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~906 days

Total

4

Last Release

124d ago

Major Versions

v1.0 → v2.12026-03-01

PHP version history (2 changes)v1.0-betaPHP &gt;=7.1

v2PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1576219?v=4)[Daniel Mellum](/maintainers/danielme85)[@danielme85](https://github.com/danielme85)

---

Top Contributors

[![danielme85](https://avatars.githubusercontent.com/u/1576219?v=4)](https://github.com/danielme85 "danielme85 (28 commits)")[![rotexdegba](https://avatars.githubusercontent.com/u/1242622?v=4)](https://github.com/rotexdegba "rotexdegba (1 commits)")

---

Tags

cpuinformation-retrievalmemoryprocfsserverstoragesysinfosystemuptimevolumes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/danielme85-simple-server-info/health.svg)

```
[![Health](https://phpackages.com/badges/danielme85-simple-server-info/health.svg)](https://phpackages.com/packages/danielme85-simple-server-info)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
