* 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 NetBSD OS class
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 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.NetBSD.inc.php 287 2009-06-26 12:11:59Z bigmichi1 $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,7 +20,7 @@
|
||||
* @package PSI NetBSD OS class
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 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
|
||||
*/
|
||||
@@ -29,29 +29,17 @@ class NetBSD extends BSDCommon
|
||||
/**
|
||||
* define the regexp for log parser
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($blockname = false)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setCPURegExp1("^cpu(.*)\, (.*) MHz");
|
||||
parent::__construct($blockname);
|
||||
//$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/");
|
||||
$this->setCPURegExp2("/user = (.*), nice = (.*), sys = (.*), intr = (.*), idle = (.*)/");
|
||||
$this->setSCSIRegExp1("^(.*) at scsibus.*: <(.*)> .*");
|
||||
$this->setSCSIRegExp2("^(da[0-9]): (.*)MB ");
|
||||
$this->setPCIRegExp1("/(.*) at pci[0-9] dev [0-9]* function [0-9]*: (.*)$/");
|
||||
$this->setSCSIRegExp1("/^(.*) at scsibus.*: <(.*)> .*/");
|
||||
$this->setSCSIRegExp2("/^(sd[0-9]+): (.*)([MG])B,/");
|
||||
$this->setPCIRegExp1("/(.*) at pci[0-9]+ dev [0-9]* function [0-9]*: (.*)$/");
|
||||
$this->setPCIRegExp2("/\"(.*)\" (.*).* at [.0-9]+ irq/");
|
||||
}
|
||||
|
||||
/**
|
||||
* UpTime
|
||||
* time the system is running
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _uptime()
|
||||
{
|
||||
$a = $this->grabkey('kern.boottime');
|
||||
$this->sys->setUptime(time() - $a);
|
||||
}
|
||||
|
||||
/**
|
||||
* get network information
|
||||
*
|
||||
@@ -66,13 +54,39 @@ class NetBSD extends BSDCommon
|
||||
for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) {
|
||||
$ar_buf_b = preg_split("/\s+/", $lines_b[$i]);
|
||||
$ar_buf_n = preg_split("/\s+/", $lines_n[$i]);
|
||||
if (! empty($ar_buf_b[0]) && ! empty($ar_buf_n[3])) {
|
||||
if (!empty($ar_buf_b[0]) && (!empty($ar_buf_n[3]) || ($ar_buf_n[3] === "0"))) {
|
||||
$dev = new NetDevice();
|
||||
$dev->setName($ar_buf_b[0]);
|
||||
$dev->setTxBytes($ar_buf_b[4]);
|
||||
$dev->setRxBytes($ar_buf_b[3]);
|
||||
$dev->setDrops($ar_buf_n[8]);
|
||||
$dev->setErrors($ar_buf_n[4] + $ar_buf_n[6]);
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS) && (CommonFunctions::executeProgram('ifconfig', $ar_buf_b[0].' 2>/dev/null', $bufr2, PSI_DEBUG))) {
|
||||
$speedinfo = "";
|
||||
$bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe2 as $buf2) {
|
||||
if (preg_match('/^\s+address:\s+(\S+)/i', $buf2, $ar_buf2)) {
|
||||
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
|
||||
} elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2)) {
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
} elseif ((preg_match('/^\s+inet6\s+([^\s%]+)\s+prefixlen/i', $buf2, $ar_buf2)
|
||||
|| preg_match('/^\s+inet6\s+([^\s%]+)%\S+\s+prefixlen/i', $buf2, $ar_buf2))
|
||||
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
|
||||
} elseif (preg_match('/^\s+media:\s+/i', $buf2) && preg_match('/[\(\s](\d+)(G*)base/i', $buf2, $ar_buf2)) {
|
||||
if (isset($ar_buf2[2]) && strtoupper($ar_buf2[2])=="G") {
|
||||
$unit = "G";
|
||||
} else {
|
||||
$unit = "M";
|
||||
}
|
||||
if (preg_match('/\s(\S+)-duplex/i', $buf2, $ar_buf3))
|
||||
$speedinfo = $ar_buf2[1].$unit.'b/s '.strtolower($ar_buf3[1]);
|
||||
else
|
||||
$speedinfo = $ar_buf2[1].$unit.'b/s';
|
||||
}
|
||||
}
|
||||
if ($speedinfo != "") $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo);
|
||||
}
|
||||
$this->sys->setNetDevices($dev);
|
||||
}
|
||||
}
|
||||
@@ -86,15 +100,34 @@ class NetBSD extends BSDCommon
|
||||
protected function ide()
|
||||
{
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match('/^(.*) at (pciide|wdc|atabus|atapibus)[0-9] (.*): <(.*)>/', $line, $ar_buf)) {
|
||||
if (preg_match('/^(.*) at (pciide|wdc|atabus|atapibus)[0-9]+ (.*): <(.*)>/', $line, $ar_buf)
|
||||
|| preg_match('/^(.*) at (pciide|wdc|atabus|atapibus)[0-9]+ /', $line, $ar_buf)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
// now loop again and find the capacity
|
||||
foreach ($this->readdmesg() as $line2) {
|
||||
if (preg_match("/^(".$ar_buf[1]."): (.*), (.*), (.*)MB, .*$/", $line2, $ar_buf_n)) {
|
||||
$dev->setCapacity($ar_buf_n[4] * 2048 * 1.049);
|
||||
} elseif (preg_match("/^(".$ar_buf[1]."): (.*) MB, (.*), (.*), .*$/", $line2, $ar_buf_n)) {
|
||||
$dev->setCapacity($ar_buf_n[2] * 2048);
|
||||
if (isset($ar_buf[4])) {
|
||||
$dev->setName($ar_buf[4]);
|
||||
} else {
|
||||
$dev->setName($ar_buf[1]);
|
||||
// now loop again and find the name
|
||||
foreach ($this->readdmesg() as $line2) {
|
||||
if (preg_match("/^(".$ar_buf[1]."): <(.*)>$/", $line2, $ar_buf_n)) {
|
||||
$dev->setName($ar_buf_n[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
// now loop again and find the capacity
|
||||
foreach ($this->readdmesg() as $line2) {
|
||||
if (preg_match("/^(".$ar_buf[1]."): (.*), (.*), (.*)MB, .*$/", $line2, $ar_buf_n)) {
|
||||
$dev->setCapacity($ar_buf_n[4] * 1024 * 1024);
|
||||
break;
|
||||
} elseif (preg_match("/^(".$ar_buf[1]."): (.*) MB, (.*), (.*), .*$/", $line2, $ar_buf_n)) {
|
||||
$dev->setCapacity($ar_buf_n[2] * 1024 * 1024);
|
||||
break;
|
||||
} elseif (preg_match("/^(".$ar_buf[1]."): (.*) GB, (.*), (.*), .*$/", $line2, $ar_buf_n)) {
|
||||
$dev->setCapacity($ar_buf_n[2] * 1024 * 1024 * 1024);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->sys->setIdeDevices($dev);
|
||||
@@ -102,6 +135,77 @@ class NetBSD extends BSDCommon
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CPU information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function cpuinfo()
|
||||
{
|
||||
$was = false;
|
||||
$cpuarray = array();
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match("/^cpu([0-9])+: (.*)/", $line, $ar_buf)) {
|
||||
$was = true;
|
||||
$ar_buf[2] = trim($ar_buf[2]);
|
||||
if (preg_match("/^(.+), ([\d\.]+) MHz/", $ar_buf[2], $ar_buf2)) {
|
||||
if (($model = trim($ar_buf2[1])) !== "") {
|
||||
$cpuarray[$ar_buf[1]]['model'] = $model;
|
||||
}
|
||||
if (($speed = trim($ar_buf2[2])) > 0) {
|
||||
$cpuarray[$ar_buf[1]]['speed'] = $speed;
|
||||
}
|
||||
} elseif (preg_match("/^L2 cache (\d+) ([KM])B /", $ar_buf[2], $ar_buf2)) {
|
||||
if ($ar_buf2[2]=="M") {
|
||||
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024*1024;
|
||||
} elseif ($ar_buf2[2]=="K") {
|
||||
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024;
|
||||
}
|
||||
}
|
||||
} elseif (!preg_match("/^cpu[0-9]+ /", $line) && $was) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$ncpu = $this->grabkey('hw.ncpu');
|
||||
if (($ncpu === "") || !($ncpu >= 1)) {
|
||||
$ncpu = 1;
|
||||
}
|
||||
$ncpu = max($ncpu, count($cpuarray));
|
||||
|
||||
$model = $this->grabkey('machdep.cpu_brand');
|
||||
$model2 = $this->grabkey('hw.model');
|
||||
if ($cpuspeed = $this->grabkey('machdep.tsc_freq')) {
|
||||
$speed = round($cpuspeed / 1000000);
|
||||
} else {
|
||||
$speed = "";
|
||||
}
|
||||
|
||||
for ($cpu = 0 ; $cpu < $ncpu ; $cpu++) {
|
||||
$dev = new CpuDevice();
|
||||
|
||||
if (isset($cpuarray[$cpu]['model'])) {
|
||||
$dev->setModel($cpuarray[$cpu]['model']);
|
||||
} elseif ($model !== "") {
|
||||
$dev->setModel($model);
|
||||
} elseif ($model2 !== "") {
|
||||
$dev->setModel($model2);
|
||||
}
|
||||
if (isset($cpuarray[$cpu]['speed'])) {
|
||||
$dev->setCpuSpeed($cpuarray[$cpu]['speed']);
|
||||
} elseif ($speed !== "") {
|
||||
$dev->setCpuSpeed($speed);
|
||||
}
|
||||
if (isset($cpuarray[$cpu]['cache'])) {
|
||||
$dev->setCache($cpuarray[$cpu]['cache']);
|
||||
}
|
||||
if (($ncpu == 1) && PSI_LOAD_BAR) {
|
||||
$dev->setLoad($this->cpuusage());
|
||||
}
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get icon name
|
||||
*
|
||||
@@ -146,14 +250,17 @@ class NetBSD extends BSDCommon
|
||||
*
|
||||
* @see BSDCommon::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
parent::build();
|
||||
$this->_distroicon();
|
||||
$this->_network();
|
||||
$this->_uptime();
|
||||
$this->_processes();
|
||||
if (!$this->blockname || $this->blockname==='vitals') {
|
||||
$this->_distroicon();
|
||||
$this->_processes();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user