* Mon May 12 2025 Brian Read <brianr@koozali.org> 11.0.0-1.sme
- Adding SM2 panel [SME: 13004] - Upgrade to phpsysinfo 3.4.4 - Add code to delete inline styles and add css to make it look better. - version saved / built uses the static version, which means no drops downs and choices.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* @package PSI Minix OS class
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2012 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version SVN: $Id: class.Minix.inc.php 687 2012-09-06 20:54:49Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,26 +20,23 @@
|
||||
* @package PSI Minix OS class
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2012 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class Minix extends OS
|
||||
{
|
||||
/**
|
||||
* uptime command result.
|
||||
*/
|
||||
private $_uptime = null;
|
||||
|
||||
/**
|
||||
* content of the syslog
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_dmesg = array();
|
||||
|
||||
/**
|
||||
* call parent constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
private $_dmesg = null;
|
||||
|
||||
/**
|
||||
* read /var/log/messages, but only if we haven't already
|
||||
@@ -48,11 +45,13 @@ class Minix extends OS
|
||||
*/
|
||||
protected function readdmesg()
|
||||
{
|
||||
if (count($this->_dmesg) === 0) {
|
||||
if ($this->_dmesg === null) {
|
||||
if (CommonFunctions::rfts('/var/log/messages', $buf)) {
|
||||
$parts = preg_split("/kernel: APIC/", $buf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
// $parts = preg_split("/ syslogd: restart\n/", $buf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$blocks = preg_replace("/\s(kernel: MINIX \d+\.\d+\.\d+\.)/", '<BLOCK>$1', $buf);
|
||||
$parts = preg_split("/<BLOCK>/", $blocks, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$this->_dmesg = preg_split("/\n/", $parts[count($parts) - 1], -1, PREG_SPLIT_NO_EMPTY);
|
||||
} else {
|
||||
$this->_dmesg = array();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +61,7 @@ class Minix extends OS
|
||||
/**
|
||||
* get the cpu information
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
protected function _cpuinfo()
|
||||
{
|
||||
@@ -73,31 +72,32 @@ class Minix extends OS
|
||||
$dev = new CpuDevice();
|
||||
$details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($details as $detail) {
|
||||
$arrBuff = preg_split('/\s+:\s+/', trim($detail));
|
||||
if (count($arrBuff) == 2) {
|
||||
switch (strtolower($arrBuff[0])) {
|
||||
if (preg_match('/^([^:]+):(.+)$/', trim($detail) , $arrBuff) && (($arrBuff2 = trim($arrBuff[2])) !== '')) {
|
||||
switch (strtolower(trim($arrBuff[1]))) {
|
||||
case 'model name':
|
||||
$_n = $arrBuff[1];
|
||||
$_n = $arrBuff2;
|
||||
break;
|
||||
case 'cpu mhz':
|
||||
$dev->setCpuSpeed($arrBuff[1]);
|
||||
$dev->setCpuSpeed($arrBuff2);
|
||||
break;
|
||||
case 'cpu family':
|
||||
$_f = $arrBuff[1];
|
||||
$_f = $arrBuff2;
|
||||
break;
|
||||
case 'model':
|
||||
$_m = $arrBuff[1];
|
||||
$_m = $arrBuff2;
|
||||
break;
|
||||
case 'stepping':
|
||||
$_s = $arrBuff[1];
|
||||
$_s = $arrBuff2;
|
||||
break;
|
||||
case 'flags':
|
||||
if (preg_match("/ vmx/", $arrBuff[1])) {
|
||||
if (preg_match("/ vmx/", $arrBuff2)) {
|
||||
$dev->setVirt("vmx");
|
||||
} elseif (preg_match("/ svm/", $arrBuff[1])) {
|
||||
} elseif (preg_match("/ svm/", $arrBuff2)) {
|
||||
$dev->setVirt("svm");
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'vendor_id':
|
||||
$dev->setVendorId($arrBuff2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,7 @@ class Minix extends OS
|
||||
{
|
||||
if (CommonFunctions::rfts('/proc/pci', $strBuf, 0, 4096, false)) {
|
||||
$arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$arrResults = array();
|
||||
foreach ($arrLines as $strLine) {
|
||||
$arrParams = preg_split('/\s+/', trim($strLine), 4);
|
||||
if (count($arrParams) == 4)
|
||||
@@ -144,7 +145,7 @@ class Minix extends OS
|
||||
$this->sys->setPciDevices($dev);
|
||||
}
|
||||
}
|
||||
if (!(isset($arrResults) && is_array($arrResults)) && is_array($results = Parser::lspci())) {
|
||||
if (!(isset($arrResults) && is_array($arrResults)) && ($results = Parser::lspci())) {
|
||||
/* if access error: chmod 4755 /usr/bin/lspci */
|
||||
foreach ($results as $dev) {
|
||||
$this->sys->setPciDevices($dev);
|
||||
@@ -159,12 +160,13 @@ class Minix extends OS
|
||||
*/
|
||||
private function _kernel()
|
||||
{
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match('/kernel: MINIX (.*) \((.*)\)/', $line, $ar_buf)) {
|
||||
$branch = $ar_buf[2];
|
||||
}
|
||||
}
|
||||
if (CommonFunctions::executeProgram('uname', '-rvm', $ret)) {
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match('/kernel: MINIX (\d+\.\d+\.\d+)\. \((.+)\)/', $line, $ar_buf)) {
|
||||
$branch = $ar_buf[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($branch))
|
||||
$this->sys->setKernel($ret.' ('.$branch.')');
|
||||
else
|
||||
@@ -195,13 +197,13 @@ class Minix extends OS
|
||||
*/
|
||||
private function _uptime()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
|
||||
if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
|
||||
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
|
||||
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
|
||||
$min = $ar_buf[3];
|
||||
$hours = $ar_buf[2];
|
||||
$days = $ar_buf[1];
|
||||
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
|
||||
} elseif (preg_match("/up (\d+):(\d+),/", $buf, $ar_buf)) {
|
||||
} elseif (preg_match("/up (\d+):(\d+),/", $this->_uptime, $ar_buf)) {
|
||||
$min = $ar_buf[2];
|
||||
$hours = $ar_buf[1];
|
||||
$this->sys->setUptime($hours * 3600 + $min * 60);
|
||||
@@ -217,27 +219,13 @@ class Minix extends OS
|
||||
*/
|
||||
private function _loadavg()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
|
||||
if (preg_match("/load averages: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
|
||||
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
|
||||
if (preg_match("/load averages: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
|
||||
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Users
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _users()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
|
||||
if (preg_match("/, (.*) users, load averages: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
|
||||
$this->sys->setUsers($ar_buf[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual Host Name
|
||||
*
|
||||
@@ -245,8 +233,8 @@ class Minix extends OS
|
||||
*/
|
||||
private function _hostname()
|
||||
{
|
||||
if (PSI_USE_VHOST === true) {
|
||||
$this->sys->setHostname(getenv('SERVER_NAME'));
|
||||
if (PSI_USE_VHOST) {
|
||||
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
|
||||
} else {
|
||||
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
|
||||
$ip = gethostbyname($result);
|
||||
@@ -257,23 +245,6 @@ class Minix extends OS
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IP of the Virtual Host Name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _ip()
|
||||
{
|
||||
if (PSI_USE_VHOST === true) {
|
||||
$this->sys->setIp(gethostbyname($this->sys->getHostname()));
|
||||
} else {
|
||||
if (!($result = getenv('SERVER_ADDR'))) {
|
||||
$this->sys->setIp(gethostbyname($this->sys->getHostname()));
|
||||
} else {
|
||||
$this->sys->setIp($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Physical memory information and Swap Space information
|
||||
@@ -360,23 +331,32 @@ class Minix extends OS
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->error->addError("WARN", "The Minix version of phpSysInfo is a work in progress, some things currently don't work");
|
||||
$this->_distro();
|
||||
$this->_hostname();
|
||||
$this->_ip();
|
||||
$this->_kernel();
|
||||
$this->_uptime();
|
||||
$this->_users();
|
||||
$this->_loadavg();
|
||||
$this->_pci();
|
||||
$this->_cpuinfo();
|
||||
$this->_memory();
|
||||
$this->_filesystems();
|
||||
$this->_network();
|
||||
$this->_processes();
|
||||
$this->error->addWarning("The Minix version of phpSysInfo is a work in progress, some things currently don't work");
|
||||
if (!$this->blockname || $this->blockname==='vitals') {
|
||||
$this->_distro();
|
||||
$this->_hostname();
|
||||
$this->_kernel();
|
||||
$this->_uptime();
|
||||
$this->_users();
|
||||
$this->_loadavg();
|
||||
$this->_processes();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='hardware') {
|
||||
$this->_pci();
|
||||
$this->_cpuinfo();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user