PHPackages                             choval/sys-stats - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. choval/sys-stats

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

choval/sys-stats
================

Gets system stats

v1.7.0(5y ago)0107[1 PRs](https://github.com/choval/sys-stats/pulls)MITPHPCI passing

Since May 11Pushed 2mo agoCompare

[ Source](https://github.com/choval/sys-stats)[ Packagist](https://packagist.org/packages/choval/sys-stats)[ RSS](/packages/choval-sys-stats/feed)WikiDiscussions master Synced 2d ago

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

Choval\\SysStats
================

[](#chovalsysstats)

Gets system status.
Tested on Unix based OS.

- If run in blocking mode, stats are retrieved at that instant.
- If run with ReactPHP loop without a frequency, promises are returned.
- If run with ReactPHP loop AND a frequency, all stats are executed in the background and all getters return from the cache.

Install
-------

[](#install)

```
composer require choval/sys-stats
```

Tested on Ubuntu/Debian &amp; Mac only. Won't work on Windows as multiple commands are not available.

### Tests

[](#tests)

```
composer install
./runtests --testdox
```

You can also use the tests as an example of how this library works.

Usage
-----

[](#usage)

```
$stats = new \Choval\System\Stats;
/*
Creates the stats object
*/

$stats->getMemUsage();
/*
Memory usage of current PHP execution.
All results in Bytes as PHP memory_get_usage & memory_get_peak_usage.
Array
(
  [peak] => inactive+active peak
  [peak_active] => active peak
  [current] => inactive+active currently
  [current_active] => active currently
)
*/

$stats->getMemStats();
/*
Memory stats.
All results in MiB, not MB.
Array
(
  [total] => system memory
  [free] => free memory (keep in mind linux memory usage, this will usually be close to 1-2)
  [used] => memory under use by applications and system
  [available] => available memory for use
  [capacity] => PERCENTAGE (without '%') of available memory/total memory
)
*/

$stats->getCpuModels();
/*
Gets the CPU model, repeated by number of (logical) CPUs (ncpu)
Array
(
  [0] => Intel(R) Core(TM) M-5Y31 CPU
  [1] => Intel(R) Core(TM) M-5Y31 CPU
  [2] => Intel(R) Core(TM) M-5Y31 CPU
  [3] => Intel(R) Core(TM) M-5Y31 CPU
)
*/

$stats->getCpuLoads();
/*
Gets the CPU load, all results in PERCENTAGE (without '%').
Unlike PHP's results, these are percentage of the system capacity already.
Keep in mind some systems may underclock depending on load.
Array
(
  [1_min] => PERCENTAGE of load/capacity last min
  [5_min] => PERCENTAGE of load/capacity last 5min
  [15_min] => PERCENTAGE of load/capacity last 15min
)
*/

$stats->getDiskStats();
/*
Disk stats.
All results in MiB, not MB. NOT BYTES!
Only return mounted disks.
Array
(
  [0] => Array
    (
      [filesystem] => The device, ie: /dev/sda1
      [size] => Capacity in MiB
      [used] => Used number of MiB
      [available] => Available capacity
      [capacity] => PERCENTAGE (without '%') of available/size
      [mounted_on] => Mount path
    )
)
*/

$stats->getSingleDiskStats( getcwd() );
/*
This returns the same data for the disk/partition the current working dir is using.
Or point to a different directory and get the stats.
Array
(
  [filesystem] => The device, ie: /dev/sda1
  [size] => Capacity in MiB
  [used] => Used number of MiB
  [available] => Available capacity
  [capacity] => PERCENTAGE (without '%') of available/size
  [mounted_on] => Mount path
)
*/

$stats->getNetStats();
/*
Returns network stats for every network interface.
Array
(
  [0] => Array
    (
      [interface] => Interface name
      [mtu] => MTU, int
      [addresses] => Array
        (
          [mac] => Mac address
          [ipv4] => IPv4
          [ipv6] => IPv6
        )
      [packets_in] => Packets, float
      [packets_out] => Packets, float
      [bytes_in] => Bytes, float
      [bytes_out] => Bytes, float
      [errors_in] => Errors, float
      [errors_out] => Errors, float
    )
)
*/

$stats->output();
/*
Returns all the data in one single call.
Array
(
  [cpu_loads] => getCpuLoads()
  [cpu_models] => getCpuModels()
  [disk_stats] => getDiskStats()
  [mem_stats] => getMemStats()
  [mem_usage] => getMemUsage()
  [net_stats] => getNetStats()
  [updated] => Time of stats
)
*/
```

With ReactPHP

```
$stats = new \Choval\System\Stats($loop);
/*
Creates the stats object, without frequency.
All methods will return a React\Promise\Promise.
*/
```

With ReactPHP &amp; a frequency

```
$stats = new \Choval\System\Stats($loop, 60);
/*
Runs the stats every 60 secs in the background.
All methods will return a React\Promise\Promise as well,
but the data will be retrieved from the cache of the
last background execution.
*/

$stats->refresh();
/*
Forces a refresh of all data ignoring the frequency.
Will not reset the frequency timer.
Returns a promise.
*/

$stats->getUpdated();
/*
Returns the time of the stats.
Does not return a promise!
*/
```

License
-------

[](#license)

MIT, see LICENSE

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance57

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~96 days

Recently: every ~111 days

Total

9

Last Release

1833d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f7e751254e7e7b319464bd6b51c51d9d2c5fedb4c2305ceaa580f9116cbc6a11?d=identicon)[choval](/maintainers/choval)

---

Top Contributors

[![choval](https://avatars.githubusercontent.com/u/794926?v=4)](https://github.com/choval "choval (25 commits)")

---

Tags

asyncphpreactphpsystem-status

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/choval-sys-stats/health.svg)

```
[![Health](https://phpackages.com/badges/choval-sys-stats/health.svg)](https://phpackages.com/packages/choval-sys-stats)
```

###  Alternatives

[fakerphp/faker

Faker is a PHP library that generates fake data for you.

4.0k379.0M4.3k](/packages/fakerphp-faker)[szepeviktor/composer-envato

Composer plugin for Envato

3616.3k1](/packages/szepeviktor-composer-envato)

PHPackages © 2026

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