vitobar / uptime-parser
一个用于解析 uptime 命令输出的 PHP 包
1.0.3
2017-10-15 00:41 UTC
Requires (Dev)
- phpunit/phpunit: 4.0.*
- satooshi/php-coveralls: ~1.0
This package is auto-updated.
Last update: 2024-09-06 23:05:47 UTC
README
一个用于解析 uptime 命令输出的 PHP 包
安装
通过 Composer 安装。
composer require vitorbari/uptime-parser
用法
use VitorBari\UptimeParser\Parser; $uptime_output = 'SNMP OK - Timeticks: (197181577) 22 days, 19:43:35.77'; $uptime = Parser::uptime($uptime_output); echo $uptime->days; // 22 echo $uptime->hours; // 547 echo $uptime->minutes; // 32863 echo $uptime->seconds; // 1971815 echo $uptime->toTimeString(); // '22 day(s), 19 hour(s), 43 minute(s) and 35 second(s)' echo $uptime; // '22 day(s), 19 hour(s), 43 minute(s) and 35 second(s)'
支持格式
SNMP OK - Timeticks: (197181577) 22 days, 19:43:35.77
SNMP OK - Timeticks, (12490039) 1 day, 10,41,40.39
SNMP OK - Timeticks, (6261427) 17,23,34.27
System Uptime - 44 day(s) 23 hour(s) 14 minute(s)
System Uptime - up 57 days, 12 Hours, 41 Minutes
System Uptime - 10 minute(s)
Sistema ativo a 32 Dia(s), 10 Hora(s) e 38 Minutos(s)
可以轻松添加不同的格式。