gemorroj/ginfo
Composer 安装命令:
composer require gemorroj/ginfo
包简介
Library for parsing system information, like network/cpu/memory/usb/pci/sound cards/filesystems/raid array/ipmi/etc and php/web-servers/databases.
关键字:
README 文档
README
Requirements:
- PHP >= 8.2
- pcre extension
- proc_open
- Linux
/proc,/sysand/etcmounted 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)
- Temperatures/voltages/fan speeds (linux: need
hddtempas daemon,mbmonas daemon,sensors(part oflm-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
- use /proc/meminfo instead free for memory info
gemorroj/ginfo 适用场景与选型建议
gemorroj/ginfo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 229 次下载、GitHub Stars 达 5, 最近一次更新时间为 2018 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「redis」 「mongodb」 「php」 「memcache」 「mysql」 「sqlite」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gemorroj/ginfo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gemorroj/ginfo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gemorroj/ginfo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generates Symfony2 documents, forms and CRUD
Microservice RPC through message queues.
The CodeIgniter Redis package
贝嘟分布式缓存扩展
A package to allow laravel/passport use with mongodb/laravel-mongodb
MongoDB Adapter to be used with Laminas Paginator
统计信息
- 总下载量: 229
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-04-10