2017 © Pedro Peláez
 

library ginfo

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

image

gemorroj/ginfo

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  • Saturday, July 28, 2018
  • by Gemorroj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 58 Forks
  • 4 Open issues
  • 9 Versions
  • 40 % Grown

The README.md

Ginfo - Server stats library

License Latest Stable Version Continuous Integration, (*1)

Requirements:

  • PHP >= 8.2
  • pcre extension
  • proc_open
  • Linux
    • /proc, /sys and /etc mounted and readable by PHP
    • Tested with the 2.6.x/3.x/4.x/5.x/6.x kernels

Installation:

composer require gemorroj/ginfo

Example:

<?php
use Ginfo\Ginfo;

$ginfo = new Ginfo();

print_r($ginfo->getGeneral()); // kernel, uptime, virtualization, load, etc...
print_r($ginfo->getPhp()); // version, extensions, Opcache, FPM, APCU, etc...
print_r($ginfo->getCpu()); // cores, speed, cache, etc...
print_r($ginfo->getMemory()); // total memory, used, free, cached, swap, etc...
print_r($ginfo->getSoundCard()); // vendor, name
print_r($ginfo->getUsb()); // vendor, name, speed
print_r($ginfo->getUps()); // vendor, time, status, charge, etc...
print_r($ginfo->getPci()); // vendor, name
print_r($ginfo->getNetwork()); // name, speed, state, stats, etc...
print_r($ginfo->getDisk()); // mounts, drives, raids, size, type, stats, etc...
print_r($ginfo->getBattery()); // model, status, voltage, charge, etc...
print_r($ginfo->getSensors()); // name, value, unit, path
print_r($ginfo->getProcesses()); // name, pid, commandLine, memory, state, stats, etc...
print_r($ginfo->getServices()); // name, state, type, etc...
print_r($ginfo->getPrinters()); // name, enabled
print_r($ginfo->getSamba()); // files, services, connections, etc...
print_r($ginfo->getSelinux()); // enabled, mode, policy
print_r($ginfo->getNginx()); // version, status, etc...
print_r($ginfo->getAngie('http://localhost/status/')); // version, status, etc...
print_r($ginfo->getHttpd()); // version, status, etc...
print_r($ginfo->getCaddy()); // version, status, etc...
print_r($ginfo->getMysql(new \PDO('mysql:host=127.0.0.1', 'root', ''))); // variables, performance, status, etc...
print_r($ginfo->getPostgres(new \PDO('pgsql:host=127.0.0.1', 'postgres', 'postgres'))); // pg_stat_activity, pg_stat_statements, etc...
print_r($ginfo->getManticore(new \PDO('mysql:host=127.0.0.1;port=9306', 'root', ''))); // status, variables, etc...
print_r($ginfo->getRedis(new \Redis(['host' => '127.0.0.1', 'port' => 6379]))); // status, memory, cpu, etc...
print_r($ginfo->getSqlite(new \PDO('sqlite:/var/www/mydb.sqlite'))); // version, size, options, etc...
$memcached = new \Memcached();
$memcached->addServer('127.0.0.1', 11211);
print_r($ginfo->getMemcached($memcached)); // version, stats, etc...
print_r($ginfo->getMongo(new \MongoDB\Driver\Manager('mongodb://127.0.0.1:27017'))); // version, stats, etc...
print_r($ginfo->getElasticsearch('https://127.0.0.1:9200/_cluster/stats', 'user', 'pass'); // version, stats, etc...

Custom parser example:

<?php
use Ginfo\Ginfo;
use Ginfo\Info\InfoInterface;
use Ginfo\InfoParserInterface;

// class for parsed data
final readonly class SwooleInfo implements InfoInterface
{
    public function __construct(private array $stats)
    {
    }

    public function getStats(): array
    {
        return $this->stats;
    }
}

// parser
final readonly class SwooleParser implements InfoParserInterface
{
    public function run(): ?InfoInterface
    {
        $stats = \app('Swoole\Http\Server')->stats(); // laravel
        return new SwooleInfo($stats);
    }
}

$swooleParser = new SwooleParser();

$ginfo = new Ginfo(customParsers: [$swooleParser]);
/** @var SwooleInfo $data */
$data = $ginfo->getCustomParser(SwooleParser::class);
print_r($data->getStats());

Information reported

  • CPU type/speed; Architecture
  • Mount point usage
  • Hard/optical/flash drives
  • Hardware devices (PCI) (linux: need pciutils)
  • USB devices (linux: need usbutils)
  • Network devices and stats
  • Uptime
  • Memory usage (physical and swap, linux: need free)
  • Temperatures/voltages/fan speeds (linux: need hddtemp as daemon, mbmon as daemon, sensors (part of lm-sensors), hwmon, acpi themal zone, nvidia-smi, ipmitool)
  • RAID arrays (linux: need mdadm)
  • Motherboard (linux: need dimedecode)
  • Processes
  • Systemd services (linux: need systemctl)
  • logged users (linux: need who)
  • UPS status (linux: need apcaccess)
  • Printer status (linux: need lpstat)
  • Samba status (linux: need smbstatus)
  • Selinux status (linux: need sestatus)
  • PHP (basic info, opcache, apcu)
  • Web-Servers (angie, nginx, httpd, caddy)
  • Databases (mysql/mariadb, postgres, manticore, redis/valkey, sqlite, memcached, mongodb, elasticsearch/opensearch)

Fork changes:

  • drop windows support
  • drop bsd* support
  • drop ui
  • drop internationalization
  • drop dhcp3 support
  • drop dnsmasq support
  • drop php libvirt support
  • drop lxd support
  • adapt the code to modern standards
  • minimal php version 8.2
  • add selinux status info
  • add php info (basic, opcache, apcu)
  • add web-servers info (nginx, angie, httpd, caddy)
  • add databases info (mysql/mariadb, postgres, manticore, redis/valkey, sqlite, memcached, mongodb, elasticsearch/opensearch)
  • allow add custom parsers

The Versions

28/07 2018

dev-master

9999999-dev

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Gemorroj

system memory linux health disk cpu specs

28/07 2018

5.0.6

5.0.6.0

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Gemorroj

system memory linux health disk cpu specs

13/04 2018

5.0.5

5.0.5.0

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Gemorroj

system memory linux health disk cpu specs

11/04 2018

5.0.4

5.0.4.0

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Gemorroj

system memory linux health disk cpu specs

11/04 2018

5.0.3

5.0.3.0

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Gemorroj

system memory linux health disk cpu specs

11/04 2018

5.0.2

5.0.2.0

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Gemorroj

system memory linux health disk cpu specs

11/04 2018

5.0.1

5.0.1.0

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Gemorroj

system memory linux health disk cpu specs

10/04 2018

5.0.0

5.0.0.0

App and library for easily parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Gemorroj

system memory linux health disk cpu specs

19/03 2018

4.0.0

4.0.0.0

App and library for easily parsing system information, like network/torrents/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc.

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

by Avatar Gemorroj

system linux health cpu specs