* 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 AIX OS class
|
||||
* @author Krzysztof Paz (kpaz@gazeta.pl) based on HPUX of Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2011 Krzysztof Paz
|
||||
* @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.AIX.inc.php 287 2009-06-26 12:11:59Z Krzysztof Paz, IBM POLSKA
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,13 +20,20 @@
|
||||
* @package PSI AIX OS class
|
||||
* @author Krzysztof Paz (kpaz@gazeta.pl) based on Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2011 Krzysztof Paz
|
||||
* @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 AIX extends OS
|
||||
{
|
||||
/**
|
||||
* uptime command result.
|
||||
*/
|
||||
private $_uptime = null;
|
||||
|
||||
/**
|
||||
* prtconf command result.
|
||||
*/
|
||||
private $_aixdata = array();
|
||||
|
||||
/**
|
||||
@@ -35,34 +42,17 @@ class AIX 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('hostname', '', $ret)) {
|
||||
$this->sys->setHostname($ret);
|
||||
}
|
||||
} */
|
||||
$this->sys->setHostname(getenv('SERVER_NAME'));
|
||||
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IBM AIX Version
|
||||
* @return void
|
||||
@@ -81,8 +71,8 @@ class AIX extends OS
|
||||
*/
|
||||
private function _uptime()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
|
||||
if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $buf, $ar_buf) || preg_match("/up (\d+) day,\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];
|
||||
@@ -91,17 +81,6 @@ class AIX extends OS
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Users
|
||||
* @return void
|
||||
*/
|
||||
private function _users()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('who', '| wc -l', $buf, PSI_DEBUG)) {
|
||||
$this->sys->setUsers($buf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processor Load
|
||||
* optionally create a loadbar
|
||||
@@ -109,8 +88,8 @@ class AIX extends OS
|
||||
*/
|
||||
private function _loadavg()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
|
||||
if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
|
||||
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
|
||||
if (preg_match("/average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
|
||||
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
|
||||
}
|
||||
}
|
||||
@@ -305,7 +284,7 @@ class AIX extends OS
|
||||
$mounts = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (CommonFunctions::executeProgram('mount', '-v', $s, PSI_DEBUG)) {
|
||||
$lines = preg_split("/\n/", $s, -1, PREG_SPLIT_NO_EMPTY);
|
||||
while (list(, $line) = each($lines)) {
|
||||
foreach ($lines as $line) {
|
||||
$a = preg_split('/ /', $line, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$fsdev[$a[0]] = $a[4];
|
||||
}
|
||||
@@ -339,7 +318,7 @@ class AIX extends OS
|
||||
|
||||
/**
|
||||
* IBM AIX informations by K.PAZ
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
private function readaixdata()
|
||||
{
|
||||
@@ -357,25 +336,34 @@ class AIX extends OS
|
||||
*
|
||||
* @see PSI_Interface_OS::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->error->addError("WARN", "The AIX 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->_cpuinfo();
|
||||
$this->_pci();
|
||||
$this->_ide();
|
||||
$this->_scsi();
|
||||
$this->_usb();
|
||||
$this->_network();
|
||||
$this->_memory();
|
||||
$this->_filesystems();
|
||||
$this->error->addWarning("The AIX 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();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='hardware') {
|
||||
$this->_cpuinfo();
|
||||
$this->_pci();
|
||||
$this->_ide();
|
||||
$this->_scsi();
|
||||
$this->_usb();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI Android 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.Linux.inc.php 712 2012-12-05 14:09:18Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,18 +20,33 @@
|
||||
* @package PSI Android 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
|
||||
*/
|
||||
class Android extends Linux
|
||||
{
|
||||
/**
|
||||
* call parent constructor
|
||||
* holds the data from /system/build.prop file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public function __construct()
|
||||
private $_buildprop = null;
|
||||
|
||||
/**
|
||||
* reads the data from /system/build.prop file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _get_buildprop()
|
||||
{
|
||||
parent::__construct();
|
||||
if ($this->_buildprop === null) {
|
||||
if (!CommonFunctions::rfts('/system/build.prop', $this->_buildprop, 0, 4096, false)) {
|
||||
CommonFunctions::rfts('/system//build.prop', $this->_buildprop, 0, 4096, false); //fix some access issues
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_buildprop;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,16 +54,25 @@ class Android extends Linux
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _kernel()
|
||||
protected function _kernel()
|
||||
{
|
||||
if (CommonFunctions::rfts('/proc/version', $strBuf, 1)) {
|
||||
if (preg_match('/version (.*?) /', $strBuf, $ar_buf)) {
|
||||
$result = $ar_buf[1];
|
||||
if (CommonFunctions::executeProgram('uname', '-r', $strBuf, false)) {
|
||||
$result = $strBuf;
|
||||
if (CommonFunctions::executeProgram('uname', '-v', $strBuf, PSI_DEBUG)) {
|
||||
if (preg_match('/SMP/', $strBuf)) {
|
||||
$result .= ' (SMP)';
|
||||
}
|
||||
$this->sys->setKernel($result);
|
||||
}
|
||||
if (CommonFunctions::executeProgram('uname', '-m', $strBuf, PSI_DEBUG)) {
|
||||
$result .= ' '.$strBuf;
|
||||
}
|
||||
$this->sys->setKernel($result);
|
||||
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1) && preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
|
||||
$result = $ar_buf[1];
|
||||
if (preg_match('/SMP/', $strBuf)) {
|
||||
$result .= ' (SMP)';
|
||||
}
|
||||
$this->sys->setKernel($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +81,7 @@ class Android extends Linux
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _users()
|
||||
protected function _users()
|
||||
{
|
||||
$this->sys->setUsers(1);
|
||||
}
|
||||
@@ -67,9 +91,10 @@ class Android extends Linux
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _filesystems()
|
||||
protected function _filesystems()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('df', '2>/dev/null ', $df, PSI_DEBUG)) {
|
||||
$notwas = true;
|
||||
if (CommonFunctions::executeProgram('df', '2>/dev/null ', $df, PSI_DEBUG) && preg_match("/\s+[0-9\.]+[KMGT]\s+/", $df)) {
|
||||
$df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (CommonFunctions::executeProgram('mount', '', $mount, PSI_DEBUG)) {
|
||||
$mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
|
||||
@@ -130,10 +155,17 @@ class Android extends Linux
|
||||
}
|
||||
}
|
||||
$this->sys->setDiskDevices($dev);
|
||||
$notwas = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($notwas) { // try Linux df style
|
||||
$arrResult = Parser::df("-P 2>/dev/null", false);
|
||||
foreach ($arrResult as $dev) {
|
||||
$this->sys->setDiskDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,18 +173,17 @@ class Android extends Linux
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _distro()
|
||||
protected function _distro()
|
||||
{
|
||||
$buf = "";
|
||||
if (CommonFunctions::rfts('/system/build.prop', $lines, 0, 4096, false)
|
||||
&& preg_match('/^ro\.build\.version\.release=([^\n]+)/m', $lines, $ar_buf)) {
|
||||
if (($lines = $this->_get_buildprop()) && preg_match('/^ro\.build\.version\.release=([^\n]+)/m', $lines, $ar_buf)) {
|
||||
$buf = trim($ar_buf[1]);
|
||||
}
|
||||
if (is_null($buf) || ($buf == "")) {
|
||||
if (($buf === null) || ($buf == "")) {
|
||||
$this->sys->setDistribution('Android');
|
||||
} else {
|
||||
if (preg_match('/^(\d+\.\d+)/', $buf, $ver)
|
||||
&& ($list = @parse_ini_file(APP_ROOT."/data/osnames.ini", true))
|
||||
&& ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))
|
||||
&& isset($list['Android'][$ver[1]])) {
|
||||
$buf.=' '.$list['Android'][$ver[1]];
|
||||
}
|
||||
@@ -166,14 +197,14 @@ class Android extends Linux
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _machine()
|
||||
protected function _machine()
|
||||
{
|
||||
if (CommonFunctions::rfts('/system/build.prop', $lines, 0, 4096, false)) {
|
||||
if ($lines = $this->_get_buildprop()) {
|
||||
$buf = "";
|
||||
if (preg_match('/^ro\.product\.manufacturer=([^\n]+)/m', $lines, $ar_buf)) {
|
||||
if (preg_match('/^ro\.product\.manufacturer=([^\n]+)/m', $lines, $ar_buf) && (trim($ar_buf[1]) !== "unknown")) {
|
||||
$buf .= ' '.trim($ar_buf[1]);
|
||||
}
|
||||
if (preg_match('/^ro\.product\.model=([^\n]+)/m', $lines, $ar_buf) && (trim($buf) !== trim($ar_buf[1]))) {
|
||||
if (preg_match('/^ro\.product\.model=([^\n]+)/m', $lines, $ar_buf) && (trim($ar_buf[1]) !== trim($buf))) {
|
||||
$buf .= ' '.trim($ar_buf[1]);
|
||||
}
|
||||
if (preg_match('/^ro\.semc\.product\.name=([^\n]+)/m', $lines, $ar_buf)) {
|
||||
@@ -188,7 +219,7 @@ class Android extends Linux
|
||||
/**
|
||||
* PCI devices
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
private function _pci()
|
||||
{
|
||||
@@ -205,50 +236,40 @@ class Android extends Linux
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* USB devices
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _usb()
|
||||
{
|
||||
if (file_exists('/dev/bus/usb') && CommonFunctions::executeProgram('lsusb', '', $bufr, false)) {
|
||||
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe as $buf) {
|
||||
$device = preg_split("/ /", $buf, 6);
|
||||
if (isset($device[5]) && trim($device[5]) != "") {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName(trim($device[5]));
|
||||
$this->sys->setUsbDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_OS::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_distro();
|
||||
$this->_hostname();
|
||||
$this->_ip();
|
||||
$this->_kernel();
|
||||
$this->_machine();
|
||||
$this->_uptime();
|
||||
$this->_users();
|
||||
$this->_cpuinfo();
|
||||
$this->_pci();
|
||||
$this->_usb();
|
||||
$this->_i2c();
|
||||
$this->_network();
|
||||
$this->_memory();
|
||||
$this->_filesystems();
|
||||
$this->_loadavg();
|
||||
$this->_processes();
|
||||
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->_machine();
|
||||
$this->_cpuinfo();
|
||||
$this->_virtualizer();
|
||||
$this->_pci();
|
||||
$this->_usb();
|
||||
$this->_i2c();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI BSDCommon 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.BSDCommon.inc.php 621 2012-07-29 18:49:04Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -21,68 +21,72 @@
|
||||
* @package PSI BSDCommon 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
|
||||
*/
|
||||
abstract class BSDCommon extends OS
|
||||
{
|
||||
/**
|
||||
* Assoc array of all CPUs loads.
|
||||
*/
|
||||
private $_cpu_loads = null;
|
||||
|
||||
/**
|
||||
* content of the syslog
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_dmesg = array();
|
||||
private $_dmesg = null;
|
||||
|
||||
/**
|
||||
* regexp1 for cpu information out of the syslog
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_CPURegExp1 = "";
|
||||
private $_CPURegExp1 = "//";
|
||||
|
||||
/**
|
||||
* regexp2 for cpu information out of the syslog
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_CPURegExp2 = "";
|
||||
private $_CPURegExp2 = "//";
|
||||
|
||||
/**
|
||||
* regexp1 for scsi information out of the syslog
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_SCSIRegExp1 = "";
|
||||
private $_SCSIRegExp1 = "//";
|
||||
|
||||
/**
|
||||
* regexp2 for scsi information out of the syslog
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_SCSIRegExp2 = "";
|
||||
private $_SCSIRegExp2 = "//";
|
||||
|
||||
/**
|
||||
* regexp3 for scsi information out of the syslog
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_SCSIRegExp3 = "//";
|
||||
|
||||
/**
|
||||
* regexp1 for pci information out of the syslog
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_PCIRegExp1 = "";
|
||||
private $_PCIRegExp1 = "//";
|
||||
|
||||
/**
|
||||
* regexp1 for pci information out of the syslog
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_PCIRegExp2 = "";
|
||||
|
||||
/**
|
||||
* call parent constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
private $_PCIRegExp2 = "//";
|
||||
|
||||
/**
|
||||
* setter for cpuregexp1
|
||||
@@ -132,6 +136,18 @@ abstract class BSDCommon extends OS
|
||||
$this->_SCSIRegExp2 = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for scsiregexp3
|
||||
*
|
||||
* @param string $value value to set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setSCSIRegExp3($value)
|
||||
{
|
||||
$this->_SCSIRegExp3 = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for pciregexp1
|
||||
*
|
||||
@@ -163,12 +179,12 @@ abstract class BSDCommon extends OS
|
||||
*/
|
||||
protected function readdmesg()
|
||||
{
|
||||
if (count($this->_dmesg) === 0) {
|
||||
if (PSI_OS != "Darwin") {
|
||||
if (CommonFunctions::rfts('/var/run/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/log/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/run/dmesg.boot', $buf)) { // Once again but with debug
|
||||
$parts = preg_split("/rebooting|Uptime/", $buf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$this->_dmesg = preg_split("/\n/", $parts[count($parts) - 1], -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
if ($this->_dmesg === null) {
|
||||
if ((PSI_OS != 'Darwin') && (CommonFunctions::rfts('/var/run/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/log/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/run/dmesg.boot', $buf))) { // Once again but with debug
|
||||
$parts = preg_split("/rebooting|Uptime/", $buf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$this->_dmesg = preg_split("/\n/", $parts[count($parts) - 1], -1, PREG_SPLIT_NO_EMPTY);
|
||||
} else {
|
||||
$this->_dmesg = array();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,8 +215,8 @@ abstract class BSDCommon extends OS
|
||||
*/
|
||||
protected 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('hostname', '', $buf, PSI_DEBUG)) {
|
||||
$this->sys->setHostname($buf);
|
||||
@@ -208,24 +224,6 @@ abstract class BSDCommon extends OS
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IP of the Canonical Host Name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kernel Version
|
||||
*
|
||||
@@ -234,19 +232,98 @@ abstract class BSDCommon extends OS
|
||||
protected function kernel()
|
||||
{
|
||||
$s = $this->grabkey('kern.version');
|
||||
$a = preg_split('/:/', $s);
|
||||
$this->sys->setKernel($a[0].$a[1].':'.$a[2]);
|
||||
$a = preg_split('/:/', $s, 4);
|
||||
if (isset($a[3])) {
|
||||
if (preg_match('/^(\d{2} [A-Z]{3});/', $a[3], $abuf) // eg. 19:58 GMT;...
|
||||
|| preg_match('/^(\d{2} [A-Z]{3} \d{4})/', $a[3], $abuf)) { // eg. 26:31 PDT 2019...
|
||||
$this->sys->setKernel($a[0].$a[1].':'.$a[2].':'.$abuf[1]);
|
||||
} else {
|
||||
$this->sys->setKernel($a[0].$a[1].':'.$a[2]);
|
||||
}
|
||||
} elseif (isset($a[2])) {
|
||||
$this->sys->setKernel($a[0].$a[1].':'.$a[2]);
|
||||
} else {
|
||||
$this->sys->setKernel($s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Users
|
||||
* Virtualizer info
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function users()
|
||||
private function virtualizer()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('who', '| wc -l', $buf, PSI_DEBUG)) {
|
||||
$this->sys->setUsers($buf);
|
||||
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
||||
$testvirt = $this->sys->getVirtualizer();
|
||||
$novm = true;
|
||||
foreach ($testvirt as $virtkey=>$virtvalue) if ($virtvalue) {
|
||||
$novm = false;
|
||||
break;
|
||||
}
|
||||
// Detect QEMU cpu
|
||||
if ($novm && isset($testvirt["cpuid:QEMU"])) {
|
||||
$this->sys->setVirtualizer('qemu'); // QEMU
|
||||
$novm = false;
|
||||
}
|
||||
|
||||
if ($novm && isset($testvirt["hypervisor"])) {
|
||||
$this->sys->setVirtualizer('unknown');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CPU usage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function cpuusage()
|
||||
{
|
||||
if (($this->_cpu_loads === null)) {
|
||||
$this->_cpu_loads = array();
|
||||
if (PSI_OS != 'Darwin') {
|
||||
if ($fd = $this->grabkey('kern.cp_time')) {
|
||||
// Find out the CPU load
|
||||
// user + sys = load
|
||||
// total = total
|
||||
if (preg_match($this->_CPURegExp2, $fd, $res) && (sizeof($res) > 4)) {
|
||||
$load = $res[2] + $res[3] + $res[4]; // cpu.user + cpu.sys
|
||||
$total = $res[2] + $res[3] + $res[4] + $res[5]; // cpu.total
|
||||
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour)
|
||||
sleep(1);
|
||||
$fd = $this->grabkey('kern.cp_time');
|
||||
if (preg_match($this->_CPURegExp2, $fd, $res) && (sizeof($res) > 4)) {
|
||||
$load2 = $res[2] + $res[3] + $res[4];
|
||||
$total2 = $res[2] + $res[3] + $res[4] + $res[5];
|
||||
if ($total2 != $total) {
|
||||
$this->_cpu_loads['cpu'] = (100 * ($load2 - $load)) / ($total2 - $total);
|
||||
} else {
|
||||
$this->_cpu_loads['cpu'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ncpu = $this->grabkey('hw.ncpu');
|
||||
if (($ncpu !== "") && ($ncpu >= 1) && CommonFunctions::executeProgram('ps', "-A -o %cpu", $pstable, false) && !empty($pstable)) {
|
||||
$pslines = preg_split("/\n/", $pstable, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($pslines) && (count($pslines)>1) && (trim($pslines[0])==="%CPU")) {
|
||||
array_shift($pslines);
|
||||
$sum = 0;
|
||||
foreach ($pslines as $psline) {
|
||||
$sum+=str_replace(',', '.', trim($psline));
|
||||
}
|
||||
$this->_cpu_loads['cpu'] = min($sum/$ncpu, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->_cpu_loads['cpu'])) {
|
||||
return $this->_cpu_loads['cpu'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,23 +338,11 @@ abstract class BSDCommon extends OS
|
||||
$s = $this->grabkey('vm.loadavg');
|
||||
$s = preg_replace('/{ /', '', $s);
|
||||
$s = preg_replace('/ }/', '', $s);
|
||||
$s = str_replace(',', '.', $s);
|
||||
$this->sys->setLoad($s);
|
||||
if (PSI_LOAD_BAR && (PSI_OS != "Darwin")) {
|
||||
if ($fd = $this->grabkey('kern.cp_time')) {
|
||||
// Find out the CPU load
|
||||
// user + sys = load
|
||||
// total = total
|
||||
preg_match($this->_CPURegExp2, $fd, $res);
|
||||
$load = $res[2] + $res[3] + $res[4]; // cpu.user + cpu.sys
|
||||
$total = $res[2] + $res[3] + $res[4] + $res[5]; // cpu.total
|
||||
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour)
|
||||
sleep(1);
|
||||
$fd = $this->grabkey('kern.cp_time');
|
||||
preg_match($this->_CPURegExp2, $fd, $res);
|
||||
$load2 = $res[2] + $res[3] + $res[4];
|
||||
$total2 = $res[2] + $res[3] + $res[4] + $res[5];
|
||||
$this->sys->setLoadPercent((100 * ($load2 - $load)) / ($total2 - $total));
|
||||
}
|
||||
|
||||
if (PSI_LOAD_BAR) {
|
||||
$this->sys->setLoadPercent($this->cpuusage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,37 +354,153 @@ abstract class BSDCommon extends OS
|
||||
protected function cpuinfo()
|
||||
{
|
||||
$dev = new CpuDevice();
|
||||
$dev->setModel($this->grabkey('hw.model'));
|
||||
$cpumodel = $this->grabkey('hw.model');
|
||||
$dev->setModel($cpumodel);
|
||||
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^QEMU Virtual CPU version /', $cpumodel)) {
|
||||
$this->sys->setVirtualizer("cpuid:QEMU", false);
|
||||
}
|
||||
|
||||
$notwas = true;
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if ($notwas) {
|
||||
if (preg_match("/".$this->_CPURegExp1."/", $line, $ar_buf)) {
|
||||
$dev->setCpuSpeed(round($ar_buf[2]));
|
||||
$notwas = false;
|
||||
$regexps = preg_split("/\n/", $this->_CPURegExp1, -1, PREG_SPLIT_NO_EMPTY); // multiple regexp separated by \n
|
||||
foreach ($regexps as $regexp) {
|
||||
if (preg_match($regexp, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
|
||||
if ($dev->getCpuSpeed() == 0) {
|
||||
$dev->setCpuSpeed(round($ar_buf[2]));
|
||||
}
|
||||
$notwas = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (preg_match("/ Origin| Features/", $line, $ar_buf)) {
|
||||
if (preg_match("/ Features2[ ]*=.*<(.*)>/", $line, $ar_buf)) {
|
||||
if (preg_match("/^\s+Origin| Features/", $line, $ar_buf)) {
|
||||
if (preg_match("/^\s+Origin[ ]*=[ ]*\"(.+)\"/", $line, $ar_buf)) {
|
||||
$dev->setVendorId($ar_buf[1]);
|
||||
} elseif (preg_match("/ Features2[ ]*=.*<(.+)>/", $line, $ar_buf)) {
|
||||
$feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($feats as $feat) {
|
||||
if (($feat=="vmx") || ($feat=="svm")) {
|
||||
$dev->setVirt($feat);
|
||||
break 2;
|
||||
} elseif ($feat=="hv") {
|
||||
if ($dev->getVirt() === null) {
|
||||
$dev->setVirt('hypervisor');
|
||||
}
|
||||
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
||||
$this->sys->setVirtualizer("hypervisor", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
|
||||
$ncpu = $this->grabkey('hw.ncpu');
|
||||
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
|
||||
if (($ncpu === "") || !($ncpu >= 1)) {
|
||||
$ncpu = 1;
|
||||
}
|
||||
if (($ncpu == 1) && PSI_LOAD_BAR) {
|
||||
$dev->setLoad($this->cpuusage());
|
||||
}
|
||||
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Machine information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function machine()
|
||||
{
|
||||
if ((PSI_OS == 'NetBSD') || (PSI_OS == 'OpenBSD')) {
|
||||
$buffer = array();
|
||||
if (PSI_OS == 'NetBSD') { // NetBSD
|
||||
$buffer['Manufacturer'] = $this->grabkey('machdep.dmi.system-vendor');
|
||||
$buffer['Model'] = $this->grabkey('machdep.dmi.system-product');
|
||||
$buffer['Product'] = $this->grabkey('machdep.dmi.board-product');
|
||||
$buffer['SMBIOSBIOSVersion'] = $this->grabkey('machdep.dmi.bios-version');
|
||||
$buffer['ReleaseDate'] = $this->grabkey('machdep.dmi.bios-date');
|
||||
} else { // OpenBSD
|
||||
$buffer['Manufacturer'] = $this->grabkey('hw.vendor');
|
||||
$buffer['Model'] = $this->grabkey('hw.product');
|
||||
$buffer['Product'] = "";
|
||||
$buffer['SMBIOSBIOSVersion'] = "";
|
||||
$buffer['ReleaseDate'] = "";
|
||||
}
|
||||
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
||||
$vendor_array = array();
|
||||
$vendor_array[] = $buffer['Model'];
|
||||
$vendor_array[] = trim($buffer['Manufacturer']." ".$buffer['Model']);
|
||||
if (PSI_OS == 'NetBSD') { // NetBSD
|
||||
$vendor_array[] = $this->grabkey('machdep.dmi.board-vendor');
|
||||
$vendor_array[] = $this->grabkey('machdep.dmi.bios-vendor');
|
||||
}
|
||||
$virt = CommonFunctions::decodevirtualizer($vendor_array);
|
||||
if ($virt !== null) {
|
||||
$this->sys->setVirtualizer($virt);
|
||||
}
|
||||
}
|
||||
|
||||
$buf = "";
|
||||
if (($buffer['Manufacturer'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^System manufacturer$|^Not Specified$/i", $buf2=trim($buffer['Manufacturer'])) && ($buf2 !== "")) {
|
||||
$buf .= ' '.$buf2;
|
||||
}
|
||||
|
||||
if (($buffer['Model'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^System Product Name$|^Not Specified$/i", $buf2=trim($buffer['Model'])) && ($buf2 !== "")) {
|
||||
$model = $buf2;
|
||||
$buf .= ' '.$buf2;
|
||||
}
|
||||
if (($buffer['Product'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^BaseBoard Product Name$|^Not Specified$|^Default string$/i", $buf2=trim($buffer['Product'])) && ($buf2 !== "")) {
|
||||
if ($buf2 !== $model) {
|
||||
$buf .= '/'.$buf2;
|
||||
} elseif (isset($buffer['SystemFamily']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Family$|^Not Specified$/i", $buf2=trim($buffer['SystemFamily'])) && ($buf2 !== "")) {
|
||||
$buf .= '/'.$buf2;
|
||||
}
|
||||
}
|
||||
|
||||
$bver = "";
|
||||
$brel = "";
|
||||
if (($buf2=trim($buffer['SMBIOSBIOSVersion'])) !== "") {
|
||||
$bver .= ' '.$buf2;
|
||||
}
|
||||
if ($buffer['ReleaseDate'] !== "") {
|
||||
if (preg_match("/^(\d{4})(\d{2})(\d{2})$/", $buffer['ReleaseDate'], $dateout)) {
|
||||
$brel .= ' '.$dateout[2].'/'.$dateout[3].'/'.$dateout[1];
|
||||
} elseif (preg_match("/^\d{2}\/\d{2}\/\d{4}$/", $buffer['ReleaseDate'])) {
|
||||
$brel .= ' '.$buffer['ReleaseDate'];
|
||||
}
|
||||
}
|
||||
if ((trim($bver) !== "") || (trim($brel) !== "")) {
|
||||
$buf .= ', BIOS'.$bver.$brel;
|
||||
}
|
||||
|
||||
if (trim($buf) !== "") {
|
||||
$this->sys->setMachine(trim($buf));
|
||||
}
|
||||
} elseif ((PSI_OS == 'FreeBSD') && defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
||||
$vendorid = $this->grabkey('hw.hv_vendor');
|
||||
if (trim($vendorid) === "") {
|
||||
foreach ($this->readdmesg() as $line) if (preg_match("/^Hypervisor: Origin = \"(.+)\"/", $line, $ar_buf)) {
|
||||
if (trim($ar_buf[1]) !== "") {
|
||||
$vendorid = $ar_buf[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trim($vendorid) !== "") {
|
||||
$virt = CommonFunctions::decodevirtualizer($vendorid);
|
||||
if ($virt !== null) {
|
||||
$this->sys->setVirtualizer($virt);
|
||||
} else {
|
||||
$this->sys->setVirtualizer('unknown');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SCSI devices
|
||||
* get the scsi device information out of dmesg
|
||||
@@ -329,16 +510,22 @@ abstract class BSDCommon extends OS
|
||||
protected function scsi()
|
||||
{
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match("/".$this->_SCSIRegExp1."/", $line, $ar_buf)) {
|
||||
if (preg_match($this->_SCSIRegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1].": ".$ar_buf[2]);
|
||||
$dev->setName($ar_buf[1].": ".trim($ar_buf[2]));
|
||||
$this->sys->setScsiDevices($dev);
|
||||
} elseif (preg_match("/".$this->_SCSIRegExp2."/", $line, $ar_buf)) {
|
||||
} elseif (preg_match($this->_SCSIRegExp2, $line, $ar_buf) && (sizeof($ar_buf) > 1)) {
|
||||
/* duplication security */
|
||||
$notwas = true;
|
||||
foreach ($this->sys->getScsiDevices() as $finddev) {
|
||||
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) {
|
||||
$finddev->setCapacity($ar_buf[2] * 2048 * 1.049);
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if (isset($ar_buf[3]) && ($ar_buf[3]==="G")) {
|
||||
$finddev->setCapacity($ar_buf[2] * 1024 * 1024 * 1024);
|
||||
} elseif (isset($ar_buf[2])) {
|
||||
$finddev->setCapacity($ar_buf[2] * 1024 * 1024);
|
||||
}
|
||||
}
|
||||
$notwas = false;
|
||||
break;
|
||||
}
|
||||
@@ -346,15 +533,43 @@ abstract class BSDCommon extends OS
|
||||
if ($notwas) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setCapacity($ar_buf[2] * 2048 * 1.049);
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if (isset($ar_buf[3]) && ($ar_buf[3]==="G")) {
|
||||
$dev->setCapacity($ar_buf[2] * 1024 * 1024 * 1024);
|
||||
} elseif (isset($ar_buf[2])) {
|
||||
$dev->setCapacity($ar_buf[2] * 1024 * 1024);
|
||||
}
|
||||
}
|
||||
$this->sys->setScsiDevices($dev);
|
||||
}
|
||||
} elseif (preg_match($this->_SCSIRegExp3, $line, $ar_buf) && (sizeof($ar_buf) > 1)) {
|
||||
/* duplication security */
|
||||
$notwas = true;
|
||||
foreach ($this->sys->getScsiDevices() as $finddev) {
|
||||
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) {
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
||||
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
||||
if (isset($ar_buf[2])) $finddev->setSerial(trim($ar_buf[2]));
|
||||
}
|
||||
$notwas = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($notwas) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
||||
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
||||
if (isset($ar_buf[2])) $dev->setSerial(trim($ar_buf[2]));
|
||||
}
|
||||
$this->sys->setScsiDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* cleaning */
|
||||
foreach ($this->sys->getScsiDevices() as $finddev) {
|
||||
if (strpos($finddev->getName(), ': ') !== false)
|
||||
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
|
||||
if (strpos($finddev->getName(), ': ') !== false)
|
||||
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,13 +627,13 @@ abstract class BSDCommon extends OS
|
||||
*/
|
||||
protected function pci()
|
||||
{
|
||||
if (!is_array($results = Parser::lspci(false)) || !is_array($results = $this->pciconf())) {
|
||||
if ((!$results = Parser::lspci(false)) && (!$results = $this->pciconf())) {
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match("/".$this->_PCIRegExp1."/", $line, $ar_buf)) {
|
||||
if (preg_match($this->_PCIRegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1].": ".$ar_buf[2]);
|
||||
$results[] = $dev;
|
||||
} elseif (preg_match("/".$this->_PCIRegExp2."/", $line, $ar_buf)) {
|
||||
} elseif (preg_match($this->_PCIRegExp2, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1].": ".$ar_buf[2]);
|
||||
$results[] = $dev;
|
||||
@@ -441,23 +656,27 @@ abstract class BSDCommon extends OS
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match('/^(ad[0-9]+): (.*)MB <(.*)> (.*) (.*)/', $line, $ar_buf)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1].": ".$ar_buf[3]);
|
||||
$dev->setCapacity($ar_buf[2] * 1024);
|
||||
$dev->setName($ar_buf[1].": ".trim($ar_buf[3]));
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
$dev->setCapacity($ar_buf[2] * 1024 * 1024);
|
||||
}
|
||||
$this->sys->setIdeDevices($dev);
|
||||
} elseif (preg_match('/^(acd[0-9]+): (.*) <(.*)> (.*)/', $line, $ar_buf)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1].": ".$ar_buf[3]);
|
||||
$dev->setName($ar_buf[1].": ".trim($ar_buf[3]));
|
||||
$this->sys->setIdeDevices($dev);
|
||||
} elseif (preg_match('/^(ada[0-9]+): <(.*)> (.*)/', $line, $ar_buf)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1].": ".$ar_buf[2]);
|
||||
$dev->setName($ar_buf[1].": ".trim($ar_buf[2]));
|
||||
$this->sys->setIdeDevices($dev);
|
||||
} elseif (preg_match('/^(ada[0-9]+): (.*)MB \((.*)\)/', $line, $ar_buf)) {
|
||||
/* duplication security */
|
||||
$notwas = true;
|
||||
foreach ($this->sys->getIdeDevices() as $finddev) {
|
||||
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) {
|
||||
$finddev->setCapacity($ar_buf[2] * 1024);
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
$finddev->setCapacity($ar_buf[2] * 1024 * 1024);
|
||||
}
|
||||
$notwas = false;
|
||||
break;
|
||||
}
|
||||
@@ -465,7 +684,31 @@ abstract class BSDCommon extends OS
|
||||
if ($notwas) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setCapacity($ar_buf[2] * 1024);
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
$dev->setCapacity($ar_buf[2] * 1024 * 1024);
|
||||
}
|
||||
$this->sys->setIdeDevices($dev);
|
||||
}
|
||||
} elseif (preg_match('/^(ada[0-9]+): Serial Number (.*)/', $line, $ar_buf)) {
|
||||
/* duplication security */
|
||||
$notwas = true;
|
||||
foreach ($this->sys->getIdeDevices() as $finddev) {
|
||||
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) {
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
||||
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
||||
$finddev->setSerial(trim($ar_buf[2]));
|
||||
}
|
||||
$notwas = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($notwas) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
||||
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
||||
$finddev->setSerial(trim($ar_buf[2]));
|
||||
}
|
||||
$this->sys->setIdeDevices($dev);
|
||||
}
|
||||
}
|
||||
@@ -530,7 +773,19 @@ abstract class BSDCommon extends OS
|
||||
*/
|
||||
protected function usb()
|
||||
{
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
$notwas = true;
|
||||
if ((PSI_OS == 'FreeBSD') && CommonFunctions::executeProgram('usbconfig', '', $bufr, false)) {
|
||||
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match('/^(ugen[0-9]+\.[0-9]+): <([^,]*)(.*)> at (usbus[0-9]+)/', $line, $ar_buf)) {
|
||||
$notwas = false;
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[2]);
|
||||
$this->sys->setUSBDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($notwas) foreach ($this->readdmesg() as $line) {
|
||||
// if (preg_match('/^(ugen[0-9\.]+): <(.*)> (.*) (.*)/', $line, $ar_buf)) {
|
||||
// $dev->setName($ar_buf[1].": ".$ar_buf[2]);
|
||||
if (preg_match('/^(u[a-z]+[0-9]+): <([^,]*)(.*)> on (usbus[0-9]+)/', $line, $ar_buf)) {
|
||||
@@ -566,27 +821,60 @@ abstract class BSDCommon extends OS
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UpTime
|
||||
* time the system is running
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function uptime()
|
||||
{
|
||||
if ($kb = $this->grabkey('kern.boottime')) {
|
||||
if (preg_match("/sec = ([0-9]+)/", $kb, $buf)) { // format like: { sec = 1096732600, usec = 885425 } Sat Oct 2 10:56:40 2004
|
||||
$this->sys->setUptime(time() - $buf[1]);
|
||||
} else {
|
||||
date_default_timezone_set('UTC');
|
||||
$kbt = strtotime($kb);
|
||||
if (($kbt !== false) && ($kbt != -1)) {
|
||||
$this->sys->setUptime(time() - $kbt); // format like: Sat Oct 2 10:56:40 2004
|
||||
} else {
|
||||
$this->sys->setUptime(time() - $kb); // format like: 1096732600
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_OS::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->distro();
|
||||
$this->memory();
|
||||
$this->ide();
|
||||
$this->pci();
|
||||
$this->cpuinfo();
|
||||
$this->filesystems();
|
||||
$this->kernel();
|
||||
$this->users();
|
||||
$this->loadavg();
|
||||
$this->hostname();
|
||||
$this->ip();
|
||||
$this->scsi();
|
||||
$this->usb();
|
||||
if (!$this->blockname || $this->blockname==='vitals') {
|
||||
$this->distro();
|
||||
$this->hostname();
|
||||
$this->kernel();
|
||||
$this->_users();
|
||||
$this->loadavg();
|
||||
$this->uptime();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='hardware') {
|
||||
$this->machine();
|
||||
$this->cpuinfo();
|
||||
$this->virtualizer();
|
||||
$this->pci();
|
||||
$this->ide();
|
||||
$this->scsi();
|
||||
$this->usb();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->filesystems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI Darwin 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.Darwin.inc.php 638 2012-08-24 09:40:48Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -21,7 +21,7 @@
|
||||
* @package PSI Darwin 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
|
||||
*/
|
||||
@@ -30,13 +30,13 @@ class Darwin extends BSDCommon
|
||||
/**
|
||||
* define the regexp for log parser
|
||||
*/
|
||||
/* public function __construct()
|
||||
/* public function __construct($blockname = false)
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct($blockname);
|
||||
$this->error->addWarning("The Darwin version of phpSysInfo is a work in progress, some things currently don't work!");
|
||||
$this->setCPURegExp1("CPU: (.*) \((.*)-MHz (.*)\)");
|
||||
$this->setCPURegExp1("/CPU: (.*) \((.*)-MHz (.*)\)/");
|
||||
$this->setCPURegExp2("/(.*) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/");
|
||||
$this->setSCSIRegExp1("^(.*): <(.*)> .*SCSI.*device");
|
||||
$this->setSCSIRegExp1("/^(.*): <(.*)> .*SCSI.*device/");
|
||||
} */
|
||||
|
||||
/**
|
||||
@@ -89,25 +89,6 @@ class Darwin extends BSDCommon
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UpTime
|
||||
* time the system is running
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _uptime()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('sysctl', '-n kern.boottime', $a, PSI_DEBUG)) {
|
||||
$tmp = explode(" ", $a);
|
||||
if ($tmp[0]=="{") { /* kern.boottime= { sec = 1096732600, usec = 885425 } Sat Oct 2 10:56:40 2004 */
|
||||
$data = trim($tmp[3], ",");
|
||||
$this->sys->setUptime(time() - $data);
|
||||
} else { /* kern.boottime= 1096732600 */
|
||||
$this->sys->setUptime(time() - $a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get CPU information
|
||||
*
|
||||
@@ -116,12 +97,12 @@ class Darwin extends BSDCommon
|
||||
protected function cpuinfo()
|
||||
{
|
||||
$dev = new CpuDevice();
|
||||
if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) {
|
||||
$dev->setModel(preg_replace('/Processor type: /', '', $buf));
|
||||
if (CommonFunctions::executeProgram('hostinfo', '', $buf, PSI_DEBUG) && ($buf !== '') && preg_match('/^Processor type:[ ]+(.+)$/m', $buf, $proc) && (($proc[1] = trim($proc[1])) !== '')) {
|
||||
$dev->setModel($proc[1]);
|
||||
$buf=$this->grabkey('hw.model');
|
||||
if (!is_null($buf) && (trim($buf) != "")) {
|
||||
if (($buf !== null) && (trim($buf) != "")) {
|
||||
$this->sys->setMachine(trim($buf));
|
||||
if (CommonFunctions::rfts(APP_ROOT.'/data/ModelTranslation.txt', $buffer)) {
|
||||
if (CommonFunctions::rftsdata('ModelTranslation.txt', $buffer)) {
|
||||
$buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($buffer as $line) {
|
||||
$ar_buf = preg_split("/:/", $line, 3);
|
||||
@@ -134,12 +115,12 @@ class Darwin extends BSDCommon
|
||||
}
|
||||
}
|
||||
$buf=$this->grabkey('machdep.cpu.brand_string');
|
||||
if (!is_null($buf) && (trim($buf) != "") &&
|
||||
if (($buf !== null) && (trim($buf) != "") &&
|
||||
((trim($buf) != "i486 (Intel 80486)") || ($dev->getModel() == ""))) {
|
||||
$dev->setModel(trim($buf));
|
||||
}
|
||||
$buf=$this->grabkey('machdep.cpu.features');
|
||||
if (!is_null($buf) && (trim($buf) != "")) {
|
||||
if (($buf !== null) && (trim($buf) != "")) {
|
||||
if (preg_match("/ VMX/", $buf)) {
|
||||
$dev->setVirt("vmx");
|
||||
} elseif (preg_match("/ SVM/", $buf)) {
|
||||
@@ -151,17 +132,21 @@ class Darwin extends BSDCommon
|
||||
$dev->setBusSpeed(round($this->grabkey('hw.busfrequency') / 1000000));
|
||||
$bufn=$this->grabkey('hw.cpufrequency_min');
|
||||
$bufx=$this->grabkey('hw.cpufrequency_max');
|
||||
if (!is_null($bufn) && (trim($bufn) != "") && !is_null($bufx) && (trim($bufx) != "") && ($bufn != $bufx)) {
|
||||
if (($bufn !== null) && (trim($bufn) != "") && ($bufx !== null) && (trim($bufx) != "") && ($bufn != $bufx)) {
|
||||
$dev->setCpuSpeedMin(round($bufn / 1000000));
|
||||
$dev->setCpuSpeedMax(round($bufx / 1000000));
|
||||
}
|
||||
$buf=$this->grabkey('hw.l2cachesize');
|
||||
if (!is_null($buf) && (trim($buf) != "")) {
|
||||
if ($buf !== "") {
|
||||
$dev->setCache(round($buf));
|
||||
}
|
||||
$ncpu = $this->grabkey('hw.ncpu');
|
||||
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
|
||||
if (($ncpu === "") || !($ncpu >= 1)) {
|
||||
$ncpu = 1;
|
||||
}
|
||||
if (($ncpu == 1) && PSI_LOAD_BAR) {
|
||||
$dev->setLoad($this->cpuusage());
|
||||
}
|
||||
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
@@ -238,6 +223,18 @@ class Darwin extends BSDCommon
|
||||
if (!preg_match('/"USB Product Name" = "([^"]*)"/', $line, $ar_buf))
|
||||
$ar_buf = preg_split("/[\s@]+/", $line, 19);
|
||||
$dev->setName(trim($ar_buf[1]));
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if (preg_match('/"USB Vendor Name" = "([^"]*)"/', $line, $ar_buf)) {
|
||||
$dev->setManufacturer(trim($ar_buf[1]));
|
||||
}
|
||||
if (preg_match('/"USB Product Name" = "([^"]*)"/', $line, $ar_buf)) {
|
||||
$dev->setProduct(trim($ar_buf[1]));
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL
|
||||
&& preg_match('/"USB Serial Number" = "([^"]*)"/', $line, $ar_buf)) {
|
||||
$dev->setSerial(trim($ar_buf[1]));
|
||||
}
|
||||
}
|
||||
$this->sys->setUsbDevices($dev);
|
||||
}
|
||||
}
|
||||
@@ -267,60 +264,63 @@ class Darwin extends BSDCommon
|
||||
*/
|
||||
protected function memory()
|
||||
{
|
||||
$s = $this->grabkey('hw.memsize');
|
||||
if (CommonFunctions::executeProgram('vm_stat', '', $pstat, PSI_DEBUG)) {
|
||||
// calculate free memory from page sizes (each page = 4096)
|
||||
if (preg_match('/^Pages free:\s+(\S+)/m', $pstat, $free_buf)) {
|
||||
if (preg_match('/^Anonymous pages:\s+(\S+)/m', $pstat, $anon_buf)
|
||||
&& preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)
|
||||
&& preg_match('/^File-backed pages:\s+(\S+)/m', $pstat, $fileb_buf)) {
|
||||
// OS X 10.9 or never
|
||||
$this->sys->setMemFree($free_buf[1] * 4 * 1024);
|
||||
$this->sys->setMemApplication(($anon_buf[1]+$wire_buf[1]) * 4 * 1024);
|
||||
$this->sys->setMemCache($fileb_buf[1] * 4 * 1024);
|
||||
if (preg_match('/^Pages occupied by compressor:\s+(\S+)/m', $pstat, $compr_buf)) {
|
||||
$this->sys->setMemBuffer($compr_buf[1] * 4 * 1024);
|
||||
}
|
||||
} else {
|
||||
if (preg_match('/^Pages speculative:\s+(\S+)/m', $pstat, $spec_buf)) {
|
||||
$this->sys->setMemFree(($free_buf[1]+$spec_buf[1]) * 4 * 1024);
|
||||
if (($s = $this->grabkey('hw.memsize')) > 0) {
|
||||
$this->sys->setMemTotal($s);
|
||||
if (CommonFunctions::executeProgram('vm_stat', '', $pstat, PSI_DEBUG)) {
|
||||
// calculate free memory from page sizes (each page = 4096)
|
||||
if (preg_match('/^Pages free:\s+(\S+)/m', $pstat, $free_buf)) {
|
||||
if (preg_match('/^Anonymous pages:\s+(\S+)/m', $pstat, $anon_buf)
|
||||
&& preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)
|
||||
&& preg_match('/^File-backed pages:\s+(\S+)/m', $pstat, $fileb_buf)) {
|
||||
// OS X 10.9 or never
|
||||
$this->sys->setMemFree($free_buf[1] * 4 * 1024);
|
||||
$this->sys->setMemApplication(($anon_buf[1]+$wire_buf[1]) * 4 * 1024);
|
||||
$this->sys->setMemCache($fileb_buf[1] * 4 * 1024);
|
||||
if (preg_match('/^Pages occupied by compressor:\s+(\S+)/m', $pstat, $compr_buf)) {
|
||||
$this->sys->setMemBuffer($compr_buf[1] * 4 * 1024);
|
||||
}
|
||||
} else {
|
||||
$this->sys->setMemFree($free_buf[1] * 4 * 1024);
|
||||
}
|
||||
$appMemory = 0;
|
||||
if (preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)) {
|
||||
$appMemory += $wire_buf[1] * 4 * 1024;
|
||||
}
|
||||
if (preg_match('/^Pages active:\s+(\S+)/m', $pstat, $active_buf)) {
|
||||
$appMemory += $active_buf[1] * 4 * 1024;
|
||||
}
|
||||
$this->sys->setMemApplication($appMemory);
|
||||
if (preg_match('/^Pages speculative:\s+(\S+)/m', $pstat, $spec_buf)) {
|
||||
$this->sys->setMemFree(($free_buf[1]+$spec_buf[1]) * 4 * 1024);
|
||||
} else {
|
||||
$this->sys->setMemFree($free_buf[1] * 4 * 1024);
|
||||
}
|
||||
$appMemory = 0;
|
||||
if (preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)) {
|
||||
$appMemory += $wire_buf[1] * 4 * 1024;
|
||||
}
|
||||
if (preg_match('/^Pages active:\s+(\S+)/m', $pstat, $active_buf)) {
|
||||
$appMemory += $active_buf[1] * 4 * 1024;
|
||||
}
|
||||
$this->sys->setMemApplication($appMemory);
|
||||
|
||||
if (preg_match('/^Pages inactive:\s+(\S+)/m', $pstat, $inactive_buf)) {
|
||||
$this->sys->setMemCache($inactive_buf[1] * 4 * 1024);
|
||||
if (preg_match('/^Pages inactive:\s+(\S+)/m', $pstat, $inactive_buf)) {
|
||||
$this->sys->setMemCache($inactive_buf[1] * 4 * 1024);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$lines = preg_split("/\n/", $pstat, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$ar_buf = preg_split("/\s+/", $lines[1], 19);
|
||||
$this->sys->setMemFree($ar_buf[2] * 4 * 1024);
|
||||
}
|
||||
} else {
|
||||
$lines = preg_split("/\n/", $pstat, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$ar_buf = preg_split("/\s+/", $lines[1], 19);
|
||||
$this->sys->setMemFree($ar_buf[2] * 4 * 1024);
|
||||
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
||||
}
|
||||
|
||||
$this->sys->setMemTotal($s);
|
||||
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
||||
|
||||
if (CommonFunctions::executeProgram('sysctl', 'vm.swapusage | colrm 1 22', $swapBuff, PSI_DEBUG)) {
|
||||
$swap1 = preg_split('/M/', $swapBuff);
|
||||
$swap2 = preg_split('/=/', $swap1[1]);
|
||||
$swap3 = preg_split('/=/', $swap1[2]);
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName('SWAP');
|
||||
$dev->setMountPoint('SWAP');
|
||||
$dev->setFsType('swap');
|
||||
$dev->setTotal($swap1[0] * 1024 * 1024);
|
||||
$dev->setUsed($swap2[1] * 1024 * 1024);
|
||||
$dev->setFree($swap3[1] * 1024 * 1024);
|
||||
$this->sys->setSwapDevices($dev);
|
||||
if (($swap = $this->grabkey("vm.swapusage")) > 0) {
|
||||
$swap0 = preg_split('/M/', $swap);
|
||||
$swap1 = preg_split('/=/', $swap0[0]);
|
||||
$swap2 = preg_split('/=/', $swap0[1]);
|
||||
$swap3 = preg_split('/=/', $swap0[2]);
|
||||
if (($swap=str_replace(',', '.', trim($swap1[1]))) > 0) {
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName('SWAP');
|
||||
$dev->setMountPoint('SWAP');
|
||||
$dev->setFsType('swap');
|
||||
$dev->setTotal($swap * 1024 * 1024);
|
||||
$dev->setUsed(str_replace(',', '.', trim($swap2[1])) * 1024 * 1024);
|
||||
$dev->setFree(str_replace(',', '.', trim($swap3[1])) * 1024 * 1024);
|
||||
$this->sys->setSwapDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ class Darwin extends BSDCommon
|
||||
$lines = preg_split("/\n/", $netstat, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($lines as $line) {
|
||||
$ar_buf = preg_split("/\s+/", $line, 10);
|
||||
if (! empty($ar_buf[0])) {
|
||||
if (!empty($ar_buf[0])) {
|
||||
$dev = new NetDevice();
|
||||
$dev->setName($ar_buf[0]);
|
||||
$dev->setTxBytes($ar_buf[8]);
|
||||
@@ -366,14 +366,25 @@ class Darwin extends BSDCommon
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS) && (CommonFunctions::executeProgram('ifconfig', $ar_buf[0].' 2>/dev/null', $bufr2, PSI_DEBUG))) {
|
||||
$bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe2 as $buf2) {
|
||||
if (preg_match('/^\s+ether\s+(\S+)/i', $buf2, $ar_buf2))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', $ar_buf2[1]));
|
||||
elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2))
|
||||
if (preg_match('/^\s+ether\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)
|
||||
} 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))
|
||||
&& !preg_match('/^fe80::/i', $ar_buf2[1]))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
&& ($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))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].$unit.'b/s '.strtolower($ar_buf3[1]));
|
||||
else
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].$unit.'b/s');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->sys->setNetDevices($dev);
|
||||
@@ -390,28 +401,37 @@ class Darwin extends BSDCommon
|
||||
protected function distro()
|
||||
{
|
||||
$this->sys->setDistributionIcon('Darwin.png');
|
||||
if (!CommonFunctions::executeProgram('system_profiler', 'SPSoftwareDataType', $buffer, PSI_DEBUG)) {
|
||||
if ((!CommonFunctions::executeProgram('system_profiler', 'SPSoftwareDataType', $buffer, PSI_DEBUG) || !preg_match('/\n\s*System Version:/', $buffer))
|
||||
&& (!CommonFunctions::executeProgram('sw_vers', '', $buffer, PSI_DEBUG) || !preg_match('/^ProductName:/', $buffer))) {
|
||||
parent::distro();
|
||||
} else {
|
||||
$arrBuff = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($arrBuff as $line) {
|
||||
$arrLine = preg_split("/:/", $line, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (trim($arrLine[0]) === "System Version") {
|
||||
$distro = trim($arrLine[1]);
|
||||
|
||||
if (preg_match('/(^Mac OS)|(^OS X)/', $distro)) {
|
||||
$this->sys->setDistributionIcon('Apple.png');
|
||||
if (preg_match('/((^Mac OS X Server)|(^Mac OS X)|(^OS X Server)|(^OS X)) (\d+\.\d+)/', $distro, $ver)
|
||||
&& ($list = @parse_ini_file(APP_ROOT."/data/osnames.ini", true))
|
||||
&& isset($list['OS X'][$ver[6]])) {
|
||||
$distro.=' '.$list['OS X'][$ver[6]];
|
||||
$distro_tmp = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($distro_tmp as $info) {
|
||||
$info_tmp = preg_split('/:/', $info, 2);
|
||||
if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "") &&
|
||||
isset($distro_tmp[1]) && ($distro_tmp[1] !== null) && (trim($distro_tmp[1]) != "")) {
|
||||
$distro_arr[trim($info_tmp[0])] = trim($info_tmp[1]);
|
||||
}
|
||||
}
|
||||
if (isset($distro_arr['ProductName']) && isset($distro_arr['ProductVersion']) && isset($distro_arr['BuildVersion'])) {
|
||||
$distro_arr['System Version'] = $distro_arr['ProductName'].' '.$distro_arr['ProductVersion'].' ('.$distro_arr['BuildVersion'].')';
|
||||
}
|
||||
if (isset($distro_arr['System Version'])) {
|
||||
$distro = $distro_arr['System Version'];
|
||||
if (preg_match('/^Mac OS |^OS X |^macOS |^iPhone OS |^Mac OS$|^OS X$|^macOS$|^iPhone OS$/', $distro)) {
|
||||
$this->sys->setDistributionIcon('Apple.png');
|
||||
if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) ((\d+)\.\d+)/', $distro, $ver)
|
||||
&& ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) {
|
||||
if (isset($list['macOS'][$ver[2]])) {
|
||||
$distro.=' '.$list['macOS'][$ver[2]];
|
||||
} elseif (isset($list['macOS'][$ver[3]])) {
|
||||
$distro.=' '.$list['macOS'][$ver[3]];
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys->setDistribution($distro);
|
||||
|
||||
return;
|
||||
}
|
||||
$this->sys->setDistribution($distro);
|
||||
} else {
|
||||
parent::distro();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -451,14 +471,19 @@ class Darwin extends BSDCommon
|
||||
*
|
||||
* @see PSI_Interface_OS::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
parent::build();
|
||||
$this->_uptime();
|
||||
$this->_network();
|
||||
$this->_processes();
|
||||
$this->_tb();
|
||||
if (!$this->blockname || $this->blockname==='vitals') {
|
||||
$this->_processes();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='hardware') {
|
||||
$this->_tb();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI DragonFly 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.DragonFly.inc.php 287 2009-06-26 12:11:59Z bigmichi1 $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,7 +20,7 @@
|
||||
* @package PSI DragonFly 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,33 +29,20 @@ class DragonFly extends BSDCommon
|
||||
/**
|
||||
* define the regexp for log parser
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($blockname = false)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setCPURegExp1("^cpu(.*)\, (.*) MHz");
|
||||
$this->setCPURegExp2("^(.*) at scsibus.*: <(.*)> .*");
|
||||
$this->setSCSIRegExp2("^(da[0-9]): (.*)MB ");
|
||||
$this->setPCIRegExp1("/(.*): <(.*)>(.*) (pci|legacypci)[0-9]$/");
|
||||
parent::__construct($blockname);
|
||||
$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/\n/^CPU: (.*) \((.*)-MHz (.*)\)/"); // multiple regexp separated by \n
|
||||
$this->setCPURegExp2("/^(.*) at scsibus.*: <(.*)> .*/");
|
||||
$this->setSCSIRegExp2("/^(da[0-9]+): (.*)MB /");
|
||||
$this->setPCIRegExp1("/(.*): <(.*)>(.*) (pci|legacypci)[0-9]+$/");
|
||||
$this->setPCIRegExp2("/(.*): <(.*)>.* at [0-9\.]+$/");
|
||||
}
|
||||
|
||||
/**
|
||||
* UpTime
|
||||
* time the system is running
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _uptime()
|
||||
{
|
||||
$a = $this->grab_key('kern.boottime');
|
||||
preg_match("/sec = ([0-9]+)/", $a, $buf);
|
||||
$this->sys->setUptime(time() - $buf[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* get network information
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
private function _network()
|
||||
{
|
||||
@@ -66,7 +53,7 @@ class DragonFly 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[5]) || ($ar_buf_n[5] === "0"))) {
|
||||
$dev = new NetDevice();
|
||||
$dev->setName($ar_buf_b[0]);
|
||||
$dev->setTxBytes($ar_buf_b[8]);
|
||||
@@ -81,16 +68,16 @@ class DragonFly extends BSDCommon
|
||||
/**
|
||||
* get the ide information
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
protected function ide()
|
||||
{
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match('/^(.*): (.*) <(.*)> at (ata[0-9]\-(.*)) (.*)/', $line, $ar_buf)) {
|
||||
if (preg_match('/^(.*): (.*) <(.*)> at (ata[0-9]+\-(.*)) (.*)/', $line, $ar_buf)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
if (!preg_match("/^acd[0-9](.*)/", $ar_buf[1])) {
|
||||
$dev->setCapacity($ar_buf[2] * 1024);
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && !preg_match("/^acd[0-9]+(.*)/", $ar_buf[1])) {
|
||||
$dev->setCapacity($ar_buf[2] * 1024 * 1024);
|
||||
}
|
||||
$this->sys->setIdeDevices($dev);
|
||||
}
|
||||
@@ -140,14 +127,17 @@ class DragonFly 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI FreeBSD 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.FreeBSD.inc.php 696 2012-09-09 11:24:04Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,7 +20,7 @@
|
||||
* @package PSI FreeBSD 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,30 +29,18 @@ class FreeBSD 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("/(.*) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/");
|
||||
$this->setSCSIRegExp1("^(.*): <(.*)> .*SCSI.*device");
|
||||
$this->setSCSIRegExp2("^(da[0-9]): (.*)MB ");
|
||||
$this->setPCIRegExp1("/(.*): <(.*)>(.*) pci[0-9]$/");
|
||||
$this->setSCSIRegExp1("/^(.*): <(.*)> .*SCSI.*device/");
|
||||
$this->setSCSIRegExp2("/^(da[0-9]+): (.*)MB /");
|
||||
$this->setSCSIRegExp3("/^(da[0-9]+|cd[0-9]+): Serial Number (.*)/");
|
||||
$this->setPCIRegExp1("/(.*): <(.*)>(.*) pci[0-9]+$/");
|
||||
$this->setPCIRegExp2("/(.*): <(.*)>.* at [.0-9]+ irq/");
|
||||
}
|
||||
|
||||
/**
|
||||
* UpTime
|
||||
* time the system is running
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _uptime()
|
||||
{
|
||||
$s = preg_split('/ /', $this->grabkey('kern.boottime'));
|
||||
$a = preg_replace('/,/', '', $s[3]);
|
||||
$this->sys->setUptime(time() - $a);
|
||||
}
|
||||
|
||||
/**
|
||||
* get network information
|
||||
*
|
||||
@@ -65,11 +53,11 @@ class FreeBSD extends BSDCommon
|
||||
$lines = preg_split("/\n/", $netstat, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($lines as $line) {
|
||||
$ar_buf = preg_split("/\s+/", $line);
|
||||
if (! empty($ar_buf[0])) {
|
||||
if (!empty($ar_buf[0])) {
|
||||
if (preg_match('/^<Link/i', $ar_buf[2])) {
|
||||
$dev = new NetDevice();
|
||||
$dev->setName($ar_buf[0]);
|
||||
if (strlen($ar_buf[3]) < 17) { /* no Address */
|
||||
if ((strlen($ar_buf[3]) < 17) && ($ar_buf[0] != $ar_buf[3])) { /* no MAC or dev name*/
|
||||
if (isset($ar_buf[11]) && (trim($ar_buf[11]) != '')) { /* Idrop column exist*/
|
||||
$dev->setTxBytes($ar_buf[9]);
|
||||
$dev->setRxBytes($ar_buf[6]);
|
||||
@@ -97,14 +85,25 @@ class FreeBSD extends BSDCommon
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS) && (CommonFunctions::executeProgram('ifconfig', $ar_buf[0].' 2>/dev/null', $bufr2, PSI_DEBUG))) {
|
||||
$bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe2 as $buf2) {
|
||||
if (preg_match('/^\s+ether\s+(\S+)/i', $buf2, $ar_buf2))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', $ar_buf2[1]));
|
||||
elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2))
|
||||
if (preg_match('/^\s+ether\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)
|
||||
} 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))
|
||||
&& !preg_match('/^fe80::/i', $ar_buf2[1]))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
&& ($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))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].$unit.'b/s '.strtolower($ar_buf3[1]));
|
||||
else
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].$unit.'b/s');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->sys->setNetDevices($dev);
|
||||
@@ -121,9 +120,19 @@ class FreeBSD extends BSDCommon
|
||||
*/
|
||||
private function _distroicon()
|
||||
{
|
||||
if (extension_loaded('pfSense') && CommonFunctions::rfts('/etc/version', $version, 1, 4096, false) && (trim($version) != '')) { // pfSense detection
|
||||
$this->sys->setDistribution('pfSense '. trim($version));
|
||||
$this->sys->setDistributionIcon('pfSense.png');
|
||||
if (CommonFunctions::rfts('/etc/version', $version, 1, 4096, false) && (($version=trim($version)) != '')) {
|
||||
if (extension_loaded('pfSense')) { // pfSense detection
|
||||
$this->sys->setDistribution('pfSense '. $version);
|
||||
$this->sys->setDistributionIcon('pfSense.png');
|
||||
} elseif (preg_match('/^FreeNAS/i', $version)) { // FreeNAS detection
|
||||
$this->sys->setDistribution($version);
|
||||
$this->sys->setDistributionIcon('FreeNAS.png');
|
||||
} elseif (preg_match('/^TrueNAS/i', $version)) { // TrueNAS detection
|
||||
$this->sys->setDistribution($version);
|
||||
$this->sys->setDistributionIcon('TrueNAS.png');
|
||||
} else {
|
||||
$this->sys->setDistributionIcon('FreeBSD.png');
|
||||
}
|
||||
} else {
|
||||
$this->sys->setDistributionIcon('FreeBSD.png');
|
||||
}
|
||||
@@ -176,15 +185,20 @@ class FreeBSD extends BSDCommon
|
||||
*
|
||||
* @see BSDCommon::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
parent::build();
|
||||
$this->_memoryadditional();
|
||||
$this->_distroicon();
|
||||
$this->_network();
|
||||
$this->_uptime();
|
||||
$this->_processes();
|
||||
if (!$this->blockname || $this->blockname==='vitals') {
|
||||
$this->_distroicon();
|
||||
$this->_processes();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memoryadditional();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
118
root/opt/phpsysinfo/includes/os/class.GNU.inc.php
Normal file
118
root/opt/phpsysinfo/includes/os/class.GNU.inc.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* GNU Class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI GNU class
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2012 phpSysInfo
|
||||
* @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.GNU.inc.php 687 2012-09-06 20:54:49Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* GNU sysinfo class
|
||||
* get all the required information from GNU
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI GNU class
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2022 phpSysInfo
|
||||
* @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 GNU extends Linux
|
||||
{
|
||||
/**
|
||||
* Network devices
|
||||
* includes also rx/tx bytes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _network($bufr = null)
|
||||
{
|
||||
if ($this->sys->getOS() == 'GNU') {
|
||||
if (CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) {
|
||||
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$was = false;
|
||||
$macaddr = "";
|
||||
$dev = null;
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match("/^\/dev\/([^\s:]+)/", $line, $ar_buf) || preg_match("/^([^\s:]+)/", $line, $ar_buf)) {
|
||||
if ($was) {
|
||||
if ($macaddr != "") {
|
||||
$dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
|
||||
}
|
||||
$this->sys->setNetDevices($dev);
|
||||
}
|
||||
$macaddr = "";
|
||||
$dev = new NetDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$was = true;
|
||||
} else {
|
||||
if ($was) {
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
||||
if (preg_match('/^\s+inet address\s+(\S+)$/', $line, $ar_buf)) {
|
||||
$dev->setInfo($ar_buf[1]);
|
||||
} elseif (preg_match('/^\s+hardware addr\s+(\S+)$/', $line, $ar_buf)) {
|
||||
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) {
|
||||
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf[1]));
|
||||
if ($macaddr === '00-00-00-00-00-00') { // empty
|
||||
$macaddr = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($was) {
|
||||
if ($macaddr != "") {
|
||||
$dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
|
||||
}
|
||||
$this->sys->setNetDevices($dev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
parent::_network($bufr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Users
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _users()
|
||||
{
|
||||
if ($this->sys->getOS() == 'GNU') {
|
||||
if (CommonFunctions::executeProgram('who', '', $strBuf, PSI_DEBUG)) {
|
||||
if (strlen($strBuf) > 0) {
|
||||
$lines = preg_split('/\n/', $strBuf);
|
||||
preg_match_all('/^login\s+/m', $strBuf, $ttybuf);
|
||||
if (($who = count($lines)-count($ttybuf[0])) > 0) {
|
||||
$this->sys->setUsers($who);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
parent::_users();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if ($this->sys->getOS() == 'GNU') {
|
||||
$this->error->addWarning("The GNU Hurd version of phpSysInfo is a work in progress, some things currently don't work");
|
||||
}
|
||||
parent::build();
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI HPUX 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.HPUX.inc.php 596 2012-07-05 19:37:48Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,12 +20,17 @@
|
||||
* @package PSI HPUX 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
|
||||
*/
|
||||
class HPUX extends OS
|
||||
{
|
||||
/**
|
||||
* uptime command result.
|
||||
*/
|
||||
private $_uptime = null;
|
||||
|
||||
/**
|
||||
* Virtual Host Name
|
||||
*
|
||||
@@ -33,8 +38,8 @@ class HPUX 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('hostname', '', $ret)) {
|
||||
$this->sys->setHostname($ret);
|
||||
@@ -42,24 +47,6 @@ class HPUX 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HP-UX Version
|
||||
*
|
||||
@@ -80,8 +67,8 @@ class HPUX 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+) days,\s*(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
|
||||
$min = $ar_buf[3];
|
||||
$hours = $ar_buf[2];
|
||||
$days = $ar_buf[1];
|
||||
@@ -90,19 +77,6 @@ class HPUX extends OS
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Users
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _users()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('who', '-q', $ret)) {
|
||||
$who = preg_split('/=/', $ret, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$this->sys->setUsers($who[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processor Load
|
||||
* optionally create a loadbar
|
||||
@@ -111,8 +85,8 @@ class HPUX extends OS
|
||||
*/
|
||||
private function _loadavg()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
|
||||
if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
|
||||
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
|
||||
if (preg_match("/average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
|
||||
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
|
||||
}
|
||||
}
|
||||
@@ -132,31 +106,29 @@ class HPUX 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':
|
||||
case 'cpu':
|
||||
$dev->setModel($arrBuff[1]);
|
||||
$dev->setModel($arrBuff2);
|
||||
break;
|
||||
case 'cpu mhz':
|
||||
case 'clock':
|
||||
$dev->setCpuSpeed($arrBuff[1]);
|
||||
$dev->setCpuSpeed($arrBuff2);
|
||||
break;
|
||||
case 'cycle frequency [hz]':
|
||||
$dev->setCpuSpeed($arrBuff[1] / 1000000);
|
||||
$dev->setCpuSpeed($arrBuff2 / 1000000);
|
||||
break;
|
||||
case 'cpu0clktck':
|
||||
$dev->setCpuSpeed(hexdec($arrBuff[1]) / 1000000); // Linux sparc64
|
||||
$dev->setCpuSpeed(hexdec($arrBuff2) / 1000000); // Linux sparc64
|
||||
break;
|
||||
case 'l2 cache':
|
||||
case 'cache size':
|
||||
$dev->setCache(preg_replace("/[a-zA-Z]/", "", $arrBuff[1]) * 1024);
|
||||
$dev->setCache(preg_replace("/[a-zA-Z]/", "", $arrBuff2) * 1024);
|
||||
break;
|
||||
case 'bogomips':
|
||||
case 'cpu0bogo':
|
||||
$dev->setBogomips($arrBuff[1]);
|
||||
break;
|
||||
$dev->setBogomips($arrBuff2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,19 +144,25 @@ class HPUX extends OS
|
||||
private function _pci()
|
||||
{
|
||||
if (CommonFunctions::rfts('/proc/pci', $bufr)) {
|
||||
$device = false;
|
||||
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe as $buf) {
|
||||
if (preg_match('/Bus/', $buf)) {
|
||||
if (preg_match('/^\s*Bus\s/', $buf)) {
|
||||
$device = true;
|
||||
continue;
|
||||
}
|
||||
if ($device) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName(preg_replace('/\([^\)]+\)\.$/', '', trim($buf)));
|
||||
$this->sys->setPciDevices($dev);
|
||||
/*
|
||||
list($key, $value) = preg_split('/: /', $buf, 2);
|
||||
if (!preg_match('/bridge/i', $key) && !preg_match('/USB/i', $key)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName(preg_replace('/\([^\)]+\)\.$/', '', trim($value)));
|
||||
$this->sys->setPciDevices($dev);
|
||||
}
|
||||
*/
|
||||
$device = false;
|
||||
}
|
||||
}
|
||||
@@ -203,10 +181,10 @@ class HPUX extends OS
|
||||
if (preg_match('/^hd/', $file)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName(trim($file));
|
||||
if (CommonFunctions::rfts("/proc/ide/".$file."/media", $buf, 1)) {
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && CommonFunctions::rfts("/proc/ide/".$file."/media", $buf, 1)) {
|
||||
if (trim($buf) == 'disk') {
|
||||
if (CommonFunctions::rfts("/proc/ide/".$file."/capacity", $buf, 1, 4096, false)) {
|
||||
$dev->setCapacity(trim($buf) * 512 / 1024);
|
||||
$dev->setCapacity(trim($buf) * 512);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,9 +228,11 @@ class HPUX extends OS
|
||||
{
|
||||
if (CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) {
|
||||
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$devnum = -1;
|
||||
$results = array();
|
||||
foreach ($bufe as $buf) {
|
||||
if (preg_match('/^T/', $buf)) {
|
||||
$devnum += 1;
|
||||
$devnum++;
|
||||
$results[$devnum] = "";
|
||||
} elseif (preg_match('/^S:/', $buf)) {
|
||||
list($key, $value) = preg_split('/: /', $buf, 2);
|
||||
@@ -344,7 +324,7 @@ class HPUX extends OS
|
||||
$mounts = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (CommonFunctions::executeProgram('mount', '-v', $s, PSI_DEBUG)) {
|
||||
$lines = preg_split("/\n/", $s, -1, PREG_SPLIT_NO_EMPTY);
|
||||
while (list(, $line) = each($lines)) {
|
||||
foreach ($lines as $line) {
|
||||
$a = preg_split('/ /', $line, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$fsdev[$a[0]] = $a[4];
|
||||
}
|
||||
@@ -381,24 +361,33 @@ class HPUX extends OS
|
||||
*
|
||||
* @see PSI_Interface_OS::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_distro();
|
||||
$this->_hostname();
|
||||
$this->_ip();
|
||||
$this->_kernel();
|
||||
$this->_uptime();
|
||||
$this->_users();
|
||||
$this->_loadavg();
|
||||
$this->_cpuinfo();
|
||||
$this->_pci();
|
||||
$this->_ide();
|
||||
$this->_scsi();
|
||||
$this->_usb();
|
||||
$this->_network();
|
||||
$this->_memory();
|
||||
$this->_filesystems();
|
||||
if (!$this->blockname || $this->blockname==='vitals') {
|
||||
$this->_distro();
|
||||
$this->_hostname();
|
||||
$this->_kernel();
|
||||
$this->_uptime();
|
||||
$this->_users();
|
||||
$this->_loadavg();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='hardware') {
|
||||
$this->_cpuinfo();
|
||||
$this->_pci();
|
||||
$this->_ide();
|
||||
$this->_scsi();
|
||||
$this->_usb();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI Haiku 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.Haiku.inc.php 687 2012-09-06 20:54:49Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,24 +20,16 @@
|
||||
* @package PSI Haiku 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 Haiku extends OS
|
||||
{
|
||||
/**
|
||||
* call parent constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the cpu information
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
protected function _cpuinfo()
|
||||
{
|
||||
@@ -53,21 +45,22 @@ class Haiku extends OS
|
||||
$dev->setModel($ar_buf[1]);
|
||||
$arrLines = preg_split("/\n/", $cpu, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($arrLines as $Line) {
|
||||
if (preg_match("/^\s+Data TLB:\s+(.*)K-byte/", $Line, $Line_buf)) {
|
||||
$dev->setCache(max($Line_buf[1]*1024, $dev->getCache()));
|
||||
} elseif (preg_match("/^\s+Data TLB:\s+(.*)M-byte/", $Line, $Line_buf)) {
|
||||
$dev->setCache(max($Line_buf[1]*1024*1024, $dev->getCache()));
|
||||
} elseif (preg_match("/^\s+Data TLB:\s+(.*)G-byte/", $Line, $Line_buf)) {
|
||||
$dev->setCache(max($Line_buf[1]*1024*1024*1024, $dev->getCache()));
|
||||
if (preg_match("/^\s+Data TLB:\s+(.*)K-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)K-byte/", $Line, $Line_buf)) {
|
||||
$dev->setCache(max(intval($Line_buf[1])*1024, $dev->getCache()));
|
||||
} elseif (preg_match("/^\s+Data TLB:\s+(.*)M-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)M-byte/", $Line, $Line_buf)) {
|
||||
$dev->setCache(max(intval($Line_buf[1])*1024*1024, $dev->getCache()));
|
||||
} elseif (preg_match("/^\s+Data TLB:\s+(.*)G-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)G-byte/", $Line, $Line_buf)) {
|
||||
$dev->setCache(max(intval($Line_buf[1])*1024*1024*1024, $dev->getCache()));
|
||||
} elseif (preg_match("/\s+VMX/", $Line, $Line_buf)) {
|
||||
$dev->setVirt("vmx");
|
||||
} elseif (preg_match("/\s+SVM/", $Line, $Line_buf)) {
|
||||
$dev->setVirt("svm");
|
||||
}
|
||||
}
|
||||
if ($cpuspeed != "")$dev->setCpuSpeed($cpuspeed);
|
||||
if ($cpuspeed != "") {
|
||||
$dev->setCpuSpeed($cpuspeed);
|
||||
}
|
||||
$this->sys->setCpus($dev);
|
||||
//echo ">>>>>".$cpu;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +129,7 @@ class Haiku extends OS
|
||||
private function _kernel()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uname', '-rvm', $ret)) {
|
||||
$this->sys->setKernel($ret);
|
||||
$this->sys->setKernel($ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,19 +156,28 @@ class Haiku extends OS
|
||||
*/
|
||||
private function _uptime()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uptime', '-u', $buf)) {
|
||||
if (preg_match("/^up (\d+) minute[s]?/", $buf, $ar_buf)) {
|
||||
$min = $ar_buf[1];
|
||||
$this->sys->setUptime($min * 60);
|
||||
} elseif (preg_match("/^up (\d+) hour[s]?, (\d+) minute[s]?/", $buf, $ar_buf)) {
|
||||
$min = $ar_buf[2];
|
||||
$hours = $ar_buf[1];
|
||||
$this->sys->setUptime($hours * 3600 + $min * 60);
|
||||
} elseif (preg_match("/^up (\d+) day[s]?, (\d+) hour[s]?, (\d+) minute[s]?/", $buf, $ar_buf)) {
|
||||
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
|
||||
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $buf, $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)) {
|
||||
$min = $ar_buf[2];
|
||||
$hours = $ar_buf[1];
|
||||
$this->sys->setUptime($hours * 3600 + $min * 60);
|
||||
} elseif (preg_match("/up (\d+) day[s]?, (\d+) hour[s]?, (\d+) minute[s]?$/", $buf, $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+) hour[s]?, (\d+) minute[s]?$/", $buf, $ar_buf)) {
|
||||
$min = $ar_buf[2];
|
||||
$hours = $ar_buf[1];
|
||||
$this->sys->setUptime($hours * 3600 + $min * 60);
|
||||
} elseif (preg_match("/up (\d+) minute[s]?$/", $buf, $ar_buf)) {
|
||||
$min = $ar_buf[1];
|
||||
$this->sys->setUptime($min * 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,7 +205,7 @@ class Haiku extends OS
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _users()
|
||||
protected function _users()
|
||||
{
|
||||
$this->sys->setUsers(1);
|
||||
}
|
||||
@@ -215,8 +217,8 @@ class Haiku 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);
|
||||
@@ -227,24 +229,6 @@ class Haiku 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
|
||||
*
|
||||
@@ -256,7 +240,7 @@ class Haiku extends OS
|
||||
if (preg_match("/(.*)bytes free\s+\(used\/max\s+(.*)\s+\/\s+(.*)\)\s*\n\s+\(cached\s+(.*)\)/", $bufr, $ar_buf)) {
|
||||
$this->sys->setMemTotal($ar_buf[3]);
|
||||
$this->sys->setMemFree($ar_buf[1]);
|
||||
$this->sys->setMemCache($ar_buf[4]);
|
||||
$this->sys->setMemCache(min($ar_buf[4], $ar_buf[2]));
|
||||
$this->sys->setMemUsed($ar_buf[2]);
|
||||
}
|
||||
}
|
||||
@@ -310,10 +294,13 @@ class Haiku extends OS
|
||||
{
|
||||
if (CommonFunctions::executeProgram('ifconfig', '', $bufr, PSI_DEBUG)) {
|
||||
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$notwas = true;
|
||||
$was = false;
|
||||
$errors = 0;
|
||||
$drops = 0;
|
||||
$dev = null;
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match("/^(\S+)/", $line, $ar_buf)) {
|
||||
if (!$notwas) {
|
||||
if ($was) {
|
||||
$dev->setErrors($errors);
|
||||
$dev->setDrops($drops);
|
||||
$this->sys->setNetDevices($dev);
|
||||
@@ -322,9 +309,9 @@ class Haiku extends OS
|
||||
$drops = 0;
|
||||
$dev = new NetDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$notwas = false;
|
||||
$was = true;
|
||||
} else {
|
||||
if (!$notwas) {
|
||||
if ($was) {
|
||||
if (preg_match('/\sReceive:\s\d+\spackets,\s(\d+)\serrors,\s(\d+)\sbytes,\s\d+\smcasts,\s(\d+)\sdropped/i', $line, $ar_buf2)) {
|
||||
$errors +=$ar_buf2[1];
|
||||
$drops +=$ar_buf2[3];
|
||||
@@ -336,18 +323,19 @@ class Haiku extends OS
|
||||
}
|
||||
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
||||
if (preg_match('/\sEthernet,\s+Address:\s(\S*)/i', $line, $ar_buf2))
|
||||
$dev->setInfo(preg_replace('/:/', '-', $ar_buf2[1]));
|
||||
elseif (preg_match('/^\s+inet\saddr:\s(\S*),/i', $line, $ar_buf2))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
elseif (preg_match('/^\s+inet6\saddr:\s(\S*),/i', $line, $ar_buf2))
|
||||
if (!preg_match('/^fe80::/i', $ar_buf2[1]))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
if (preg_match('/\sEthernet,\s+Address:\s(\S*)/i', $line, $ar_buf2)) {
|
||||
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $dev->setInfo(preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
|
||||
} elseif (preg_match('/^\s+inet\saddr:\s(\S*),/i', $line, $ar_buf2)) {
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
} elseif (preg_match('/^\s+inet6\saddr:\s(\S*),/i', $line, $ar_buf2)
|
||||
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$notwas) {
|
||||
if ($was) {
|
||||
$dev->setErrors($errors);
|
||||
$dev->setDrops($drops);
|
||||
$this->sys->setNetDevices($dev);
|
||||
@@ -380,24 +368,33 @@ class Haiku extends OS
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->error->addError("WARN", "The Haiku 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->_usb();
|
||||
$this->_cpuinfo();
|
||||
$this->_memory();
|
||||
$this->_filesystems();
|
||||
$this->_network();
|
||||
$this->_processes();
|
||||
$this->error->addWarning("The Haiku 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->_cpuinfo();
|
||||
$this->_pci();
|
||||
$this->_usb();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI 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.OS.inc.php 699 2012-09-15 11:57:13Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
* @package PSI 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
|
||||
*/
|
||||
@@ -28,10 +28,17 @@ abstract class OS implements PSI_Interface_OS
|
||||
/**
|
||||
* object for error handling
|
||||
*
|
||||
* @var Error
|
||||
* @var PSI_Error
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
/**
|
||||
* block name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $blockname = false;
|
||||
|
||||
/**
|
||||
* @var System
|
||||
*/
|
||||
@@ -40,10 +47,12 @@ abstract class OS implements PSI_Interface_OS
|
||||
/**
|
||||
* build the global Error object
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($blockname = false)
|
||||
{
|
||||
$this->error = Error::singleton();
|
||||
$this->error = PSI_Error::singleton();
|
||||
$this->sys = new System();
|
||||
$this->blockname = $blockname;
|
||||
$this->sys->setOS(get_class($this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,6 +66,7 @@ abstract class OS implements PSI_Interface_OS
|
||||
{
|
||||
return PSI_SYSTEM_CODEPAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* get os specific language
|
||||
*
|
||||
@@ -69,6 +79,180 @@ abstract class OS implements PSI_Interface_OS
|
||||
return PSI_SYSTEM_LANG;
|
||||
}
|
||||
|
||||
/**
|
||||
* get block name
|
||||
*
|
||||
* @see PSI_Interface_OS::getBlockName()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlockName()
|
||||
{
|
||||
return $this->blockname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Users
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _users()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('who', '', $strBuf, PSI_DEBUG)) {
|
||||
if (strlen($strBuf) > 0) {
|
||||
$lines = preg_split('/\n/', $strBuf);
|
||||
$this->sys->setUsers(count($lines));
|
||||
}
|
||||
} elseif (CommonFunctions::executeProgram('uptime', '', $buf, PSI_DEBUG) && preg_match("/,\s+(\d+)\s+user[s]?,/", $buf, $ar_buf)) {
|
||||
//} elseif (CommonFunctions::executeProgram('uptime', '', $buf) && preg_match("/,\s+(\d+)\s+user[s]?,\s+load average[s]?:\s+(.*),\s+(.*),\s+(.*)$/", $buf, $ar_buf)) {
|
||||
$this->sys->setUsers($ar_buf[1]);
|
||||
} else {
|
||||
$processlist = CommonFunctions::findglob('/proc/*/cmdline', GLOB_NOSORT);
|
||||
if (is_array($processlist) && (($total = count($processlist)) > 0)) {
|
||||
$count = 0;
|
||||
$buf = "";
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
if (CommonFunctions::rfts($processlist[$i], $buf, 0, 4096, false)) {
|
||||
$name = str_replace(chr(0), ' ', trim($buf));
|
||||
if (preg_match("/^-/", $name)) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($count > 0) {
|
||||
$this->sys->setUsers($count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IP of the Host
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _ip()
|
||||
{
|
||||
if (PSI_USE_VHOST && !defined('PSI_EMU_HOSTNAME')) {
|
||||
if ((CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result)) //is server address defined
|
||||
&& !strstr($result, '.') && strstr($result, ':')) { //is IPv6, quick version of preg_match('/\(([[0-9A-Fa-f\:]+)\)/', $result)
|
||||
$dnsrec = dns_get_record($this->sys->getHostname(), DNS_AAAA);
|
||||
if (isset($dnsrec[0]['ipv6'])) { //is DNS IPv6 record
|
||||
$this->sys->setIp($dnsrec[0]['ipv6']); //from DNS (avoid IPv6 NAT translation)
|
||||
} else {
|
||||
$this->sys->setIp(preg_replace('/^::ffff:/i', '', $result)); //from SERVER_ADDR or LOCAL_ADDR
|
||||
}
|
||||
} else {
|
||||
$this->sys->setIp(gethostbyname($this->sys->getHostname())); //IPv4 only
|
||||
}
|
||||
} elseif (((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) && (CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result))) {
|
||||
$this->sys->setIp(preg_replace('/^::ffff:/i', '', $result));
|
||||
} else {
|
||||
//$this->sys->setIp(gethostbyname($this->sys->getHostname()));
|
||||
$hn = $this->sys->getHostname();
|
||||
$ghbn = gethostbyname($hn);
|
||||
if (defined('PSI_EMU_HOSTNAME') && ($hn === $ghbn)) {
|
||||
$this->sys->setIp(PSI_EMU_HOSTNAME);
|
||||
} else {
|
||||
$this->sys->setIp($ghbn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MEM information from dmidecode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _dmimeminfo()
|
||||
{
|
||||
$dmimd = CommonFunctions::readdmimemdata();
|
||||
if (!empty($dmimd)) {
|
||||
foreach ($dmimd as $mem) {
|
||||
if (isset($mem['Size']) && preg_match('/^(\d+)\s(M|G)B$/', $mem['Size'], $size) && ($size[1] > 0)) {
|
||||
$dev = new HWDevice();
|
||||
$name = '';
|
||||
if (isset($mem['Part Number']) && !preg_match("/^PartNum\d+$/", $part = $mem['Part Number']) && ($part != 'None') && ($part != 'N/A') && ($part != 'Not Specified') && ($part != 'NOT AVAILABLE')) {
|
||||
$name = $part;
|
||||
}
|
||||
if (isset($mem['Locator']) && (($dloc = $mem['Locator']) != 'None') && ($dloc != 'N/A') && ($dloc != 'Not Specified')) {
|
||||
if ($name != '') {
|
||||
$name .= ' - '.$dloc;
|
||||
} else {
|
||||
$name = $dloc;
|
||||
}
|
||||
}
|
||||
if (isset($mem['Bank Locator']) && (($bank = $mem['Bank Locator']) != 'None') && ($bank != 'N/A') && ($bank != 'Not Specified')) {
|
||||
if ($name != '') {
|
||||
$name .= ' in '.$bank;
|
||||
} else {
|
||||
$name = 'Physical Memory in '.$bank;
|
||||
}
|
||||
}
|
||||
if ($name != '') {
|
||||
$dev->setName(trim($name));
|
||||
} else {
|
||||
$dev->setName('Physical Memory');
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if (isset($mem['Manufacturer']) && !preg_match("/^([A-F\d]{4}|[A-F\d]{12}|[A-F\d]{16})$/", $manufacturer = $mem['Manufacturer']) && !preg_match("/^Manufacturer\d+$/", $manufacturer) && !preg_match("/^Mfg \d+$/", $manufacturer) && !preg_match("/^JEDEC ID:/", $manufacturer) && ($manufacturer != 'None') && ($manufacturer != 'N/A') && ($manufacturer != 'Not Specified') && ($manufacturer != 'UNKNOWN')) {
|
||||
$dev->setManufacturer($manufacturer);
|
||||
}
|
||||
if ($size[2] == 'G') {
|
||||
$dev->setCapacity($size[1]*1024*1024*1024);
|
||||
} else {
|
||||
$dev->setCapacity($size[1]*1024*1024);
|
||||
}
|
||||
$memtype = '';
|
||||
if (isset($mem['Type']) && (($type = $mem['Type']) != 'None') && ($type != 'N/A') && ($type != 'Not Specified') && ($type != 'Other') && ($type != 'Unknown') && ($type != '<OUT OF SPEC>')) {
|
||||
if (isset($mem['Speed']) && preg_match('/^(\d+)\s(MHz|MT\/s)/', $mem['Speed'], $speed) && ($speed[1] > 0) && (preg_match('/^(DDR\d*)(.*)/', $type, $dr) || preg_match('/^(SDR)AM(.*)/', $type, $dr))) {
|
||||
if (isset($mem['Minimum Voltage']) && isset($mem['Maximum Voltage']) &&
|
||||
preg_match('/^([\d\.]+)\sV$/', $mem['Minimum Voltage'], $minv) && preg_match('/^([\d\.]+)\sV$/', $mem['Maximum Voltage'], $maxv) &&
|
||||
($minv[1] > 0) && ($maxv[1] >0) && ($minv[1] < $maxv[1])) {
|
||||
$lv = 'L';
|
||||
} else {
|
||||
$lv = '';
|
||||
}
|
||||
if (isset($dr[2])) {
|
||||
$memtype = $dr[1].$lv.'-'.$speed[1].' '.$dr[2];
|
||||
} else {
|
||||
$memtype = $dr[1].$lv.'-'.$speed[1];
|
||||
}
|
||||
} else {
|
||||
$memtype = $type;
|
||||
}
|
||||
}
|
||||
if (isset($mem['Form Factor']) && (($form = $mem['Form Factor']) != 'None') && ($form != 'N/A') && ($form != 'Not Specified') && ($form != 'Other') && ($form != 'Unknown') && !preg_match('/ '.$form.'$/', $memtype)) {
|
||||
$memtype .= ' '.$form;
|
||||
}
|
||||
if (isset($mem['Data Width']) && isset($mem['Total Width']) &&
|
||||
preg_match('/^(\d+)\sbits$/', $mem['Data Width'], $dataw) && preg_match('/^(\d+)\sbits$/', $mem['Total Width'], $totalw) &&
|
||||
($dataw[1] > 0) && ($totalw[1] >0) && ($dataw[1] < $totalw[1])) {
|
||||
$memtype .= ' ECC';
|
||||
}
|
||||
if (isset($mem['Type Detail']) && preg_match('/Registered/', $mem['Type Detail'])) {
|
||||
$memtype .= ' REG';
|
||||
}
|
||||
if (($memtype = trim($memtype)) != '') {
|
||||
$dev->setProduct($memtype);
|
||||
}
|
||||
if (isset($mem['Configured Clock Speed']) && preg_match('/^(\d+)\s(MHz|MT\/s)$/', $mem['Configured Clock Speed'], $clock) && ($clock[1] > 0)) {
|
||||
$dev->setSpeed($clock[1]);
|
||||
}
|
||||
if (isset($mem['Configured Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Configured Voltage'], $voltage) && ($voltage[1] > 0)) {
|
||||
$dev->setVoltage($voltage[1]);
|
||||
}
|
||||
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL &&
|
||||
isset($mem['Serial Number']) && !preg_match("/^SerNum\d+$/", $serial = $mem['Serial Number']) && ($serial != 'None') && ($serial != 'Not Specified')) {
|
||||
$dev->setSerial($serial);
|
||||
}
|
||||
}
|
||||
$this->sys->setMemDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the filled or unfilled (with default values) System object
|
||||
*
|
||||
@@ -79,6 +263,12 @@ abstract class OS implements PSI_Interface_OS
|
||||
final public function getSys()
|
||||
{
|
||||
$this->build();
|
||||
if (!$this->blockname || $this->blockname==='vitals') {
|
||||
$this->_ip();
|
||||
}
|
||||
if ((!$this->blockname || $this->blockname==='hardware') && (PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
|
||||
$this->_dmimeminfo();
|
||||
}
|
||||
|
||||
return $this->sys;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI OpenBSD 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.OpenBSD.inc.php 621 2012-07-29 18:49:04Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,7 +20,7 @@
|
||||
* @package PSI OpenBSD 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 OpenBSD 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("/(.*),(.*),(.*),(.*),(.*)/");
|
||||
$this->setSCSIRegExp1("^(.*) at scsibus.*: <(.*)> .*");
|
||||
$this->setSCSIRegExp2("^(da[0-9]): (.*)MB ");
|
||||
$this->setPCIRegExp1("/(.*) at pci[0-9] .* \"(.*)\"/");
|
||||
$this->setSCSIRegExp1("/^(.*) at scsibus.*: <(.*)> .*/");
|
||||
$this->setSCSIRegExp2("/^(sd[0-9]+): (.*)MB,/");
|
||||
$this->setPCIRegExp1("/(.*) at pci[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,43 @@ class OpenBSD 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->setErrors($ar_buf_n[4] + $ar_buf_n[6]);
|
||||
$dev->setDrops($ar_buf_n[8]);
|
||||
if (sizeof($ar_buf_n) == 9) {
|
||||
$dev->setErrors($ar_buf_n[4] + $ar_buf_n[6]);
|
||||
$dev->setDrops($ar_buf_n[8]);
|
||||
} elseif (sizeof($ar_buf_n) == 8) {
|
||||
$dev->setDrops($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+lladdr\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,13 +104,16 @@ class OpenBSD extends BSDCommon
|
||||
protected function ide()
|
||||
{
|
||||
foreach ($this->readdmesg() as $line) {
|
||||
if (preg_match('/^(.*) at pciide[0-9] (.*): <(.*)>/', $line, $ar_buf)) {
|
||||
if (preg_match('/^(.*) at pciide[0-9]+ (.*): <(.*)>/', $line, $ar_buf)) {
|
||||
$dev = new HWDevice();
|
||||
$dev->setName($ar_buf[0]);
|
||||
// now loop again and find the capacity
|
||||
foreach ($this->readdmesg() as $line2) {
|
||||
if (preg_match("/^(".$ar_buf[0]."): (.*), (.*), (.*)MB, .*$/", $line2, $ar_buf_n)) {
|
||||
$dev->setCapacity($ar_buf_n[4] * 2048 * 1.049);
|
||||
$dev->setName($ar_buf[3]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->sys->setIdeDevices($dev);
|
||||
@@ -107,13 +128,81 @@ class OpenBSD extends BSDCommon
|
||||
*/
|
||||
protected function cpuinfo()
|
||||
{
|
||||
$dev = new CpuDevice();
|
||||
$dev->setModel($this->grabkey('hw.model'));
|
||||
$dev->setCpuSpeed($this->grabkey('hw.cpuspeed'));
|
||||
$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("/(\d+)([KM])B \S+ \S+ L[23] cache$/", $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;
|
||||
}
|
||||
} else {
|
||||
$feats = preg_split("/,/", strtolower($ar_buf[2]), -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($feats as $feat) {
|
||||
if (($feat=="vmx") || ($feat=="svm")) {
|
||||
$cpuarray[$ar_buf[1]]['virt'] = $feat;
|
||||
} elseif ($feat=="hv") {
|
||||
if (!isset($cpuarray[$ar_buf[1]]['virt'])) {
|
||||
$cpuarray[$ar_buf[1]]['virt'] = 'hypervisor';
|
||||
}
|
||||
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
||||
$this->sys->setVirtualizer("hypervisor", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (!preg_match("/^cpu[0-9]+|^mtrr: |^acpitimer[0-9]+: /", $line) && $was) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$ncpu = $this->grabkey('hw.ncpu');
|
||||
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
|
||||
if (($ncpu === "") || !($ncpu >= 1)) {
|
||||
$ncpu = 1;
|
||||
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
|
||||
}
|
||||
$ncpu = max($ncpu, count($cpuarray));
|
||||
|
||||
$model = $this->grabkey('hw.model');
|
||||
$speed = $this->grabkey('hw.cpuspeed');
|
||||
$vendor = $this->grabkey('machdep.cpuvendor');
|
||||
|
||||
for ($cpu = 0 ; $cpu < $ncpu ; $cpu++) {
|
||||
$dev = new CpuDevice();
|
||||
|
||||
if (isset($cpuarray[$cpu]['model'])) {
|
||||
$dev->setModel($cpuarray[$cpu]['model']);
|
||||
} elseif ($model !== "") {
|
||||
$dev->setModel($model);
|
||||
}
|
||||
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 (isset($cpuarray[$cpu]['virt'])) {
|
||||
$dev->setVirt($cpuarray[$cpu]['virt']);
|
||||
}
|
||||
if ($vendor !== "") {
|
||||
$dev->setVendorId($vendor);
|
||||
}
|
||||
if (($ncpu == 1) && PSI_LOAD_BAR) {
|
||||
$dev->setLoad($this->cpuusage());
|
||||
}
|
||||
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
}
|
||||
@@ -161,14 +250,17 @@ class OpenBSD 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI QNX 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.QNX.inc.php 687 2012-09-06 20:54:49Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,31 +20,16 @@
|
||||
* @package PSI QNX 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 QNX extends OS
|
||||
{
|
||||
/**
|
||||
* content of the syslog
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_dmesg = array();
|
||||
|
||||
/**
|
||||
* call parent constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the cpu information
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
protected function _cpuinfo()
|
||||
{
|
||||
@@ -103,23 +88,9 @@ class QNX extends OS
|
||||
if (CommonFunctions::executeProgram('pidin', 'info', $buf)
|
||||
&& preg_match('/^.* BootTime:(.*)/', $buf, $bstart)
|
||||
&& CommonFunctions::executeProgram('date', '', $bstop)) {
|
||||
/* default error handler */
|
||||
if (function_exists('errorHandlerPsi')) {
|
||||
restore_error_handler();
|
||||
}
|
||||
/* fatal errors only */
|
||||
$old_err_rep = error_reporting();
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
$uptime = strtotime($bstop)-strtotime($bstart[1]);
|
||||
if ($uptime > 0) $this->sys->setUptime($uptime);
|
||||
|
||||
/* restore error level */
|
||||
error_reporting($old_err_rep);
|
||||
/* restore error handler */
|
||||
if (function_exists('errorHandlerPsi')) {
|
||||
set_error_handler('errorHandlerPsi');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +99,7 @@ class QNX extends OS
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _users()
|
||||
protected function _users()
|
||||
{
|
||||
$this->sys->setUsers(1);
|
||||
}
|
||||
@@ -140,8 +111,8 @@ class QNX 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);
|
||||
@@ -152,24 +123,6 @@ class QNX 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
|
||||
*
|
||||
@@ -207,20 +160,21 @@ class QNX extends OS
|
||||
{
|
||||
if (CommonFunctions::executeProgram('ifconfig', '', $bufr, PSI_DEBUG)) {
|
||||
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$notwas = true;
|
||||
$was = false;
|
||||
$dev = null;
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match("/^([^\s:]+)/", $line, $ar_buf)) {
|
||||
if (!$notwas) {
|
||||
if ($was) {
|
||||
$this->sys->setNetDevices($dev);
|
||||
}
|
||||
$dev = new NetDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$notwas = false;
|
||||
$was = true;
|
||||
} else {
|
||||
if (!$notwas) {
|
||||
if ($was) {
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
||||
if (preg_match('/^\s+address:\s*(\S+)/i', $line, $ar_buf2)) {
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
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', $line, $ar_buf2))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
|
||||
@@ -228,7 +182,7 @@ class QNX extends OS
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$notwas) {
|
||||
if ($was) {
|
||||
$this->sys->setNetDevices($dev);
|
||||
}
|
||||
}
|
||||
@@ -237,20 +191,29 @@ class QNX extends OS
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->error->addError("WARN", "The QNX 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->_cpuinfo();
|
||||
$this->_memory();
|
||||
$this->_filesystems();
|
||||
$this->_network();
|
||||
$this->error->addWarning("The QNX 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();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='hardware') {
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
857
root/opt/phpsysinfo/includes/os/class.SSH.inc.php
Normal file
857
root/opt/phpsysinfo/includes/os/class.SSH.inc.php
Normal file
@@ -0,0 +1,857 @@
|
||||
<?php
|
||||
/**
|
||||
* SSH Class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI SSH class
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2012 phpSysInfo
|
||||
* @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.SSH.inc.php 687 2012-09-06 20:54:49Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* SSH sysinfo class
|
||||
* get all the required information from SSH
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI SSH class
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2022 phpSysInfo
|
||||
* @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 SSH extends GNU
|
||||
{
|
||||
/**
|
||||
* content of the system status
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_sysstatus = null;
|
||||
|
||||
/**
|
||||
* content of the system performance status
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_sysperformance = null;
|
||||
|
||||
/**
|
||||
* content of the sys ver systeminfo
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_sysversysteminfo = null;
|
||||
|
||||
/**
|
||||
* content of the show status
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_showstatus = null;
|
||||
|
||||
/**
|
||||
* OS type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_ostype = null;
|
||||
|
||||
/**
|
||||
* check system type
|
||||
*/
|
||||
public function __construct($blockname = false)
|
||||
{
|
||||
parent::__construct($blockname);
|
||||
$this->_ostype = $this->sys->getOS();
|
||||
switch ($this->_ostype) {
|
||||
case '4.2BSD':
|
||||
case 'AIX':
|
||||
case 'Darwin':
|
||||
case 'DragonFly':
|
||||
case 'FreeBSD':
|
||||
case 'HI-UX/MPP':
|
||||
case 'Haiku':
|
||||
case 'Minix':
|
||||
case 'NetBSD':
|
||||
case 'OpenBSD':
|
||||
case 'QNX':
|
||||
case 'SunOS':
|
||||
$this->error->addError("__construct()", "OS ".$this->_ostype. " is not supported via SSH");
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
break;
|
||||
case 'SSH':
|
||||
$this->error->addError("__construct()", "SSH connection error");
|
||||
break;
|
||||
default:
|
||||
if ($this->getSystemStatus() !== '') {
|
||||
$this->_ostype = 'FortiOS';
|
||||
$this->sys->setOS('Linux');
|
||||
} elseif ($this->getSysVerSysteminfo() !== '') {
|
||||
$this->_ostype = 'DrayOS';
|
||||
$this->sys->setOS('DrayOS');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get os specific encoding
|
||||
*
|
||||
* @see PSI_Interface_OS::getEncoding()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
// if (($this->_ostype === 'FortiOS') || ($this->_ostype === 'DrayOS') || ($this->_ostype === 'SSH')) {
|
||||
// return 'UTF-8';
|
||||
// }
|
||||
//return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get os specific language
|
||||
*
|
||||
* @see PSI_Interface_OS::getLanguage()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
//return null;
|
||||
}
|
||||
|
||||
private function getSystemStatus()
|
||||
{
|
||||
if ($this->_sysstatus === null) {
|
||||
if (CommonFunctions::executeProgram('get', 'system status', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$this->_sysstatus = substr($resulte, strlen($resulto[1][0]));
|
||||
} else {
|
||||
$this->_sysstatus = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_sysstatus;
|
||||
}
|
||||
|
||||
private function getSystemPerformance()
|
||||
{
|
||||
if ($this->_sysperformance === null) {
|
||||
if (CommonFunctions::executeProgram('get', 'system performance status', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$this->_sysperformance = substr($resulte, strlen($resulto[1][0]));
|
||||
} else {
|
||||
$this->_sysperformance = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_sysperformance;
|
||||
}
|
||||
|
||||
private function getSysVerSysteminfo()
|
||||
{
|
||||
if ($this->_sysversysteminfo === null) {
|
||||
if (CommonFunctions::executeProgram('sys', 'ver systeminfo', $resulte, false, PSI_EXEC_TIMEOUT_INT, '>') && ($resulte !== "")
|
||||
&& preg_match('/([\s\S]+> sys ver systeminfo)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$this->_sysversysteminfo = substr($resulte, strlen($resulto[1][0]));
|
||||
} else {
|
||||
$this->_sysversysteminfo = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_sysversysteminfo;
|
||||
}
|
||||
|
||||
private function getShowStatus()
|
||||
{
|
||||
if ($this->_showstatus === null) {
|
||||
if (CommonFunctions::executeProgram('show', 'status', $resulte, false, PSI_EXEC_TIMEOUT_INT, '>') && ($resulte !== "")
|
||||
&& preg_match('/([\s\S]+> show status)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$this->_showstatus = substr($resulte, strlen($resulto[1][0]));
|
||||
} else {
|
||||
$this->_showstatus = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_showstatus;
|
||||
}
|
||||
/**
|
||||
* Physical memory information and Swap Space information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _memory($mbuf = null, $sbuf = null)
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
if (CommonFunctions::executeProgram('get', 'hardware memory', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
parent::_memory(substr($resulte, strlen($resulto[1][0])));
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (($sysstat = $this->getSysVerSysteminfo()) !== '') {
|
||||
$machine= '';
|
||||
if (preg_match("/ Total memory usage : \d+ % \((\d+)K\/(\d+)K\)/", $sysstat, $buf)) {
|
||||
$this->sys->setMemTotal($buf[2]*1024);
|
||||
$this->sys->setMemUsed($buf[1]*1024);
|
||||
$this->sys->setMemFree(($buf[2]-$buf[1])*1024);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
if (!CommonFunctions::executeProgram('cat', '/proc/meminfo', $mbuf, false) || ($mbuf === "")) {
|
||||
$mbuf = null;
|
||||
}
|
||||
if (!CommonFunctions::executeProgram('cat', '/proc/swaps', $sbuf, false) || ($sbuf === "")) {
|
||||
$sbuf = null;
|
||||
}
|
||||
if (($mbuf !== null) || ($sbuf !== null)) {
|
||||
parent::_memory($mbuf, $sbuf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* USB devices
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _usb($bufu = null)
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
$bufr = '';
|
||||
if (CommonFunctions::executeProgram('fnsysctl', 'cat /proc/bus/usb/devices', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$resulti = substr($resulte, strlen($resulto[1][0]));
|
||||
if (preg_match('/(\n.*[\$#])$/', $resulti, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$bufr = substr($resulti, 0, $resulto[1][1]);
|
||||
if (count(preg_split('/\n/', $bufr, -1, PREG_SPLIT_NO_EMPTY)) >= 2) {
|
||||
parent::_usb($bufr);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::_usb();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Network devices
|
||||
* includes also rx/tx bytes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _network($bufr = null)
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
$bufr = '';
|
||||
if (CommonFunctions::executeProgram('fnsysctl', 'ifconfig', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$resulti = substr($resulte, strlen($resulto[1][0]));
|
||||
if (preg_match('/(\n.*[\$#])$/', $resulti, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$bufr = substr($resulti, 0, $resulto[1][1]);
|
||||
if (count(preg_split('/\n/', $bufr, -1, PREG_SPLIT_NO_EMPTY)) < 2) {
|
||||
$bufr = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($bufr !== '') {
|
||||
parent::_network($bufr);
|
||||
} else {
|
||||
$netdevs = array();
|
||||
if (CommonFunctions::executeProgram('diagnose', 'ip address list', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$strBuf = substr($resulte, strlen($resulto[1][0]));
|
||||
$lines = preg_split('/\n/', $strBuf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($lines as $line) if (preg_match('/^IP=(\S+)->.+ devname=(\S+)$/', $line, $buf)) {
|
||||
if (!isset($netdevs[$buf[2]])) {
|
||||
$netdevs[$buf[2]] = $buf[1];
|
||||
} else {
|
||||
$netdevs[$buf[2]] .= ';'.$buf[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CommonFunctions::executeProgram('diagnose', 'ipv6 address list', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$strBuf = substr($resulte, strlen($resulto[1][0]));
|
||||
$lines = preg_split('/\n/', $strBuf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($lines as $line) if (preg_match('/ devname=(\S+) .+ addr=(\S+)/', $line, $buf)) {
|
||||
if (!preg_match('/^fe80::/i', $buf[2])) {
|
||||
if (!isset($netdevs[$buf[1]])) {
|
||||
$netdevs[$buf[1]] = $buf[2];
|
||||
} else {
|
||||
$netdevs[$buf[1]] .= ';'.$buf[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($netdevs as $netname=>$netinfo) {
|
||||
if (!preg_match('/^vsys_/i', $netname)) {
|
||||
$dev = new NetDevice();
|
||||
// if ($netname === 'root') {
|
||||
// $dev->setName('lo');
|
||||
// } else {
|
||||
$dev->setName($netname);
|
||||
// }
|
||||
$this->sys->setNetDevices($dev);
|
||||
$dev->setInfo($netinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
$macarray = array();
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS) && (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR)) {
|
||||
if (CommonFunctions::executeProgram('sys', 'iface', $resulte, false, PSI_EXEC_TIMEOUT_INT, '>') && ($resulte !== "")
|
||||
&& preg_match('/([\s\S]+> sys iface)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$lines = preg_split("/\n/", substr($resulte, strlen($resulto[1][0])), -1, PREG_SPLIT_NO_EMPTY);
|
||||
$ipaddr = 'LAN';
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match("/^IP Address:\s+([\d\.]+)\s/", trim($line), $ar_buf)) {
|
||||
if ($ipaddr === false) {
|
||||
$ipaddr = $ar_buf[1];
|
||||
}
|
||||
} elseif (preg_match("/^MAC:\s+([\d\-A-F]+)/", trim($line), $ar_buf)) {
|
||||
if ($ipaddr !== '0.0.0.0') {
|
||||
$macarray[$ipaddr] = $ar_buf[1];
|
||||
}
|
||||
$ipaddr = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$lantxrate = false;
|
||||
$lanrxrate = false;
|
||||
if (defined('PSI_SHOW_NETWORK_ACTIVE_SPEED') && PSI_SHOW_NETWORK_ACTIVE_SPEED) {
|
||||
if ((($bufr = $this->getShowStatus()) !== '') && preg_match('/IP Address:[\d\.]+[ ]+Tx Rate:(\d+)[ ]+Rx Rate:(\d+)/m', $bufr, $ar_buf)) {
|
||||
$lantxrate = $ar_buf[1];
|
||||
$lanrxrate = $ar_buf[2];
|
||||
}
|
||||
}
|
||||
|
||||
$notwaslan = true;
|
||||
if (CommonFunctions::executeProgram('show', 'lan', $resulte, false, PSI_EXEC_TIMEOUT_INT, '>') && ($resulte !== "")
|
||||
&& preg_match('/([\s\S]+> show lan)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$lines = preg_split("/\n/", substr($resulte, strlen($resulto[1][0])), -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match("/^\[V\](\S+)\s+([\d\.]+)\s/", trim($line), $ar_buf)) {
|
||||
$dev = new NetDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
||||
$dev->setInfo($ar_buf[2]);
|
||||
if (isset($macarray['LAN'])) {
|
||||
$dev->setInfo($macarray['LAN'].';'.$ar_buf[2]);
|
||||
} else {
|
||||
$dev->setInfo($ar_buf[2]);
|
||||
}
|
||||
}
|
||||
if ($lantxrate !== false) {
|
||||
$dev->setTxRate($lantxrate);
|
||||
}
|
||||
if ($lanrxrate !== false) {
|
||||
$dev->setRxRate($lanrxrate);
|
||||
}
|
||||
$this->sys->setNetDevices($dev);
|
||||
if (preg_match('/^LAN/', $ar_buf[1])) {
|
||||
$notwaslan = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($bufr = $this->getShowStatus()) !== '') {
|
||||
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$last = false;
|
||||
$dev = null;
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match("/^(.+) Status/", trim($line), $ar_buf)) {
|
||||
if (($last !== false) && (($last !== 'LAN') || $notwaslan)) {
|
||||
$this->sys->setNetDevices($dev);
|
||||
}
|
||||
$dev = new NetDevice();
|
||||
$last = preg_replace('/\s+/', '', $ar_buf[1]);
|
||||
$dev->setName($last);
|
||||
} else {
|
||||
if ($last !== false) {
|
||||
if (preg_match('/ IP:([\d\.]+)[ ]+GW/', $line, $ar_buf) || preg_match('/IP Address:([\d\.]+)[ ]+Tx/', $line, $ar_buf)) {
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
||||
if ($last === 'LAN') {
|
||||
if (isset($macarray['LAN'])) {
|
||||
$dev->setInfo($macarray['LAN'].';'.$ar_buf[1]);
|
||||
}
|
||||
if ($lantxrate !== false) {
|
||||
$dev->setTxRate($lantxrate);
|
||||
}
|
||||
if ($lanrxrate !== false) {
|
||||
$dev->setRxRate($lanrxrate);
|
||||
}
|
||||
} elseif (isset($macarray[$ar_buf[1]])) {
|
||||
$dev->setInfo($macarray[$ar_buf[1]].';'.$ar_buf[1]);
|
||||
} else {
|
||||
$dev->setInfo($ar_buf[1]);
|
||||
}
|
||||
}
|
||||
} elseif (preg_match('/TX Packets:\d+[ ]+TX Rate\(bps\):(\d+)[ ]+RX Packets:\d+[ ]+RX Rate\(bps\):(\d+)/', $line, $ar_buf)) {
|
||||
if (defined('PSI_SHOW_NETWORK_ACTIVE_SPEED') && PSI_SHOW_NETWORK_ACTIVE_SPEED) {
|
||||
$dev->setTxRate($ar_buf[1]);
|
||||
$dev->setRxRate($ar_buf[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($last !== false) && (($last !== 'LAN') || $notwaslan)) {
|
||||
$this->sys->setNetDevices($dev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::_network();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CPU information
|
||||
* All of the tags here are highly architecture dependant.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _cpuinfo($bufr = null)
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
if (CommonFunctions::executeProgram('get', 'hardware cpu', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
parent::_cpuinfo(substr($resulte, strlen($resulto[1][0])));
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (preg_match_all("/CPU(\d+) speed:[ ]*(\d+) MHz/m", $sysinfo = $this->getSysVerSysteminfo(), $bufarr)) {
|
||||
foreach ($bufarr[1] as $index=>$nr) {
|
||||
$dev = new CpuDevice();
|
||||
$dev->setModel('CPU'.$nr);
|
||||
$dev->setCpuSpeed($bufarr[2][$index]);
|
||||
if (PSI_LOAD_BAR) {
|
||||
$dev->setLoad($this->_parseProcStat('cpu'.$nr));
|
||||
}
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
// $this->_cpu_loads['cpu'] = $buf[1];
|
||||
// if (preg_match("/CPU1 speed/", $sysinfo)) {
|
||||
// $this->_cpu_loads['cpu0'] = $buf[1];
|
||||
// }
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
if (CommonFunctions::executeProgram('cat', '/proc/cpuinfo', $resulte, false) && ($resulte !== "")) {
|
||||
parent::_cpuinfo($resulte);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Machine
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _machine()
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
if (($sysstat = $this->getSystemStatus()) !== '') {
|
||||
$machine= '';
|
||||
if (preg_match("/^Version: (\S+) v/", $sysstat, $buf)) {
|
||||
$machine = $buf[1];
|
||||
}
|
||||
if (preg_match("/\nSystem Part-Number: (\S+)\n/", $sysstat, $buf)) {
|
||||
$machine .= ' '.$buf[1];
|
||||
}
|
||||
if (preg_match("/\nBIOS version: (\S+)\n/", $sysstat, $buf)) {
|
||||
if (trim($machine) !== '') {
|
||||
$machine .= ', BIOS '.$buf[1];
|
||||
} else {
|
||||
$machine = 'BIOS '.$buf[1];
|
||||
}
|
||||
}
|
||||
$machine = trim($machine);
|
||||
|
||||
if ($machine !== '') {
|
||||
$this->sys->setMachine($machine);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (($sysstat = $this->getSysVerSysteminfo()) !== '') {
|
||||
$machine= '';
|
||||
if (preg_match("/[\r\n]Router Model: (\S+) /", $sysstat, $buf)) {
|
||||
$machine = $buf[1];
|
||||
}
|
||||
if (preg_match("/[\r\n]Revision: (.+)[\r\n]/", $sysstat, $buf)) {
|
||||
$machine .= ' '.$buf[1];
|
||||
}
|
||||
$machine = trim($machine);
|
||||
|
||||
if ($machine !== '') {
|
||||
$this->sys->setMachine($machine);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::_machine();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hostname
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _hostname()
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
// $hostname = PSI_EMU_HOSTNAME;
|
||||
if (preg_match("/\nHostname: ([^\n]+)\n/", $this->getSystemStatus(), $buf)) {
|
||||
$this->sys->setHostname(trim($buf[1]));
|
||||
// $hostname = trim($buf[1]);
|
||||
}
|
||||
|
||||
// $ip = gethostbyname($hostname);
|
||||
// if ($ip != $hostname) {
|
||||
// $this->sys->setHostname(gethostbyaddr($ip));
|
||||
// } else {
|
||||
// $this->sys->setHostname($hostname);
|
||||
// }
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (preg_match("/[\r\n]Router Name: ([^\n\r]+)[\r\n]/", $this->getSysVerSysteminfo(), $buf)) {
|
||||
$this->sys->setHostname(trim($buf[1]));
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::_hostname();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* filesystem information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _filesystems()
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
if (CommonFunctions::executeProgram('fnsysctl', 'df -k', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$resulti = substr($resulte, $resulto[1][1]);
|
||||
$df = preg_split("/\n/", $resulti, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($df as $df_line) {
|
||||
$df_buf1 = preg_split("/(\%\s)/", $df_line, 3);
|
||||
if (count($df_buf1) != 2) {
|
||||
continue;
|
||||
}
|
||||
if (preg_match("/(.*)(\s+)(([0-9]+)(\s+)([0-9]+)(\s+)([\-0-9]+)(\s+)([0-9]+)$)/", $df_buf1[0], $df_buf2)) {
|
||||
$df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]);
|
||||
if (count($df_buf) == 6) {
|
||||
$df_buf[5] = trim($df_buf[5]);
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName(trim($df_buf[0]));
|
||||
if ($df_buf[2] < 0) {
|
||||
$dev->setTotal($df_buf[3] * 1024);
|
||||
$dev->setUsed($df_buf[3] * 1024);
|
||||
} else {
|
||||
$dev->setTotal($df_buf[1] * 1024);
|
||||
$dev->setUsed($df_buf[2] * 1024);
|
||||
if ($df_buf[3]>0) {
|
||||
$dev->setFree($df_buf[3] * 1024);
|
||||
}
|
||||
}
|
||||
if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($df_buf[5]);
|
||||
$dev->setFsType('unknown');
|
||||
$this->sys->setDiskDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (CommonFunctions::executeProgram('nand', 'usage', $resulte, false, PSI_EXEC_TIMEOUT_INT, '>') && ($resulte !== "")
|
||||
&& preg_match('/([\s\S]+> nand usage)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$df = substr($resulte, strlen($resulto[1][0]));
|
||||
|
||||
if (preg_match('/Usecfg/', $df)) { // fix for Vigor2135ac v4.4.2
|
||||
$df = preg_replace("/(cfg|bin)/", "\n$1", substr($resulte, strlen($resulto[1][0])));
|
||||
$percent = '';
|
||||
} else {
|
||||
$percent = '%';
|
||||
}
|
||||
|
||||
$df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($df as $df_line) {
|
||||
if (preg_match("/^(\S+)[ ]+(\d+)[ ]+(\d+)[ ]+(\d+)[ ]+(\d+)".$percent."/", trim($df_line), $df_buf)) {
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName($df_buf[1]);
|
||||
$dev->setTotal($df_buf[2]);
|
||||
$dev->setUsed($df_buf[3]);
|
||||
$dev->setFree($df_buf[4]);
|
||||
$dev->setFsType('NAND');
|
||||
$this->sys->setDiskDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::_filesystems();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Distribution
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _distro()
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'SSH':
|
||||
$this->sys->setOS('Unknown');
|
||||
$this->sys->setDistributionIcon('Unknown.png');
|
||||
break;
|
||||
case 'FortiOS':
|
||||
if (preg_match("/^Version: \S+ (v[^\n]+)\n/", $this->getSystemStatus(), $buf)) {
|
||||
$this->sys->setDistribution('FortiOS '.trim($buf[1]));
|
||||
}
|
||||
$this->sys->setDistributionIcon('FortiOS.png');
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (preg_match("/ Version: ([^\n]+)\n/", $this->getSysVerSysteminfo(), $buf)) {
|
||||
$this->sys->setDistribution('DrayOS '.trim($buf[1]));
|
||||
}
|
||||
$this->sys->setDistributionIcon('DrayOS.png');
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::_distro();
|
||||
}
|
||||
// if ($this->_ostype !== null) {
|
||||
// $this->sys->setDistributionIcon($this->_ostype);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* fill the load for a individual cpu, through parsing /proc/stat for the specified cpu
|
||||
*
|
||||
* @param String $cpuline cpu for which load should be meassured
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function _parseProcStat($cpuline)
|
||||
{
|
||||
if ($this->_cpu_loads === null) {
|
||||
$this->_cpu_loads = array();
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
if (($strBuf = $this->getSystemPerformance()) !== '') {
|
||||
$lines = preg_split('/\n/', $strBuf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($lines as $line) if (preg_match('/^CPU(\d*) states: \d+% user \d+% system \d+% nice (\d+)% idle /', $line, $buf)) {
|
||||
$this->_cpu_loads['cpu'.$buf[1]] = 100-$buf[2];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (preg_match("/CPU usage :[ ]*(\d+) %/", $sysinfo = $this->getSysVerSysteminfo(), $buf)) {
|
||||
$this->_cpu_loads['cpu'] = $buf[1];
|
||||
if (preg_match("/CPU1 speed/", $sysinfo) && !preg_match("/CPU2 speed/", $sysinfo)) { //only one cpu
|
||||
$this->_cpu_loads['cpu1'] = $buf[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($this->_cpu_loads[$cpuline])) {
|
||||
return $this->_cpu_loads[$cpuline];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processor Load
|
||||
* optionally create a loadbar
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _loadavg($bufr = null)
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
if (CommonFunctions::executeProgram('fnsysctl', 'cat /proc/loadavg', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
parent::_loadavg(substr($resulte, strlen($resulto[1][0])));
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (PSI_LOAD_BAR) {
|
||||
$this->sys->setLoadPercent($this->_parseProcStat('cpu'));
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::_loadavg();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UpTime
|
||||
* time the system is running
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _uptime($bufu = null)
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
if (preg_match("/\nUptime: ([^\n]+)\n/", $this->getSystemPerformance(), $buf)) {
|
||||
parent::_uptime('up '.trim($buf[1]));
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
if (preg_match("/System Uptime:([\d:]+)/", $this->getShowStatus(), $buf)) {
|
||||
parent::_uptime('up '.trim($buf[1]));
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
if (CommonFunctions::executeProgram('cat', '/proc/uptime', $resulte, false) && ($resulte !== "")) {
|
||||
$ar_buf = preg_split('/ /', $resulte);
|
||||
$this->sys->setUptime(trim($ar_buf[0]));
|
||||
} else {
|
||||
parent::_uptime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kernel Version
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _kernel()
|
||||
{
|
||||
switch ($this->_ostype) {
|
||||
case 'FortiOS':
|
||||
if (CommonFunctions::executeProgram('fnsysctl', 'cat /proc/version', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$strBuf = substr($resulte, $resulto[1][1]);
|
||||
if (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
|
||||
$verBuf = $ar_buf[1];
|
||||
if (preg_match('/ SMP /', $strBuf)) {
|
||||
$verBuf .= ' (SMP)';
|
||||
}
|
||||
$this->sys->setKernel($verBuf);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::_kernel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->error->addWarning("The SSH version of phpSysInfo is a work in progress, some things currently don't work");
|
||||
switch ($this->_ostype) {
|
||||
case 'SSH':
|
||||
$this->_distro();
|
||||
break;
|
||||
case 'FortiOS':
|
||||
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->_machine();
|
||||
$this->_cpuinfo();
|
||||
//$this->_virtualizer();
|
||||
// $this->_pci();
|
||||
$this->_usb();
|
||||
// $this->_i2c();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
break;
|
||||
case 'DrayOS':
|
||||
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->_machine();
|
||||
$this->_cpuinfo();
|
||||
// //$this->_virtualizer();
|
||||
//// $this->_pci();
|
||||
// $this->_usb();
|
||||
//// $this->_i2c();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
break;
|
||||
case 'GNU':
|
||||
case 'Linux':
|
||||
parent::build();
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI SunOS 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.SunOS.inc.php 687 2012-09-06 20:54:49Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,12 +20,89 @@
|
||||
* @package PSI SunOS 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
|
||||
*/
|
||||
class SunOS extends OS
|
||||
{
|
||||
|
||||
/**
|
||||
* content of prtconf -v
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_prtconf = null;
|
||||
|
||||
/**
|
||||
* Execute prtconf -v and save ass array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function prtconf()
|
||||
{
|
||||
if ($this->_prtconf === null) {
|
||||
$this->_prtconf = array();
|
||||
if (CommonFunctions::executeProgram('prtconf', '-v', $buf, PSI_DEBUG) && ($buf!="")) {
|
||||
$blocks = preg_split('/\n(?= \S)/', $buf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($blocks) && (count($blocks)>2)) {
|
||||
array_shift($blocks);
|
||||
foreach ($blocks as $block) {
|
||||
if (preg_match('/^ (\S+) /', $block, $ar_buf)) {
|
||||
$group = trim($ar_buf[1], ',');
|
||||
$grouparr = array();
|
||||
$blocks1 = preg_split('/\n(?= \S)/', $block, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($blocks1) && count($blocks1)) {
|
||||
array_shift($blocks1);
|
||||
foreach ($blocks1 as $block1) {
|
||||
if (!preg_match('/^ name=\'([^\']+)\'/', $block1)
|
||||
&& preg_match('/^ (\S+) /', $block1, $ar_buf)) {
|
||||
$device = trim($ar_buf[1], ',');
|
||||
$devicearr = array();
|
||||
$blocks2 = preg_split('/\n(?= \S)/', $block1, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($blocks2) && count($blocks2)) {
|
||||
array_shift($blocks2);
|
||||
foreach ($blocks2 as $block2) {
|
||||
if (!preg_match('/^ name=\'([^\']+)\'/', $block2)
|
||||
&& preg_match('/^ (\S+) /', $block2, $ar_buf)) {
|
||||
$subdev = trim($ar_buf[1], ',');
|
||||
$subdevarr = array();
|
||||
$blocks3 = preg_split('/\n(?= \S)/', $block2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($blocks3) && count($blocks3)) {
|
||||
array_shift($blocks3);
|
||||
foreach ($blocks3 as $block3) {
|
||||
if (preg_match('/^ name=\'([^\']+)\' [\s\S]+ value=\'?([^\']+)\'?/m', $block3, $ar_buf)) {
|
||||
if ($subdev==='Hardware') {
|
||||
$subdevarr[$ar_buf[1]] = $ar_buf[2];
|
||||
$subdevarr['device'] = $device;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($subdevarr)) {
|
||||
$devicearr = $subdevarr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($devicearr)) {
|
||||
$grouparr[$device][] = $devicearr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($grouparr)) {
|
||||
$this->_prtconf[$group][] = $grouparr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_prtconf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract kernel values via kstat() interface
|
||||
*
|
||||
@@ -35,11 +112,10 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _kstat($key)
|
||||
{
|
||||
if (CommonFunctions::executeProgram('kstat', '-p d '.$key, $m, PSI_DEBUG) &&
|
||||
!is_null($m) && (trim($m)!=="")) {
|
||||
list($key, $value) = preg_split("/\t/", trim($m), 2);
|
||||
if (CommonFunctions::executeProgram('kstat', '-p d '.$key, $m, PSI_DEBUG) && ($m!=="")) {
|
||||
list($key, $value) = preg_split("/\t/", $m, 2);
|
||||
|
||||
return $value;
|
||||
return trim($value);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@@ -52,8 +128,8 @@ class SunOS 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);
|
||||
@@ -64,24 +140,6 @@ class SunOS 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kernel Version
|
||||
*
|
||||
@@ -89,12 +147,17 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _kernel()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uname', '-s', $os, PSI_DEBUG)) {
|
||||
if (CommonFunctions::executeProgram('uname', '-r', $version, PSI_DEBUG)) {
|
||||
$this->sys->setKernel($os.' '.$version);
|
||||
} else {
|
||||
$this->sys->setKernel($os);
|
||||
if (CommonFunctions::executeProgram('uname', '-s', $kernel, PSI_DEBUG) && ($kernel != "")) {
|
||||
if (CommonFunctions::executeProgram('uname', '-r', $version, PSI_DEBUG) && ($version != "")) {
|
||||
$kernel.=' '.$version;
|
||||
}
|
||||
if (CommonFunctions::executeProgram('uname', '-v', $subversion, PSI_DEBUG) && ($subversion != "")) {
|
||||
$kernel.=' ('.$subversion.')';
|
||||
}
|
||||
if (CommonFunctions::executeProgram('uname', '-i', $platform, PSI_DEBUG) && ($platform != "")) {
|
||||
$kernel.=' '.$platform;
|
||||
}
|
||||
$this->sys->setKernel($kernel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,19 +172,6 @@ class SunOS extends OS
|
||||
$this->sys->setUptime(time() - $this->_kstat('unix:0:system_misc:boot_time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Users
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _users()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('who', '-q', $buf, PSI_DEBUG)) {
|
||||
$who = preg_split('/=/', $buf);
|
||||
$this->sys->setUsers($who[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processor Load
|
||||
* optionally create a loadbar
|
||||
@@ -143,13 +193,75 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _cpuinfo()
|
||||
{
|
||||
$dev = new CpuDevice();
|
||||
if (CommonFunctions::executeProgram('uname', '-i', $buf, PSI_DEBUG)) {
|
||||
$dev->setModel(trim($buf));
|
||||
if (CommonFunctions::executeProgram('kstat', '-p d cpu_info:*:cpu_info*:core_id', $m, PSI_DEBUG) && ($m!=="")) {
|
||||
$cpuc = count(preg_split('/\n/', $m, -1, PREG_SPLIT_NO_EMPTY));
|
||||
for ($cpu=0; $cpu < $cpuc; $cpu++) {
|
||||
$dev = new CpuDevice();
|
||||
if (($buf = $this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':current_clock_Hz')) !== "") {
|
||||
$dev->setCpuSpeed($buf/1000000);
|
||||
} elseif (($buf = $this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':clock_MHz')) !== "") {
|
||||
$dev->setCpuSpeed($buf);
|
||||
}
|
||||
if (($buf = $this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':supported_frequencies_Hz')) !== "") {
|
||||
$cpuarr = preg_split('/:/', $buf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (($cpuarrc=count($cpuarr))>1) {
|
||||
$dev->setCpuSpeedMin($cpuarr[0]/1000000);
|
||||
$dev->setCpuSpeedMax($cpuarr[$cpuarrc-1]/1000000);
|
||||
}
|
||||
}
|
||||
if (($buf =$this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':brand')) !== "") {
|
||||
$dev->setModel($buf);
|
||||
} elseif (($buf =$this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':cpu_type')) !== "") {
|
||||
$dev->setModel($buf);
|
||||
} elseif (CommonFunctions::executeProgram('uname', '-p', $buf, PSI_DEBUG) && ($buf!="")) {
|
||||
$dev->setModel($buf);
|
||||
} elseif (CommonFunctions::executeProgram('uname', '-i', $buf, PSI_DEBUG) && ($buf!="")) {
|
||||
$dev->setModel($buf);
|
||||
}
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PCI devices
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _pci()
|
||||
{
|
||||
$prtconf = $this->prtconf();
|
||||
if ((count($prtconf)>1) && isset($prtconf['pci'])) {
|
||||
foreach ($prtconf['pci'] as $prt) {
|
||||
foreach ($prt as $pci) {
|
||||
foreach ($pci as $pcidev) {
|
||||
if (isset($pcidev['device'])) {
|
||||
$dev = new HWDevice();
|
||||
if (isset($pcidev['model'])) {
|
||||
$name = $pcidev['model'];
|
||||
} else {
|
||||
$name = $pcidev['device'];
|
||||
}
|
||||
if (isset($pcidev['device-name'])) {
|
||||
$name .= ': '.$pcidev['device-name'];
|
||||
}
|
||||
$dev->setName($name);
|
||||
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if (isset($pcidev['subsystem-name']) && ($pcidev['subsystem-name']!=='unknown subsystem')) {
|
||||
$dev->setProduct($pcidev['subsystem-name']);
|
||||
}
|
||||
if (isset($pcidev['vendor-name'])) {
|
||||
$dev->setManufacturer($pcidev['vendor-name']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys->setPciDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$dev->setCpuSpeed($this->_kstat('cpu_info:0:cpu_info0:clock_MHz'));
|
||||
$dev->setCache($this->_kstat('cpu_info:0:cpu_info0:cpu_type') * 1024);
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,23 +301,22 @@ class SunOS extends OS
|
||||
}
|
||||
}
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
||||
if (CommonFunctions::executeProgram('ifconfig', $ar_buf[0], $bufr2, PSI_DEBUG)
|
||||
&& !is_null($bufr2) && (trim($bufr2) !== "")) {
|
||||
if (CommonFunctions::executeProgram('ifconfig', $ar_buf[0], $bufr2, PSI_DEBUG) && ($bufr2!=="")) {
|
||||
$bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe2 as $buf2) {
|
||||
if (preg_match('/^\s+ether\s+(\S+)/i', $buf2, $ar_buf2))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', $ar_buf2[1]));
|
||||
elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2))
|
||||
if (preg_match('/^\s+ether\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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CommonFunctions::executeProgram('ifconfig', $ar_buf[0].' inet6', $bufr2, PSI_DEBUG)
|
||||
&& !is_null($bufr2) && (trim($bufr2) !== "")) {
|
||||
if (CommonFunctions::executeProgram('ifconfig', $ar_buf[0].' inet6', $bufr2, PSI_DEBUG) && ($bufr2!=="")) {
|
||||
$bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe2 as $buf2) {
|
||||
if (preg_match('/^\s+inet6\s+([^\s\/]+)/i', $buf2, $ar_buf2)
|
||||
&& !preg_match('/^fe80::/i', $ar_buf2[1]))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1]))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,14 +338,16 @@ class SunOS extends OS
|
||||
$this->sys->setMemTotal($this->_kstat('unix:0:system_pages:pagestotal') * $pagesize);
|
||||
$this->sys->setMemUsed($this->_kstat('unix:0:system_pages:pageslocked') * $pagesize);
|
||||
$this->sys->setMemFree($this->_kstat('unix:0:system_pages:pagesfree') * $pagesize);
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName('SWAP');
|
||||
$dev->setFsType('swap');
|
||||
$dev->setMountPoint('SWAP');
|
||||
$dev->setTotal($this->_kstat('unix:0:vminfo:swap_avail') / 1024);
|
||||
$dev->setUsed($this->_kstat('unix:0:vminfo:swap_alloc') / 1024);
|
||||
$dev->setFree($this->_kstat('unix:0:vminfo:swap_free') / 1024);
|
||||
$this->sys->setSwapDevices($dev);
|
||||
if (($swap=$this->_kstat('unix:0:vminfo:swap_avail')) > 0) {
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName('SWAP');
|
||||
$dev->setFsType('swap');
|
||||
$dev->setMountPoint('SWAP');
|
||||
$dev->setTotal($swap / 1024);
|
||||
$dev->setUsed($this->_kstat('unix:0:vminfo:swap_alloc') / 1024);
|
||||
$dev->setFree($this->_kstat('unix:0:vminfo:swap_free') / 1024);
|
||||
$this->sys->setSwapDevices($dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,8 +402,21 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _distro()
|
||||
{
|
||||
$this->sys->setDistribution('SunOS');
|
||||
$this->sys->setDistributionIcon('SunOS.png');
|
||||
if (CommonFunctions::rfts('/etc/release', $buf, 1, 4096, false) && (trim($buf)!="")) {
|
||||
$this->sys->setDistribution(trim($buf));
|
||||
$list = @parse_ini_file(PSI_APP_ROOT."/data/distros.ini", true);
|
||||
if ($list && preg_match('/^(\S+)\s*/', preg_replace('/^open\s+/', 'open', preg_replace('/^oracle\s+/', 'oracle', strtolower(trim($buf)))), $id_buf) && isset($list[$distid=(trim($id_buf[1].' sunos'))]['Image'])) {
|
||||
$this->sys->setDistributionIcon($list[$distid]['Image']);
|
||||
if (isset($list[trim($distid)]['Name'])) {
|
||||
$this->sys->setDistribution(trim($list[$distid]['Name']).' '.$this->sys->getDistribution());
|
||||
}
|
||||
} else {
|
||||
$this->sys->setDistributionIcon('SunOS.png');
|
||||
}
|
||||
} else {
|
||||
$this->sys->setDistribution('SunOS');
|
||||
$this->sys->setDistributionIcon('SunOS.png');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,22 +454,32 @@ class SunOS extends OS
|
||||
*
|
||||
* @see PSI_Interface_OS::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->error->addError("WARN", "The SunOS 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->_cpuinfo();
|
||||
$this->_network();
|
||||
$this->_memory();
|
||||
$this->_filesystems();
|
||||
$this->_processes();
|
||||
$this->error->addWarning("The SunOS 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->_cpuinfo();
|
||||
$this->_pci();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user