2017 © Pedro Peláez
 

library sysinfo

Reads info about memory usage, cpu, load etc

image

anpk12/sysinfo

Reads info about memory usage, cpu, load etc

  • Saturday, April 16, 2016
  • by anpk12
  • Repository
  • 1 Watchers
  • 0 Stars
  • 75 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

Build Status Scrutinizer Code Quality Code Coverage, (*1)

This is a simple script for retrieving information about the host system that the code (typically web application) is running on, so that it can be presented on a web page, and/or graphed over time. Or perhaps it can be used to detect situations where the system is running low on resources., (*2)

It is made as part of an online course in web development. So I was forced to make this available on github and packagist. Maybe it can be useful for someone., (*3)

Note that it is intended for Linux host systems and no effort has been made to make it work for other host operating systems., (*4)

HOW TO USE WITH ANAX-MVC, (*5)

Clone the Anax-MVC git repository using, (*6)

$ git clone https://github.com/mosbth/Anax-MVC.git Anax-MVC.git, (*7)

Then add the following line to the "require" property of Anax-MVC.git/composer.json:, (*8)

"anpk12/sysinfo": "dev-master", (*9)

The part after the colon is the version requirement and can optionally be changed to a fixed version such as "1.0.0"., (*10)

Validate your composer.json file:, (*11)

$ composer validate, (*12)

If it succeeds, update:, (*13)

$ composer update, (*14)

Now, to see if it works, you need to integrate anpk12\sysinfo into a route. We will take the easiest route possible to create a working demo., (*15)

Make a copy of webroot/hello.php, call it webroot/hello_sysinfo.php . After the line that starts with "require", create an instance of Anpk12\Sysinfo\Snapshot:, (*16)

$sysinfo = new Anpk12\Sysinfo\Snapshot();, (*17)

This will create a snapshot of the current system status, which we can then use to generate html, graphs/images or database entries etc., (*18)

The Snapshot class provides easy access to the various types of system information it collects through accessors., (*19)

But it can also generate a complete html report using all the information. This is done using the htmlReport() member function. Add the following line to hello_sysinfo.php, just after the creation of the Snapshot instance:, (*20)

$sysReport = $sysinfo->htmlReport(false), (*21)

The boolean argument controls whether or not to create a short summary (true) or a full report (false)., (*22)

The variable $sysReport now holds a string of html markup, which we can tell Anax-MVC to render. Simply change the title and main variables of the theme:, (*23)

// Prepare the page content $app->theme->setVariable('title', "Hello World Sysinfo") ->setVariable('main', $sysreport);, (*24)

Done! Try accessing Anax-MVC.git/webroot/hello_sysinfo.php with a web browser. You should see current memory usage etc., (*25)

In order to access the system information directly instead of generating html, use the Snapshot member functions meminfo(), memTotal(), memAvailable() and loadavg() ., (*26)

The Versions

16/04 2016

dev-master

9999999-dev https://github.com/anpk12/sysinfo.git

Reads info about memory usage, cpu, load etc

  Sources   Download

GPL-3.0

The Requires

  • php >=5.4

 

by Anton Petersson

load memory sysinfo cpu

16/04 2016

dev-unit-test

dev-unit-test https://github.com/anpk12/sysinfo.git

Reads info about memory usage, cpu, load etc

  Sources   Download

GPL-3.0

The Requires

  • php >=5.4

 

by Anton Petersson

load memory sysinfo cpu

09/04 2016

v1.0

1.0.0.0 https://github.com/anpk12/sysinfo.git

Reads info about memory usage, cpu, load etc

  Sources   Download

GPL-3.0

The Requires

  • php >=5.4

 

by Anton Petersson

load memory sysinfo cpu