SysInfo-0.1.0 released

The other day I released the first version of a small Open Source (MIT) PHP library that can be used to fetch system information; like for instance CPU usage, load average and memory usage (amongst other information). The library is available at GitHub and can be installed using composer (support for PEAR and phar will be added later).

Installation using composer is very simple:

curl -s | php
php composer.phar create-project christeredvartsen/sysinfo sysinfo 0.1.0

and you are good to go. If you have a project with a composer.json file, simply add a dependency:

  "require": {
    "christeredvartsen/sysinfo": "0.1.0"

and update your dependencies using composer.phar:

php composer.phar update

After installation, fire up your favorite editor (Vim, right?) and paste the following to get started using the library:

// Edit to match the directory where you installed SysInfo
require 'sysinfo/vendor/autoload.php';

// Fetch an instance based on the PHP_OS constant. Currently only Linux is supported.
$sysInfo = SysInfo\SysInfo::factory();
// or
$sysInfo = new SysInfo\Linux();

// Get snapshot of CPU
$cpu = $sysInfo->getCPU();

// Get snapshot of load
$load = $sysInfo->getLoad();

// Get snapshot of memory
$memory = $sysInfo->getMemory();

// Get snapshot of disk info
$disk = $sysInfo->getDisk();

// Get snapshot of uptime
$uptime = $sysInfo->getUptime();

The snapshots above are implementations of different interfaces. Read the documentation over at GitHub to see which methods you can call, and what they return:

If you want to add some features or find any bugs, file an issue and I’ll see what I can do.

This entry was posted in PHP and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s