Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 3037 → Rev 3100

/web/acc/phpsysinfo/includes/autoloader.inc.php
69,7 → 69,7
function errorHandlerPsi($level, $message, $file, $line)
{
$error = PSI_Error::singleton();
if (PSI_DEBUG || (($level !== 2) && ($level !== 8)) || !(preg_match("/^[^:]*: open_basedir /", $message) || preg_match("/^fopen\(/", $message) || preg_match("/^is_readable\(/", $message) || preg_match("/^file_exists\(/", $message) || preg_match("/^fgets\(/", $message))) { // disable open_basedir, fopen, is_readable, file_exists and fgets warnings and notices
if ((PSI_DEBUG && !preg_match("/^fgets\(|^stream_select\(/", $message)) || (($level !== 2) && ($level !== 8)) || !preg_match("/^[^:]*: open_basedir |^fopen\(|^fwrite\(|^is_readable\(|^file_exists\(|^fgets\(|^stream_select\(/", $message)) { // disable open_basedir, fopen, is_readable, file_exists, fgets and stream_select warnings and notices
$error->addPhpError("errorHandlerPsi : ", "Level : ".$level." Message : ".$message." File : ".$file." Line : ".$line);
}
}
/web/acc/phpsysinfo/includes/class.CommonFunctions.inc.php
156,7 → 156,7
* NOT $program = CommonFunctions::executeProgram('netstat', '-anp|grep LIST');
*
* @param string $strProgramname name of the program
* @param string $strArgs arguments to the program
* @param string $strArguments arguments to the program
* @param string &$strBuffer output of the command
* @param boolean $booErrorRep en- or disables the reporting of errors which should be logged
* @param int $timeout timeout value in seconds (default value is PSI_EXEC_TIMEOUT_INT)
163,10 → 163,23
*
* @return boolean command successfull or not
*/
public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $booErrorRep = true, $timeout = PSI_EXEC_TIMEOUT_INT)
public static function executeProgram($strProgramname, $strArguments, &$strBuffer, $booErrorRep = true, $timeout = PSI_EXEC_TIMEOUT_INT, $separator = '')
{
if (PSI_ROOT_FILESYSTEM !== '') { // disabled if ROOTFS defined
 
return false;
}
 
if ((PSI_OS != 'WINNT') && preg_match('/^([^=]+=[^ \t]+)[ \t]+(.*)$/', $strProgramname, $strmatch)) {
$strSet = $strmatch[1].' ';
$strProgramname = $strmatch[2];
} else {
$strSet = '';
}
$strAll = trim($strSet.$strProgramname.' '.$strArguments);
 
if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
$out = self::_parse_log_file("Executing: ".trim($strProgramname.' '.$strArgs));
$out = self::_parse_log_file("Executing: ".$strAll);
if ($out == false) {
if (substr(PSI_LOG, 0, 1)=="-") {
$strBuffer = '';
180,21 → 193,65
}
}
 
if (PSI_ROOT_FILESYSTEM !== '') { // disabled if ROOTFS defined
 
return false;
$PathStr = '';
if (defined('PSI_EMU_PORT') && !in_array($strProgramname, array('ping', 'snmpwalk'))) {
if (defined('PSI_SUDO_COMMANDS') && is_string(PSI_SUDO_COMMANDS)) {
if (preg_match(ARRAY_EXP, PSI_SUDO_COMMANDS)) {
$sudocommands = eval(PSI_SUDO_COMMANDS);
} else {
$sudocommands = array(PSI_SUDO_COMMANDS);
}
if (in_array($strProgramname, $sudocommands)) {
$strAll = 'sudo '.$strAll;
}
}
$strSet = '';
$strProgramname = 'sshpass';
$strOptions = '';
if (defined('PSI_EMU_ADD_OPTIONS') && is_string(PSI_EMU_ADD_OPTIONS)) {
if (preg_match(ARRAY_EXP, PSI_EMU_ADD_OPTIONS)) {
$arrParams = eval(PSI_EMU_ADD_OPTIONS);
} else {
$arrParams = array(PSI_EMU_ADD_OPTIONS);
}
foreach ($arrParams as $Params) if (preg_match('/(\S+)\s*\=\s*(\S+)/', $Params, $obuf)) {
$strOptions = $strOptions.'-o '.$obuf[1].'='.$obuf[2].' ';
}
}
if (defined('PSI_EMU_ADD_PATHS') && is_string(PSI_EMU_ADD_PATHS)) {
if (preg_match(ARRAY_EXP, PSI_EMU_ADD_PATHS)) {
$arrPath = eval(PSI_EMU_ADD_PATHS);
} else {
$arrPath = array(PSI_EMU_ADD_PATHS);
}
foreach ($arrPath as $Path) {
if ($PathStr === '') {
$PathStr = $Path;
} else {
$PathStr = $PathStr.':'.$Path;
}
}
if ($separator === '') {
$strArguments = '-e ssh -Tq '.$strOptions.'-o ConnectTimeout='.$timeout.' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '.PSI_EMU_USER.'@'.PSI_EMU_HOSTNAME.' -p '.PSI_EMU_PORT.' "PATH=\''.$PathStr.':$PATH\' '.$strAll.'"' ;
} else {
$strArguments = '-e ssh -Tq '.$strOptions.'-o ConnectTimeout='.$timeout.' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '.PSI_EMU_USER.'@'.PSI_EMU_HOSTNAME.' -p '.PSI_EMU_PORT;
}
} else {
if ($separator === '') {
$strArguments = '-e ssh -Tq '.$strOptions.'-o ConnectTimeout='.$timeout.' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '.PSI_EMU_USER.'@'.PSI_EMU_HOSTNAME.' -p '.PSI_EMU_PORT.' "'.$strAll.'"' ;
} else {
$strArguments = '-e ssh -Tq '.$strOptions.'-o ConnectTimeout='.$timeout.' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '.PSI_EMU_USER.'@'.PSI_EMU_HOSTNAME.' -p '.PSI_EMU_PORT;
}
}
$externally = true;
} else {
$externally = false;
}
 
if ((PSI_OS != 'WINNT') && preg_match('/^([^=]+=[^ \t]+)[ \t]+(.*)$/', $strProgramname, $strmatch)) {
$strSet = $strmatch[1].' ';
$strProgramname = $strmatch[2];
} else {
$strSet = '';
}
$strProgram = self::_findProgram($strProgramname);
$error = PSI_Error::singleton();
if (!$strProgram) {
if ($booErrorRep) {
if ($booErrorRep || $externally) {
$error->addError('find_program("'.$strProgramname.'")', 'program not found on the machine');
}
 
205,7 → 262,7
}
}
 
if ((PSI_OS != 'WINNT') && defined('PSI_SUDO_COMMANDS') && is_string(PSI_SUDO_COMMANDS)) {
if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME') && defined('PSI_SUDO_COMMANDS') && is_string(PSI_SUDO_COMMANDS)) {
if (preg_match(ARRAY_EXP, PSI_SUDO_COMMANDS)) {
$sudocommands = eval(PSI_SUDO_COMMANDS);
} else {
214,9 → 271,7
if (in_array($strProgramname, $sudocommands)) {
$sudoProgram = self::_findProgram("sudo");
if (!$sudoProgram) {
if ($booErrorRep) {
$error->addError('find_program("sudo")', 'program not found on the machine');
}
$error->addError('find_program("sudo")', 'program not found on the machine');
 
return false;
} else {
229,6 → 284,7
}
}
 
$strArgs = $strArguments;
// see if we've gotten a | or &, if we have we need to do path checking on the cmd
if ($strArgs) {
$arrArgs = preg_split('/ /', $strArgs, -1, PREG_SPLIT_NO_EMPTY);
236,10 → 292,25
if (($arrArgs[$i] == '|') || ($arrArgs[$i] == '&')) {
$strCmd = $arrArgs[$i + 1];
$strNewcmd = self::_findProgram($strCmd);
if ($arrArgs[$i] == '|') {
$strArgs = preg_replace('/\| '.$strCmd.'/', '| "'.$strNewcmd.'"', $strArgs);
if (!$strNewcmd) {
if ($booErrorRep || $externally) {
$error->addError('find_program("'.$strCmd.'")', 'program not found on the machine');
}
 
return false;
}
if (preg_match('/\s/', $strNewcmd)) {
if ($arrArgs[$i] == '|') {
$strArgs = preg_replace('/\| '.$strCmd.'/', '| "'.$strNewcmd.'"', $strArgs);
} else {
$strArgs = preg_replace('/& '.$strCmd.'/', '& "'.$strNewcmd.'"', $strArgs);
}
} else {
$strArgs = preg_replace('/& '.$strCmd.'/', '& "'.$strNewcmd.'"', $strArgs);
if ($arrArgs[$i] == '|') {
$strArgs = preg_replace('/\| '.$strCmd.'/', '| '.$strNewcmd, $strArgs);
} else {
$strArgs = preg_replace('/& '.$strCmd.'/', '& '.$strNewcmd, $strArgs);
}
}
}
}
250,7 → 321,15
$strError = '';
$pipes = array();
$descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w"));
if ($externally) {
putenv('SSHPASS='.PSI_EMU_PASSWORD);
}
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
if ($separator !== '') {
$error->addError('executeProgram', 'wrong execution mode');
 
return false;
}
if (PSI_OS == 'WINNT') {
$process = $pipes[1] = popen($strSet.$strProgram.$strArgs." 2>nul", "r");
} else {
258,9 → 337,19
}
} else {
$process = proc_open($strSet.$strProgram.$strArgs, $descriptorspec, $pipes);
if ($separator !== '') {
if ($PathStr === '') {
fwrite($pipes[0], $strAll."\n "); // spaces at end for handling 'more'
} else {
fwrite($pipes[0], 'PATH=\''.$PathStr.':$PATH\' '.$strAll."\n");
}
}
}
if ($externally) {
putenv('SSHPASS');
}
if (is_resource($process)) {
$te = self::_timeoutfgets($pipes, $strBuffer, $strError, $timeout);
$te = self::_timeoutfgets($pipes, $strBuffer, $strError, $timeout, $separator);
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
$return_value = pclose($pipes[1]);
} else {
286,7 → 375,7
$strError = trim($strError);
$strBuffer = trim($strBuffer);
if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && (substr(PSI_LOG, 0, 1)!="-") && (substr(PSI_LOG, 0, 1)!="+")) {
error_log("---".gmdate('r T')."--- Executing: ".trim($strProgramname.$strArgs)."\n".$strBuffer."\n", 3, PSI_LOG);
error_log("---".gmdate('r T')."--- Executing: ".$strAll."\n".$strBuffer."\n", 3, PSI_LOG);
}
if (! empty($strError)) {
if ($booErrorRep) {
306,6 → 395,10
*/
public static function rolv($similarFileName, $match = "//", $replace = "")
{
if (defined('PSI_EMU_PORT')) {
return null;
}
 
$filename = preg_replace($match, $replace, $similarFileName);
if (self::fileexists($filename) && self::rfts($filename, $buf, 1, 4096, false) && (($buf=trim($buf)) != "")) {
return $buf;
359,6 → 452,10
*/
public static function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true)
{
if (defined('PSI_EMU_PORT')) {
return false;
}
 
if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
$out = self::_parse_log_file("Reading: ".$strFileName);
if ($out == false) {
478,6 → 575,10
*/
public static function findglob($pattern, $flags = 0)
{
if (defined('PSI_EMU_PORT')) {
return false;
}
 
$outarr = glob(PSI_ROOT_FILESYSTEM.$pattern, $flags);
if (PSI_ROOT_FILESYSTEM == '') {
return $outarr;
503,6 → 604,10
*/
public static function fileexists($strFileName)
{
if (defined('PSI_EMU_PORT')) {
return false;
}
 
if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
$log_file = substr(PSI_LOG, 1);
if (file_exists($log_file)
613,7 → 718,7
*
* @return boolean timeout expired or not
*/
private static function _timeoutfgets($pipes, &$out, &$err, $timeout)
private static function _timeoutfgets($pipes, &$out, &$err, $timeout, $separator = '')
{
$w = null;
$e = null;
638,6 → 743,9
break;
} elseif ($n === 0) {
error_log('stream_select: timeout expired !');
// if ($separator !== '') {
// fwrite($pipes[0], "q");
// }
$te = true;
break;
}
649,6 → 757,13
$err .= fread($r, 4096);
}
}
// if (($separator !== '') && preg_match('/'.$separator.'[^'.$separator.']+'.$separator.'/', $out)) {
if (($separator !== '') && preg_match('/'.$separator.'[\s\S]+'.$separator.'/', $out)) {
fwrite($pipes[0], "quit\n");
$separator = ''; //only one time
// $te = true;
// break;
}
}
 
return $te;
692,6 → 807,8
if (gettype($vendor_data) === "array") {
$vendarray = array(
'KVM' => 'kvm', // KVM
'OpenStack' => 'kvm', // Detect OpenStack instance as KVM in non x86 architecture
'KubeVirt' => 'kvm', // Detect KubeVirt instance as KVM in non x86 architecture
'Amazon EC2' => 'amazon', // Amazon EC2 Nitro using Linux KVM
'QEMU' => 'qemu', // QEMU
'VMware' => 'vmware', // VMware https://kb.vmware.com/s/article/1009458
704,6 → 821,7
// https://wiki.freebsd.org/bhyve
'BHYVE' => 'bhyve', // bhyve
'Hyper-V' => 'microsoft', // Hyper-V
'Apple Virtualization' => 'apple', // Apple Virtualization.framework guests
'Microsoft Corporation Virtual Machine' => 'microsoft' // Hyper-V
);
for ($i = 0; $i < count($vendor_data); $i++) {
717,6 → 835,7
$vidarray = array(
'bhyvebhyve' => 'bhyve', // bhyve
'KVMKVMKVM' => 'kvm', // KVM
'LinuxKVMHv' => 'hv-kvm', // KVM (KVM + HyperV Enlightenments)
'MicrosoftHv' => 'microsoft', // Hyper-V
'lrpepyhvr' => 'parallels', // Parallels
'UnisysSpar64' => 'spar', // Unisys sPar
744,7 → 863,7
*/
public static function readdmimemdata()
{
if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME') && (self::$_dmimd === null)) {
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) && (self::$_dmimd === null)) {
self::$_dmimd = array();
$buffer = '';
if (defined('PSI_DMIDECODE_ACCESS') && (strtolower(PSI_DMIDECODE_ACCESS)==='data')) {
/web/acc/phpsysinfo/includes/class.Parser.inc.php
117,7 → 117,7
$mount_parm[] = $parm;
}
}
} elseif (CommonFunctions::rfts(((PSI_ROOT_FILESYSTEM === '')||(PHP_OS !== 'Linux'))?"/etc/mtab":"/proc/1/mounts", $mount)) {
} elseif (CommonFunctions::rfts(((PSI_ROOT_FILESYSTEM === '')||(PSI_OS !== 'Linux'))?"/etc/mtab":"/proc/1/mounts", $mount)) {
$mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
foreach ($mount as $mount_line) {
if (preg_match("/(\S+) (\S+) (\S+) (\S+) ([0-9]+) ([0-9]+)/", $mount_line, $mount_buf)) {
/web/acc/phpsysinfo/includes/error/class.PSI_Error.inc.php
240,6 → 240,10
} else {
$strFunc = $val['function'].'(';
if (isset($val['args'][0])) {
if (($val['function'] == 'executeProgram') && ($val['args'][0] == 'sshpass')
&& isset($val['args'][1]) && preg_match('/"([^"]+)"$/', $val['args'][1], $tmpout)) {
$val['args'][1] = 'ssh: '. $tmpout[1];
}
$strFunc .= ' ';
$strComma = '';
foreach ($val['args'] as $valArgs) {
/web/acc/phpsysinfo/includes/mb/class.cpumem.inc.php
73,7 → 73,7
$this->mbinfo->setMbVolt($dev);
}
}
if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) {
$dmimd = CommonFunctions::readdmimemdata();
$counter = 0;
foreach ($dmimd as $mem) {
/web/acc/phpsysinfo/includes/mb/class.fortisensor.inc.php
0,0 → 1,122
<?php
/**
* fortisensor sensor class, getting hardware sensors information from Fortinet devices
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @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 FortiSensor extends Sensors
{
/**
* content to parse
*
* @var array
*/
private $_lines = array();
 
/**
* fill the private array
*/
public function __construct()
{
parent::__construct();
$lines = "";
if (defined('PSI_EMU_PORT') && CommonFunctions::executeProgram('execute', 'sensor list', $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)) {
$lines = substr($resulti, 0, $resulto[1][1]);
}
}
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
 
/**
* get temperature information
*
* @return void
*/
private function _temperature()
{
foreach ($this->_lines as $line) {
if (preg_match('/^\s*\d+\s(.+)\sTemperature\s+([\d\.]+)\s\S*C\s*$/', $line, $data)) {
$dev = new SensorDevice();
$dev->setName($data[1]);
$dev->setValue($data[2]);
$this->mbinfo->setMbTemp($dev);
} elseif (preg_match('/^\s*\d+\s(.+)\s+alarm=(\d)\s+value=(\d+)\s/', $line, $data)
&& !preg_match('/fan| vin/i', $data[1])) {
$dev = new SensorDevice();
$dev->setName(trim($data[1]));
$dev->setValue($data[3]);
if ($data[2] != 0) {
$dev->setEvent("Alarm");
}
$this->mbinfo->setMbTemp($dev);
}
}
}
 
/**
* get voltage information
*
* @return void
*/
private function _voltage()
{
foreach ($this->_lines as $line) {
if (preg_match('/^\s*\d+\s(.+)\s+alarm=(\d)\s+value=([\d\.]+)\s/', $line, $data)
&& preg_match('/\./', $data[3])
&& !preg_match('/fan|temp/i', $data[1])) {
$dev = new SensorDevice();
$dev->setName(trim($data[1]));
$dev->setValue($data[3]);
if ($data[2] != 0) {
$dev->setEvent("Alarm");
}
$this->mbinfo->setMbVolt($dev);
}
}
}
 
/**
* get fan information
*
* @return void
*/
private function _fans()
{
foreach ($this->_lines as $line) {
if (preg_match('/^\s*\d+\s(.+)\s+alarm=(\d)\s+value=(\d+)\s/', $line, $data)
&& preg_match('/fan/i', $data[1])) {
$dev = new SensorDevice();
$dev->setName(trim($data[1]));
$dev->setValue($data[3]);
if ($data[2] != 0) {
$dev->setEvent("Alarm");
}
$this->mbinfo->setMbFan($dev);
}
}
}
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return void
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
}
}
/web/acc/phpsysinfo/includes/mb/class.freeipmi.inc.php
27,13 → 27,13
public function __construct()
{
parent::__construct();
if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_FREEIPMI_ACCESS')?strtolower(PSI_SENSOR_FREEIPMI_ACCESS):'command') {
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_FREEIPMI_ACCESS')?strtolower(PSI_SENSOR_FREEIPMI_ACCESS):'command') {
case 'command':
CommonFunctions::executeProgram('ipmi-sensors', '--output-sensor-thresholds', $lines);
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rftsdata('freeipmi.tmp', $lines)) {
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('freeipmi.tmp', $lines)) {
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
/web/acc/phpsysinfo/includes/mb/class.hddtemp.inc.php
24,11 → 24,11
private function _temperature()
{
$ar_buf = array();
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_HDDTEMP_ACCESS')?strtolower(PSI_SENSOR_HDDTEMP_ACCESS):'command') {
if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_HDDTEMP_ACCESS')?strtolower(PSI_SENSOR_HDDTEMP_ACCESS):'command') {
case 'tcp':
$lines = '';
// Timo van Roermund: connect to the hddtemp daemon, use a 5 second timeout.
$fp = @fsockopen('localhost', 7634, $errno, $errstr, 5);
$fp = @fsockopen(defined('PSI_EMU_HOSTNAME')?PSI_EMU_HOSTNAME:'localhost', 7634, $errno, $errstr, 5);
// if connected, read the output of the hddtemp daemon
if ($fp) {
while (!feof($fp)) {
/web/acc/phpsysinfo/includes/mb/class.healthd.inc.php
37,7 → 37,7
}
break;
case 'data':
if (CommonFunctions::rftsdata('healthd.tmp', $lines)) {
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('healthd.tmp', $lines)) {
$lines0 = preg_split("/\n/", $lines, 1, PREG_SPLIT_NO_EMPTY);
if (count($lines0) == 1) {
$this->_values = preg_split("/\t+/", $lines0[0]);
/web/acc/phpsysinfo/includes/mb/class.hwmon.inc.php
246,7 → 246,7
*/
public function build()
{
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) {
$hwpaths = CommonFunctions::findglob("/sys/class/hwmon/hwmon*/", GLOB_NOSORT);
if (is_array($hwpaths) && (count($hwpaths) > 0)) {
$hwpaths2 = CommonFunctions::findglob("/sys/class/hwmon/hwmon*/device/", GLOB_NOSORT);
/web/acc/phpsysinfo/includes/mb/class.ipmicfg.inc.php
27,7 → 27,7
public function __construct()
{
parent::__construct();
if (!defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_IPMICFG_ACCESS')?strtolower(PSI_SENSOR_IPMICFG_ACCESS):'command') {
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) switch (defined('PSI_SENSOR_IPMICFG_ACCESS')?strtolower(PSI_SENSOR_IPMICFG_ACCESS):'command') {
case 'command':
if (!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) {
CommonFunctions::executeProgram('ipmicfg', '-sdr', $lines);
40,7 → 40,7
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rftsdata('ipmicfg.tmp', $lines)) {
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('ipmicfg.tmp', $lines)) {
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
/web/acc/phpsysinfo/includes/mb/class.ipmitool.inc.php
28,12 → 28,14
{
parent::__construct();
$lines = "";
if (!defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_IPMITOOL_ACCESS')?strtolower(PSI_SENSOR_IPMITOOL_ACCESS):'command') {
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) switch (defined('PSI_SENSOR_IPMITOOL_ACCESS')?strtolower(PSI_SENSOR_IPMITOOL_ACCESS):'command') {
case 'command':
CommonFunctions::executeProgram('ipmitool', 'sensor -v', $lines);
break;
case 'data':
CommonFunctions::rftsdata('ipmitool.tmp', $lines);
if (!defined('PSI_EMU_PORT')) {
CommonFunctions::rftsdata('ipmitool.tmp', $lines);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_ipmitool] ACCESS');
/web/acc/phpsysinfo/includes/mb/class.ipmiutil.inc.php
27,13 → 27,13
public function __construct()
{
parent::__construct();
if (!defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_IPMIUTIL_ACCESS')?strtolower(PSI_SENSOR_IPMIUTIL_ACCESS):'command') {
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) switch (defined('PSI_SENSOR_IPMIUTIL_ACCESS')?strtolower(PSI_SENSOR_IPMIUTIL_ACCESS):'command') {
case 'command':
CommonFunctions::executeProgram('ipmiutil', 'sensor -stw', $lines);
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rftsdata('ipmiutil.tmp', $lines)) {
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('ipmiutil.tmp', $lines)) {
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
/web/acc/phpsysinfo/includes/mb/class.k8temp.inc.php
27,7 → 27,7
public function __construct()
{
parent::__construct();
if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_K8TEMP_ACCESS')?strtolower(PSI_SENSOR_K8TEMP_ACCESS):'command') {
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_K8TEMP_ACCESS')?strtolower(PSI_SENSOR_K8TEMP_ACCESS):'command') {
case 'command':
$lines = "";
CommonFunctions::executeProgram('k8temp', '', $lines);
34,7 → 34,7
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rftsdata('k8temp.tmp', $lines)) {
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('k8temp.tmp', $lines)) {
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
/web/acc/phpsysinfo/includes/mb/class.lmsensors.inc.php
28,12 → 28,14
{
parent::__construct();
$lines = "";
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_LMSENSORS_ACCESS')?strtolower(PSI_SENSOR_LMSENSORS_ACCESS):'command') {
if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_LMSENSORS_ACCESS')?strtolower(PSI_SENSOR_LMSENSORS_ACCESS):'command') {
case 'command':
CommonFunctions::executeProgram("sensors", "", $lines);
break;
case 'data':
CommonFunctions::rftsdata('lmsensors.tmp', $lines);
if (!defined('PSI_EMU_PORT')) {
CommonFunctions::rftsdata('lmsensors.tmp', $lines);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_lmsensors] ACCESS');
/web/acc/phpsysinfo/includes/mb/class.mbmon.inc.php
27,9 → 27,9
public function __construct()
{
parent::__construct();
if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_MBMON_ACCESS')?strtolower(PSI_SENSOR_MBMON_ACCESS):'command') {
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_MBMON_ACCESS')?strtolower(PSI_SENSOR_MBMON_ACCESS):'command') {
case 'tcp':
$fp = fsockopen("localhost", 411, $errno, $errstr, 5);
$fp = fsockopen(defined('PSI_EMU_HOSTNAME')?PSI_EMU_HOSTNAME:'localhost', 411, $errno, $errstr, 5);
if ($fp) {
$lines = "";
while (!feof($fp)) {
45,7 → 45,7
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rftsdata('mbmon.tmp', $lines)) {
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('mbmon.tmp', $lines)) {
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
/web/acc/phpsysinfo/includes/mb/class.nvidiasmi.inc.php
27,7 → 27,7
public function __construct()
{
parent::__construct();
if (!defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_NVIDIASMI_ACCESS')?strtolower(PSI_SENSOR_NVIDIASMI_ACCESS):'command') {
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) switch (defined('PSI_SENSOR_NVIDIASMI_ACCESS')?strtolower(PSI_SENSOR_NVIDIASMI_ACCESS):'command') {
case 'command':
if (PSI_OS == 'WINNT') {
$winnt_exe = (defined('PSI_SENSOR_NVIDIASMI_EXE_PATH') && is_string(PSI_SENSOR_NVIDIASMI_EXE_PATH))?strtolower(PSI_SENSOR_NVIDIASMI_EXE_PATH):"c:\\Program Files\\NVIDIA Corporation\\NVSMI\\nvidia-smi.exe";
43,7 → 43,7
$this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rftsdata('nvidiasmi.tmp', $lines)) {
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('nvidiasmi.tmp', $lines)) {
$this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
/web/acc/phpsysinfo/includes/mb/class.ohm.inc.php
27,7 → 27,7
public function __construct()
{
parent::__construct();
if ((PSI_OS == 'WINNT') || defined('PSI_EMU_HOSTNAME')) {
if ((PSI_OS == 'WINNT') || (defined('PSI_EMU_HOSTNAME') && !defined('PSI_EMU_PORT'))) {
$_wmi = WINNT::initWMI('root\OpenHardwareMonitor', true);
if ($_wmi) {
$tmpbuf = WINNT::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
/web/acc/phpsysinfo/includes/mb/class.qtssnmp.inc.php
21,7 → 21,12
*/
private function _temperature()
{
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.5.0", $buffer, PSI_DEBUG)
if (!defined('PSI_EMU_PORT')) {
$address = '127.0.0.1';
} else {
$address = PSI_EMU_HOSTNAME;
}
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.5.0", $buffer, PSI_DEBUG)
&& preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
$dev = new SensorDevice();
$dev->setName("CPU");
29,7 → 34,7
$this->mbinfo->setMbTemp($dev);
}
 
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.6.0", $buffer, PSI_DEBUG)
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.6.0", $buffer, PSI_DEBUG)
&& preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
$dev = new SensorDevice();
$dev->setName("System");
37,7 → 42,7
$this->mbinfo->setMbTemp($dev);
}
 
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.11.1.3", $buffer, PSI_DEBUG)) {
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.11.1.3", $buffer, PSI_DEBUG)) {
$lines = preg_split('/\r?\n/', $buffer);
foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sC/', $line, $data)) {
$dev = new SensorDevice();
55,7 → 60,12
*/
private function _fans()
{
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.15.1.3", $buffer, PSI_DEBUG)) {
if (!defined('PSI_EMU_PORT')) {
$address = '127.0.0.1';
} else {
$address = PSI_EMU_HOSTNAME;
}
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.15.1.3", $buffer, PSI_DEBUG)) {
$lines = preg_split('/\r?\n/', $buffer);
foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sRPM/', $line, $data)) {
$dev = new SensorDevice();
75,7 → 85,7
*/
public function build()
{
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) {
$this->_temperature();
$this->_fans();
}
/web/acc/phpsysinfo/includes/mb/class.thermalzone.inc.php
29,7 → 29,7
parent::__construct();
switch (defined('PSI_SENSOR_THERMALZONE_ACCESS')?strtolower(PSI_SENSOR_THERMALZONE_ACCESS):'command') {
case 'command':
if ((PSI_OS == 'WINNT') || defined('PSI_EMU_HOSTNAME')) {
if ((PSI_OS == 'WINNT') || (defined('PSI_EMU_HOSTNAME') && !defined('PSI_EMU_PORT'))) {
if (defined('PSI_EMU_HOSTNAME') || WINNT::isAdmin()) {
$_wmi = WINNT::initWMI('root\WMI', true);
if ($_wmi) {
/web/acc/phpsysinfo/includes/os/class.Android.inc.php
54,7 → 54,7
*
* @return void
*/
private function _kernel()
protected function _kernel()
{
if (CommonFunctions::executeProgram('uname', '-r', $strBuf, false)) {
$result = $strBuf;
91,7 → 91,7
*
* @return void
*/
private function _filesystems()
protected function _filesystems()
{
$notwas = true;
if (CommonFunctions::executeProgram('df', '2>/dev/null ', $df, PSI_DEBUG) && preg_match("/\s+[0-9\.]+[KMGT]\s+/", $df)) {
197,7 → 197,7
*
* @return void
*/
private function _machine()
protected function _machine()
{
if ($lines = $this->_get_buildprop()) {
$buf = "";
/web/acc/phpsysinfo/includes/os/class.BSDCommon.inc.php
232,8 → 232,15
protected function kernel()
{
$s = $this->grabkey('kern.version');
$a = preg_split('/:/', $s);
if (isset($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);
305,7 → 312,7
array_shift($pslines);
$sum = 0;
foreach ($pslines as $psline) {
$sum+=trim($psline);
$sum+=str_replace(',', '.', trim($psline));
}
$this->_cpu_loads['cpu'] = min($sum/$ncpu, 100);
}
331,6 → 338,7
$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) {
358,7 → 366,7
$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) {
if ($dev->getCpuSpeed() == 0) {
$dev->setCpuSpeed(round($ar_buf[2]));
}
$notwas = false;
/web/acc/phpsysinfo/includes/os/class.Darwin.inc.php
97,8 → 97,8
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 (($buf !== null) && (trim($buf) != "")) {
$this->sys->setMachine(trim($buf));
264,60 → 264,61
*/
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);
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 {
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);
}
} else {
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);
$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]);
if (($swap=trim($swap1[0])) > 0) {
if (($swap = $this->grabkey("vm.swapusage")) > 0) {
$swap0 = preg_split('/M/', $swapBuff);
$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(trim($swap2[1]) * 1024 * 1024);
$dev->setFree(trim($swap3[1]) * 1024 * 1024);
$dev->setUsed(str_replace(',', '.', trim($swap2[1])) * 1024 * 1024);
$dev->setFree(str_replace(',', '.', trim($swap3[1])) * 1024 * 1024);
$this->sys->setSwapDevices($dev);
}
}
417,7 → 418,7
}
if (isset($distro_arr['System Version'])) {
$distro = $distro_arr['System Version'];
if (preg_match('/^Mac OS|^OS X|^macOS/', $distro)) {
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))) {
/web/acc/phpsysinfo/includes/os/class.FreeBSD.inc.php
127,6 → 127,9
} 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');
}
/web/acc/phpsysinfo/includes/os/class.GNU.inc.php
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();
}
}
/web/acc/phpsysinfo/includes/os/class.Linux.inc.php
34,7 → 34,7
/**
* Assoc array of all CPUs loads.
*/
private $_cpu_loads = null;
protected $_cpu_loads = null;
 
/**
* Version string.
196,7 → 196,7
$this->_machine_info['machine'] = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified|Default string) ?/i", "", $this->_machine_info['machine'])));
}
 
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && count($vendor_array)>0) {
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && count($vendor_array) > 0) {
$virt = CommonFunctions::decodevirtualizer($vendor_array);
if ($virt !== null) {
$this->_machine_info['hypervisor'] = $virt;
216,20 → 216,29
{
if ($this->_kernel_string === null) {
$this->_kernel_string = "";
if (CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) || // show effective kernel if ksplice uptrack is installed
CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG)) {
if ($this->sys->getOS() == 'SSH') {
if (CommonFunctions::executeProgram('uname', '-s', $strBuf, false) && ($strBuf !== '')) {
$this->sys->setOS($strBuf);
} else {
return $this->_kernel_string;
}
}
if ((CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) && ($strBuf !== '')) || // show effective kernel if ksplice uptrack is installed
(CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG) && ($strBuf !== ''))) {
$this->_kernel_string = $strBuf;
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG)) {
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG) && ($strBuf !== '')) {
if (preg_match('/ SMP /', $strBuf)) {
$this->_kernel_string .= ' (SMP)';
}
}
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG) && ($strBuf !== '')) {
$this->_kernel_string .= ' '.$strBuf;
}
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1)) {
if (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
if (preg_match('/\/Hurd-([^\)]+)/', $strBuf, $ar_buf)) {
$this->_kernel_string = $ar_buf[1];
} elseif (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
$this->_kernel_string = $ar_buf[1];
if (preg_match('/ SMP /', $strBuf)) {
$this->_kernel_string .= ' (SMP)';
}
241,11 → 250,20
}
 
/**
* check OS type
*/
public function __construct($blockname = false)
{
parent::__construct($blockname);
$this->_get_kernel_string();
}
 
/**
* Machine
*
* @return void
*/
private function _machine()
protected function _machine()
{
$machine_info = $this->_get_machine_info();
if (isset($machine_info['machine'])) {
279,7 → 297,7
*/
protected function _hostname()
{
if (PSI_USE_VHOST) {
if (PSI_USE_VHOST && !defined('PSI_EMU_PORT')) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
299,7 → 317,7
*
* @return void
*/
private function _kernel()
protected function _kernel()
{
if (($verBuf = $this->_get_kernel_string()) != "") {
$this->sys->setKernel($verBuf);
334,14 → 352,14
$novm = true;
// code based on src/basic/virt.c from systemd-detect-virt source code (https://github.com/systemd/systemd)
 
// First, try to detect Oracle Virtualbox and Amazon EC2 Nitro, even if they use KVM, as well as Xen even if
// it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also since it runs as a user-process
// nested inside other VMs. Also check for Xen now, because Xen PV mode does not override CPUID when nested
// inside another hypervisor.
// First, try to detect Oracle Virtualbox, Amazon EC2 Nitro and Parallels, even if they use KVM,
// as well as Xen even if it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also
// since it runs as a user-process nested inside other VMs. Also check for Xen now, because Xen PV
// mode does not override CPUID when nested inside another hypervisor.
$machine_info = $this->_get_machine_info();
if (isset($machine_info['hypervisor'])) {
$hypervisor = $machine_info['hypervisor'];
if (($hypervisor === 'oracle') || ($hypervisor === 'amazon') || ($hypervisor === 'xen')) {
if (($hypervisor === 'oracle') || ($hypervisor === 'amazon') || ($hypervisor === 'xen') || ($hypervisor === 'parallels')) {
$this->sys->setVirtualizer($hypervisor);
$novm = false;
}
520,12 → 538,15
*
* @return void
*/
protected function _uptime()
protected function _uptime($bufu = null)
{
if (CommonFunctions::rfts('/proc/uptime', $buf, 1, 4096, PSI_OS != 'Android')) {
$ar_buf = preg_split('/ /', $buf);
$this->sys->setUptime(trim($ar_buf[0]));
} elseif (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
} elseif (($this->_uptime !== null) || ($bufu !== null) || CommonFunctions::executeProgram('uptime', '', $bufu)) {
if (($this->_uptime === null) && ($bufu !== null)) {
$this->_uptime = $bufu;
}
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[3];
$hours = $ar_buf[2];
539,9 → 560,19
$min = $ar_buf[2];
$hours = $ar_buf[1];
$this->sys->setUptime($hours * 3600 + $min * 60);
} elseif (preg_match("/up[ ]+(\d+):(\d+):(\d+)/", $this->_uptime, $ar_buf)) {
$sec = $ar_buf[3];
$min = $ar_buf[2];
$hours = $ar_buf[1];
$this->sys->setUptime($hours * 3600 + $min * 60 + $sec);
} elseif (preg_match("/up[ ]+(\d+) min,/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[1];
$this->sys->setUptime($min * 60);
} elseif (preg_match("/up[ ]+(\d+) day[s]?,[ ]+(\d+) hour[s]?,[ ]+(\d+) minute[s]?/", $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);
}
}
}
552,15 → 583,15
*
* @return void
*/
protected function _loadavg()
protected function _loadavg($buf = null)
{
if (CommonFunctions::rfts('/proc/loadavg', $buf, 1, 4096, PSI_OS != 'Android')) {
if ((($buf !== null) || CommonFunctions::rfts('/proc/loadavg', $buf, 1, 4096, PSI_OS != 'Android')) && preg_match("/^\d/", trim($buf))) {
$result = preg_split("/\s/", $buf, 4);
// don't need the extra values, only first three
unset($result[3]);
$this->sys->setLoad(implode(' ', $result));
} elseif ((($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) && preg_match("/load average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
} elseif (($buf === null) && ((($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) && preg_match("/load average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf))) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
if (PSI_LOAD_BAR) {
$this->sys->setLoadPercent($this->_parseProcStat('cpu'));
641,10 → 672,9
*
* @return void
*/
protected function _cpuinfo()
protected function _cpuinfo($bufr = null)
{
if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
 
if (($bufr !== null) || CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
$cpulist = null;
$raslist = null;
 
703,11 → 733,15
case 'cpu frequency':
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
$_cpus = round($bufr2[1]/1000000);
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
$_cpus = $bufr2[1];
}
break;
case 'system bus frequency':
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
$_buss = round($bufr2[1]/1000000);
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
$_buss = $bufr2[1];
}
break;
case 'bogomips per cpu':
741,7 → 775,7
case 'processor':
$proc = $arrBuff1;
if (is_numeric($proc)) {
if (($procname !== null) && (strlen($procname)>0)) {
if (($procname !== null) && (strlen($procname) > 0)) {
$dev->setModel($procname);
}
} else {
755,25 → 789,40
case 'cpu':
$dev->setModel($arrBuff1);
break;
case 'cpu frequency':
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
if (($tmpsp = round($bufr2[1]/1000000)) > 0) {
$dev->setCpuSpeed($tmpsp);
$speedset = true;
}
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
if ($bufr2[1] > 0) {
$dev->setCpuSpeed($bufr2[1]);
$speedset = true;
}
}
break;
case 'cpu mhz':
case 'clock':
if ($arrBuff1 > 0) { // openSUSE fix
if ($arrBuff1 > 0) {
$dev->setCpuSpeed($arrBuff1);
$speedset = true;
}
break;
case 'cpu mhz static':
if ($arrBuff1 > 0) { // openSUSE fix
$dev->setCpuSpeedMax($arrBuff1);
}
$dev->setCpuSpeedMax($arrBuff1);
break;
case 'cycle frequency [hz]':
$dev->setCpuSpeed($arrBuff1 / 1000000);
$speedset = true;
if (($tmpsp = round($arrBuff1/1000000)) > 0) {
$dev->setCpuSpeed($tmpsp);
$speedset = true;
}
break;
case 'cpu0clktck':
$dev->setCpuSpeed(hexdec($arrBuff1) / 1000000); // Linux sparc64
$speedset = true;
case 'cpu0clktck': // Linux sparc64
if (($tmpsp = round(hexdec($arrBuff1)/1000000)) > 0) {
$dev->setCpuSpeed($tmpsp);
$speedset = true;
}
break;
case 'l3 cache':
case 'cache size':
845,8 → 894,8
// sparc64 specific code ends
 
// XScale detection code
if (($arch === "5TE") && ($dev->getBogomips() !== null)) {
$dev->setCpuSpeed($dev->getBogomips()); // BogoMIPS are not BogoMIPS on this CPU, it's the speed
if (($arch === "5TE") && (($bogo = $dev->getBogomips()) !== null) && ($bogo > 0)) {
$dev->setCpuSpeed($bogo); // BogoMIPS are not BogoMIPS on this CPU, it's the speed
$speedset = true;
$dev->setBogomips(null); // no BogoMIPS available, unset previously set BogoMIPS
}
854,7 → 903,7
if (($dev->getBusSpeed() == 0) && ($_buss !== null)) {
$dev->setBusSpeed($_buss);
}
if (($dev->getCpuSpeed() == 0) && ($_cpus !== null)) {
if (($dev->getCpuSpeed() == 0) && ($_cpus !== null) && ($_cpus > 0)) {
$dev->setCpuSpeed($_cpus);
$speedset = true;
}
873,18 → 922,20
$proc = 0;
}
// variable speed processors specific code follows
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false)) {
$dev->setCpuSpeed(trim($buf) / 1000);
$speedset = true;
} elseif (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) {
$dev->setCpuSpeed(trim($buf) / 1000);
$speedset = true;
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false)
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) {
if (round(trim($buf)/1000) > 0) {
$dev->setCpuSpeed(round(trim($buf)/1000));
$speedset = true;
}
}
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)) {
$dev->setCpuSpeedMax(trim($buf) / 1000);
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_max_freq', $buf, 1, 4096, false)) {
$dev->setCpuSpeedMax(round(trim($buf)/1000));
}
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)) {
$dev->setCpuSpeedMin(trim($buf) / 1000);
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_min_freq', $buf, 1, 4096, false)) {
$dev->setCpuSpeedMin(round(trim($buf)/1000));
}
// variable speed processors specific code ends
if (PSI_LOAD_BAR) {
901,9 → 952,15
&& (($_hard === 'BCM2708') || ($_hard === 'BCM2835') || ($_hard === 'BCM2709') || ($_hard === 'BCM2836') || ($_hard === 'BCM2710') || ($_hard === 'BCM2837') || ($_hard === 'BCM2711') || ($_hard === 'BCM2838'))
&& ($_revi !== null)) { // Raspberry Pi detection (instead of 'cat /proc/device-tree/model')
if ($raslist === null) $raslist = @parse_ini_file(PSI_APP_ROOT."/data/raspberry.ini", true);
$oldmach = $this->sys->getMachine();
if (($oldmach !== '') && preg_match("/^raspberrypi rpi(,.+)/", $oldmach, $machbuf)) {
$oldmachend = $machbuf[1];
} else {
$oldmachend = '';
}
if ($raslist && !preg_match('/[^0-9a-f]/', $_revi)) {
if (($revidec = hexdec($_revi)) & 0x800000) {
if ($this->sys->getMachine() === '') {
if (($oldmach === '') || ($oldmachend !== '')) {
$manufacturer = ($revidec >> 16) & 15;
if (isset($raslist['manufacturer'][$manufacturer])) {
$manuf = ' '.$raslist['manufacturer'][$manufacturer];
912,17 → 969,17
}
$model = ($revidec >> 4) & 255;
if (isset($raslist['model'][$model])) {
$this->sys->setMachine('Raspberry Pi '.$raslist['model'][$model].' (PCB 1.'.($revidec & 15).$manuf.')');
$this->sys->setMachine('Raspberry Pi '.$raslist['model'][$model].' (PCB 1.'.($revidec & 15).$manuf.')'.$oldmachend);
} else {
$this->sys->setMachine('Raspberry Pi (PCB 1.'.($revidec & 15).$manuf.')');
$this->sys->setMachine('Raspberry Pi (PCB 1.'.($revidec & 15).$manuf.')'.$oldmachend);
}
}
} else {
if ($this->sys->getMachine() === '') {
if (($oldmach === '') || ($oldmachend !== '')) {
if (isset($raslist['old'][$revidec & 0x7fffff])) {
$this->sys->setMachine('Raspberry Pi '.$raslist['old'][$revidec & 0x7fffff]);
$this->sys->setMachine('Raspberry Pi '.$raslist['old'][$revidec & 0x7fffff].$oldmachend);
} else {
$this->sys->setMachine('Raspberry Pi');
$this->sys->setMachine('Raspberry Pi'.$oldmachend);
}
}
}
1119,52 → 1176,54
*
* @return void
*/
protected function _usb()
protected function _usb($bufu = null)
{
$usbarray = array();
if (CommonFunctions::executeProgram('lsusb', (PSI_OS != 'Android')?'':'2>/dev/null', $bufr, PSI_DEBUG && (PSI_OS != 'Android'), 5) && ($bufr !== "")) {
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
$device = preg_split("/ /", $buf, 7);
if (((isset($device[6]) && trim($device[6]) != "")) ||
((isset($device[5]) && trim($device[5]) != ""))) {
$usbid = intval($device[1]).'-'.intval(trim($device[3], ':')).' '.$device[5];
if ((isset($device[6]) && trim($device[6]) != "")) {
$usbarray[$usbid]['name'] = trim($device[6]);
} else {
$usbarray[$usbid]['name'] = 'unknown';
if ($nobufu = ($bufu === null)) {
if (CommonFunctions::executeProgram('lsusb', (PSI_OS != 'Android')?'':'2>/dev/null', $bufr, PSI_DEBUG && (PSI_OS != 'Android'), 5) && ($bufr !== "")) {
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
$device = preg_split("/ /", $buf, 7);
if (((isset($device[6]) && trim($device[6]) != "")) ||
((isset($device[5]) && trim($device[5]) != ""))) {
$usbid = intval($device[1]).'-'.intval(trim($device[3], ':')).' '.$device[5];
if ((isset($device[6]) && trim($device[6]) != "")) {
$usbarray[$usbid]['name'] = trim($device[6]);
} else {
$usbarray[$usbid]['name'] = 'unknown';
}
}
}
}
}
 
$usbdevices = CommonFunctions::findglob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) {
for ($i = 0; $i < $total; $i++) {
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { // is readable
$busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum');
$devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum');
$idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor');
if (($busnum!==null) && ($devnum!==null) && ($idvendor!==null)) {
$usbid = intval($busnum).'-'.intval($devnum).' '.$idvendor.':'.$idproduct;
$manufacturer = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/manufacturer');
if ($manufacturer!==null) {
$usbarray[$usbid]['manufacturer'] = $manufacturer;
}
$product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product');
if ($product!==null) {
$usbarray[$usbid]['product'] = $product;
}
$speed = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/speed');
if ($product!==null) {
$usbarray[$usbid]['speed'] = $speed;
}
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial');
if (($serial!==null) && !preg_match('/\W/', $serial)) {
$usbarray[$usbid]['serial'] = $serial;
$usbdevices = CommonFunctions::findglob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) {
for ($i = 0; $i < $total; $i++) {
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { // is readable
$busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum');
$devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum');
$idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor');
if (($busnum!==null) && ($devnum!==null) && ($idvendor!==null)) {
$usbid = intval($busnum).'-'.intval($devnum).' '.$idvendor.':'.$idproduct;
$manufacturer = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/manufacturer');
if ($manufacturer!==null) {
$usbarray[$usbid]['manufacturer'] = $manufacturer;
}
$product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product');
if ($product!==null) {
$usbarray[$usbid]['product'] = $product;
}
$speed = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/speed');
if ($product!==null) {
$usbarray[$usbid]['speed'] = $speed;
}
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial');
if (($serial!==null) && !preg_match('/\W/', $serial)) {
$usbarray[$usbid]['serial'] = $serial;
}
}
}
}
}
1171,9 → 1230,9
}
}
 
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { // usb-devices
if (!$nobufu || ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufu, 0, 4096, false))) { // usb-devices
$devnum = -1;
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
$bufe = preg_split("/\n/", $bufu, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
if (preg_match('/^T/', $buf)) {
$devnum++;
1202,7 → 1261,7
}
}
 
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/input/devices', $bufr, 0, 4096, false)) {
if ($nobufu && (count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/input/devices', $bufr, 0, 4096, false)) {
$devnam = "unknown";
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
1375,9 → 1434,9
*
* @return void
*/
protected function _network()
protected function _network($bufr = null)
{
if (CommonFunctions::rfts('/proc/net/dev', $bufr, 0, 4096, PSI_DEBUG)) {
if (($bufr === null) && CommonFunctions::rfts('/proc/net/dev', $bufr, 0, 4096, PSI_DEBUG)) {
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
if (preg_match('/:/', $buf)) {
1420,7 → 1479,8
|| preg_match('/^'.trim($dev_name).':\s+ip\s+(\S+)\s+mask/i', $buf2, $ar_buf2)
|| preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $buf2, $ar_buf2)
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $buf2, $ar_buf2)
|| preg_match('/^\s+inet6?\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2))
|| preg_match('/^\s+inet6?\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2)
|| preg_match('/^\s+inet\saddr6:\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]));
}
1447,7 → 1507,7
$this->sys->setNetDevices($dev);
}
}
} elseif (CommonFunctions::executeProgram('ip', 'addr show', $bufr, PSI_DEBUG) && ($bufr!="")) {
} elseif (($bufr === null) && CommonFunctions::executeProgram('ip', 'addr show', $bufr, PSI_DEBUG) && ($bufr!="")) {
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
$was = false;
$macaddr = "";
1526,7 → 1586,7
}
$this->sys->setNetDevices($dev);
}
} elseif (CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) {
} elseif (($bufr !== null) || CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) {
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
$was = false;
$errors = 0;
1617,7 → 1677,8
} elseif ((preg_match('/^\s+inet\saddr:(\S+)/i', $line, $ar_buf2)
|| preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $line, $ar_buf2)
|| preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $line, $ar_buf2)
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $line, $ar_buf2))
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $line, $ar_buf2)
|| preg_match('/^\s+inet\saddr6:\s+(\S+)\s+prefixlen(.+)/i', $line, $ar_buf2))
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
}
1644,9 → 1705,9
*
* @return void
*/
protected function _memory()
protected function _memory($mbuf = null, $sbuf = null)
{
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
if (($mbuf !== null) || CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
$swaptotal = null;
$swapfree = null;
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
1670,7 → 1731,7
if (($this->sys->getMemCache() !== null) && ($this->sys->getMemBuffer() !== null)) {
$this->sys->setMemApplication($this->sys->getMemUsed() - $this->sys->getMemCache() - $this->sys->getMemBuffer());
}
if (CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) {
if (($sbuf !== null) || CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) {
$swaps = preg_split("/\n/", $sbuf, -1, PREG_SPLIT_NO_EMPTY);
unset($swaps[0]);
foreach ($swaps as $swap) {
1699,7 → 1760,7
*
* @return void
*/
private function _filesystems()
protected function _filesystems()
{
$df_args = "";
$hideFstypes = array();
2039,6 → 2100,26
$this->sys->setDistribution(trim($buf));
}
}
} elseif (CommonFunctions::fileexists($filename="/etc/slackware-version")) {
if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
$buf = "";
}
if (isset($list['Slackware']['Image'])) {
$this->sys->setDistributionIcon($list['Slackware']['Image']);
}
if (isset($list['Slackware']['Name'])) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution($list['Slackware']['Name']);
} else {
$this->sys->setDistribution($list['Slackware']['Name']." ".trim($buf));
}
} else {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution('Slackware');
} else {
$this->sys->setDistribution(trim($buf));
}
}
} elseif (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf")
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
/web/acc/phpsysinfo/includes/os/class.OS.inc.php
52,6 → 52,7
$this->error = PSI_Error::singleton();
$this->sys = new System();
$this->blockname = $blockname;
$this->sys->setOS(get_class($this));
}
 
/**
/web/acc/phpsysinfo/includes/os/class.SSH.inc.php
0,0 → 1,848
<?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;
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 '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 '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();
}
}
}
/web/acc/phpsysinfo/includes/output/class.WebpageXML.inc.php
61,7 → 61,26
private function _prepare()
{
if ($this->_pluginName === null) {
if (((PSI_OS == 'WINNT') || (PSI_OS == 'Linux')) && defined('PSI_WMI_HOSTNAME')) {
if ((PSI_OS == 'Linux') && defined('PSI_SSH_HOSTNAME') && defined('PSI_SSH_USER') && defined('PSI_SSH_PASSWORD')) {
$fgthost = preg_split("/:/", PSI_SSH_HOSTNAME, -1, PREG_SPLIT_NO_EMPTY);
define('PSI_EMU_HOSTNAME', trim($fgthost[0]));
if (isset($fgthost[1]) && (trim($fgthost[1] !== ''))) {
define('PSI_EMU_PORT', trim($fgthost[1]));
} else {
define('PSI_EMU_PORT', 22);
}
define('PSI_EMU_USER', PSI_SSH_USER);
define('PSI_EMU_PASSWORD', PSI_SSH_PASSWORD);
if (defined('PSI_SSH_ADD_PATHS')) {
define('PSI_EMU_ADD_PATHS', PSI_SSH_ADD_PATHS);
}
if (defined('PSI_SSH_ADD_OPTIONS')) {
define('PSI_EMU_ADD_OPTIONS', PSI_SSH_ADD_OPTIONS);
}
if (!file_exists(PSI_APP_ROOT.'/includes/os/class.Linux.inc.php')) {
$this->error->addError("file_exists(class.Linux.inc.php)", "Linux is not currently supported");
}
} elseif (((PSI_OS == 'WINNT') || (PSI_OS == 'Linux')) && defined('PSI_WMI_HOSTNAME')) {
define('PSI_EMU_HOSTNAME', PSI_WMI_HOSTNAME);
if (defined('PSI_WMI_USER') && defined('PSI_WMI_PASSWORD')) {
define('PSI_EMU_USER', PSI_WMI_USER);
141,7 → 160,23
} else {
if ((PSI_OS == 'WINNT') || (PSI_OS == 'Linux')) {
$plugname = strtoupper(trim($this->_pluginName));
if (defined('PSI_PLUGIN_'.$plugname.'_WMI_HOSTNAME')) {
if ((PSI_OS == 'Linux') && defined('PSI_PLUGIN_'.$plugname.'_SSH_HOSTNAME') && defined('PSI_PLUGIN_'.$plugname.'_SSH_USER') && defined('PSI_PLUGIN_'.$plugname.'_SSH_PASSWORD')) {
$fgthost = preg_split("/:/", constant('PSI_PLUGIN_'.$plugname.'_SSH_HOSTNAME'), -1, PREG_SPLIT_NO_EMPTY);
define('PSI_EMU_HOSTNAME', trim($fgthost[0]));
if (isset($fgthost[1]) && (trim($fgthost[1] !== ''))) {
define('PSI_EMU_PORT', trim($fgthost[1]));
} else {
define('PSI_EMU_PORT', 22);
}
define('PSI_EMU_USER', constant('PSI_PLUGIN_'.$plugname.'_SSH_USER'));
define('PSI_EMU_PASSWORD', constant('PSI_PLUGIN_'.$plugname.'_SSH_PASSWORD'));
if (defined('PSI_PLUGIN_'.$plugname.'_SSH_ADD_PATHS')) {
define('PSI_EMU_ADD_PATHS', constant('PSI_PLUGIN_'.$plugname.'_SSH_ADD_PATHS'));
}
if (defined('PSI_PLUGIN_'.$plugname.'_SSH_ADD_OPTIONS')) {
define('PSI_EMU_ADD_OPTIONS', constant('PSI_PLUGIN_'.$plugname.'_SSH_ADD_OPTIONS'));
}
} elseif (defined('PSI_PLUGIN_'.$plugname.'_WMI_HOSTNAME')) {
define('PSI_EMU_HOSTNAME', constant('PSI_PLUGIN_'.$plugname.'_WMI_HOSTNAME'));
if (defined('PSI_PLUGIN_'.$plugname.'_WMI_USER') && defined('PSI_PLUGIN_'.$plugname.'_WMI_PASSWORD')) {
define('PSI_EMU_USER', constant('PSI_PLUGIN_'.$plugname.'_WMI_USER'));
150,6 → 185,22
define('PSI_EMU_USER', null);
define('PSI_EMU_PASSWORD', null);
}
} elseif ((PSI_OS == 'Linux') && defined('PSI_SSH_HOSTNAME') && defined('PSI_SSH_USER') && defined('PSI_SSH_PASSWORD')) {
$fgthost = preg_split("/:/", PSI_SSH_HOSTNAME, -1, PREG_SPLIT_NO_EMPTY);
define('PSI_EMU_HOSTNAME', trim($fgthost[0]));
if (isset($fgthost[1]) && (trim($fgthost[1] !== ''))) {
define('PSI_EMU_PORT', trim($fgthost[1]));
} else {
define('PSI_EMU_PORT', 22);
}
define('PSI_EMU_USER', PSI_SSH_USER);
define('PSI_EMU_PASSWORD', PSI_SSH_PASSWORD);
if (defined('PSI_SSH_ADD_PATHS')) {
define('PSI_EMU_ADD_PATHS', PSI_SSH_ADD_PATHS);
}
if (defined('PSI_SSH_ADD_OPTIONS')) {
define('PSI_EMU_ADD_OPTIONS', PSI_SSH_ADD_OPTIONS);
}
} elseif (defined('PSI_WMI_HOSTNAME')) {
define('PSI_EMU_HOSTNAME', PSI_WMI_HOSTNAME);
if (defined('PSI_WMI_USER') && defined('PSI_WMI_PASSWORD')) {
/web/acc/phpsysinfo/includes/to/class.System.inc.php
260,6 → 260,13
private $_virtualizer = array();
 
/**
* operating system type
*
* @var string
*/
private $_OS = "";
 
/**
* remove duplicate Entries and Count
*
* @param array $arrDev list of HWDevices
1281,4 → 1288,30
}
}
}
 
/**
* Returns $_OS.
*
* @see System::$_OS
*
* @return string
*/
public function getOS()
{
return $this->_OS;
}
 
/**
* Sets $_OS.
*
* @param $os operating system type
*
* @see System::$_OS
*
* @return void
*/
public function setOS($OS)
{
$this->_OS = $OS;
}
}
/web/acc/phpsysinfo/includes/to/device/class.NetDevice.inc.php
68,6 → 68,20
private $_info = null;
 
/**
* transmitted bytes rate
*
* @var int
*/
private $_txRate = null;
 
/**
* received bytes rate
*
* @var int
*/
private $_rxRate = null;
 
/**
* Returns $_drops.
*
* @see NetDevice::$_drops
222,4 → 236,55
{
$this->_info = $info;
}
/**
* Returns $_rxRate.
*
* @see NetDevice::$_rxRate
*
* @return int
*/
public function getRxRate()
{
return $this->_rxRate;
}
 
/**
* Sets $_rxRate.
*
* @param int $rxRate received bytes rate
*
* @see NetDevice::$_rxRate
*
* @return void
*/
public function setRxRate($rxRate)
{
$this->_rxRate = $rxRate;
}
 
/**
* Returns $_txRate.
*
* @see NetDevice::$_txRate
*
* @return int
*/
public function getTxRate()
{
return $this->_txRate;
}
 
/**
* Sets $_txRate.
*
* @param int $txRate transmitted bytes rate
*
* @see NetDevice::$_txRate
*
* @return void
*/
public function setTxRate($txRate)
{
$this->_txRate = $txRate;
}
}
/web/acc/phpsysinfo/includes/ups/class.apcupsd.inc.php
78,7 → 78,7
}
}
} else { //use default if address and port not defined
if (!defined('PSI_EMU_HOSTNAME')) {
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) {
CommonFunctions::executeProgram('apcaccess', 'status', $temp);
} else {
CommonFunctions::executeProgram('apcaccess', 'status '.PSI_EMU_HOSTNAME, $temp);
/web/acc/phpsysinfo/includes/ups/class.nut.inc.php
84,7 → 84,7
}
}
} else { //use default if address and port not defined
if (!defined('PSI_EMU_HOSTNAME')) {
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) {
CommonFunctions::executeProgram('upsc', '-l', $output, PSI_DEBUG);
} else {
CommonFunctions::executeProgram('upsc', '-l '.PSI_EMU_HOSTNAME, $output, PSI_DEBUG);
/web/acc/phpsysinfo/includes/xml/class.SimpleXMLExtended.inc.php
211,7 → 211,11
}
}
} else {
return mb_convert_encoding($str, 'UTF-8');
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($str, 'UTF-8');
} else {
return $str;
}
}
}
 
/web/acc/phpsysinfo/includes/xml/class.XML.inc.php
92,7 → 92,9
} else {
$this->_complete_request = false;
}
if (defined('PSI_EMU_HOSTNAME')) {
if (defined('PSI_EMU_PORT')) {
$os = 'SSH';
} elseif (defined('PSI_EMU_HOSTNAME')) {
$os = 'WINNT';
} else {
$os = PSI_OS;
161,10 → 163,12
}
}
 
if (defined('PSI_EMU_HOSTNAME')) {
$vitals->addAttribute('OS', 'WINNT');
if (($os = $this->_sys->getOS()) == 'Android') {
$vitals->addAttribute('OS', 'Linux');
} elseif ($os == 'GNU') {
$vitals->addAttribute('OS', 'Hurd');
} else {
$vitals->addAttribute('OS', (PSI_OS=='Android')?'Linux':PSI_OS);
$vitals->addAttribute('OS', $os);
}
}
 
203,8 → 207,28
if (!$hide) {
$device = $network->addChild('NetDevice');
$device->addAttribute('Name', $dev->getName());
$device->addAttribute('RxBytes', $dev->getRxBytes());
$device->addAttribute('TxBytes', $dev->getTxBytes());
$rxbytes = $dev->getRxBytes();
$txbytes = $dev->getTxBytes();
$device->addAttribute('RxBytes', $rxbytes);
$device->addAttribute('TxBytes', $txbytes);
if (defined('PSI_SHOW_NETWORK_ACTIVE_SPEED') && PSI_SHOW_NETWORK_ACTIVE_SPEED) {
if (($rxbytes == 0) && ($txbytes == 0)) {
$rxrate = $dev->getRxRate();
$txrate = $dev->getTxRate();
if (($rxrate !== null) || ($txrate !== null)) {
if ($rxrate !== null) {
$device->addAttribute('RxRate', $rxrate);
} else {
$device->addAttribute('RxRate', 0);
}
if ($txrate !== null) {
$device->addAttribute('TxRate', $txrate);
} else {
$device->addAttribute('TxRate', 0);
}
}
}
}
$device->addAttribute('Err', $dev->getErrors());
$device->addAttribute('Drops', $dev->getDrops());
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS && $dev->getInfo())
222,16 → 246,29
{
$hardware = $this->_xml->addChild('Hardware');
if (($machine = $this->_sys->getMachine()) != "") {
if ((preg_match('/^(.* (.*\/.*\/.*))\/(.*\/.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^(.* (.*\/.*))\/(.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^(.* (.*))\/(.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^((.*\/.*\/.*))\/(.*\/.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^((.*\/.*))\/(.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
|| preg_match('/^((.*))\/(.*)(, BIOS .*)$/', $machine, $mbuf))
&& ($mbuf[2] === $mbuf[3])) { // find duplicates
$machine = $mbuf[1].$mbuf[4]; // minimized machine name
$machine = trim(preg_replace("/\s+/", " ", preg_replace("/^\s*[\/,]*/", "", preg_replace("/\/\s+,/", "/,", $machine)))); // remove leading slash or comma and unnecessary spaces
if (preg_match('/, BIOS .*$/', $machine, $mbuf, PREG_OFFSET_CAPTURE)) {
$comapos = $mbuf[0][1];
$endstr = $mbuf[0][0];
$offset = 0;
while (($offset < $comapos)
&& (($slashpos = strpos($machine, "/", $offset)) !== false)
&& ($slashpos < $comapos)) {
$len1 = $comapos - $slashpos - 1;
$str1 = substr($machine, $slashpos + 1, $len1);
$begstr = substr($machine, 0, $slashpos);
if ($len1 > 0) { // no empty
$str2 = substr($begstr, -$len1 - 1);
} else {
$str2 = " ";
}
if ((" ".$str1 === $str2) || ($str1 === $begstr)) { // duplicates
$machine = $begstr.$endstr;
break;
}
$offset = $slashpos + 1;
}
}
$machine = trim(preg_replace("/^\s*\/?,?/", "", $machine)); // remove leading slash and comma
 
if ($machine != "") {
$hardware->addAttribute('Name', $machine);