Line 27... |
Line 27... |
27 |
class Linux extends OS
|
27 |
class Linux extends OS
|
28 |
{
|
28 |
{
|
29 |
/**
|
29 |
/**
|
30 |
* Assoc array of all CPUs loads.
|
30 |
* Assoc array of all CPUs loads.
|
31 |
*/
|
31 |
*/
|
32 |
protected $_cpu_loads;
|
32 |
private $_cpu_loads = null;
|
33 |
|
33 |
|
34 |
/**
|
34 |
/**
|
35 |
* Machine
|
35 |
* Machine
|
36 |
*
|
36 |
*
|
37 |
* @return void
|
37 |
* @return void
|
Line 73... |
Line 73... |
73 |
$machine .= ", BIOS ".$bios;
|
73 |
$machine .= ", BIOS ".$bios;
|
74 |
}
|
74 |
}
|
75 |
}
|
75 |
}
|
76 |
|
76 |
|
77 |
if ($machine != "") {
|
77 |
if ($machine != "") {
|
78 |
$machine = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified) ?/i", "", $machine)));
|
78 |
$machine = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified|Default string) ?/i", "", $machine)));
|
79 |
}
|
79 |
}
|
80 |
|
80 |
|
81 |
if (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf") // QNAP detection
|
81 |
if (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf") // QNAP detection
|
82 |
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
|
82 |
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
|
83 |
&& preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
|
83 |
&& preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
|
Line 136... |
Line 136... |
136 |
}
|
136 |
}
|
137 |
}
|
137 |
}
|
138 |
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
|
138 |
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
|
139 |
$result .= ' '.$strBuf;
|
139 |
$result .= ' '.$strBuf;
|
140 |
}
|
140 |
}
|
141 |
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1) && preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
|
141 |
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1) && preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
|
142 |
$result = $ar_buf[1];
|
142 |
$result = $ar_buf[1];
|
143 |
if (preg_match('/SMP/', $strBuf)) {
|
143 |
if (preg_match('/SMP/', $strBuf)) {
|
144 |
$result .= ' (SMP)';
|
144 |
$result .= ' (SMP)';
|
145 |
}
|
145 |
}
|
146 |
}
|
146 |
}
|
Line 152... |
Line 152... |
152 |
$result .= ' [docker]';
|
152 |
$result .= ' [docker]';
|
153 |
} elseif (preg_match('/:\/system\.slice\/docker\-/m', $strBuf2)) {
|
153 |
} elseif (preg_match('/:\/system\.slice\/docker\-/m', $strBuf2)) {
|
154 |
$result .= ' [docker]';
|
154 |
$result .= ' [docker]';
|
155 |
}
|
155 |
}
|
156 |
}
|
156 |
}
|
157 |
if (CommonFunctions::rfts('/proc/version', $strBuf2, 1, 4096, false)
|
157 |
if (CommonFunctions::rfts('/proc/version', $strBuf2, 1, 4096, false)) {
|
158 |
&& preg_match('/^Linux version [\d\.-]+-Microsoft/', $strBuf2)) {
|
158 |
if (preg_match('/^Linux version [\d\.-]+-Microsoft/', $strBuf2)) {
|
159 |
$result .= ' [lxss]';
|
159 |
$result .= ' [wsl]';
|
- |
|
160 |
} elseif (preg_match('/^Linux version [\d\.-]+-microsoft-standard/', $strBuf2)) {
|
- |
|
161 |
$result .= ' [wsl2]';
|
- |
|
162 |
}
|
160 |
}
|
163 |
}
|
161 |
$this->sys->setKernel($result);
|
164 |
$this->sys->setKernel($result);
|
162 |
}
|
165 |
}
|
163 |
}
|
166 |
}
|
164 |
|
167 |
|
Line 226... |
Line 229... |
226 |
{
|
229 |
{
|
227 |
if (is_null($this->_cpu_loads)) {
|
230 |
if (is_null($this->_cpu_loads)) {
|
228 |
$this->_cpu_loads = array();
|
231 |
$this->_cpu_loads = array();
|
229 |
|
232 |
|
230 |
$cpu_tmp = array();
|
233 |
$cpu_tmp = array();
|
231 |
if (CommonFunctions::rfts('/proc/stat', $buf)) {
|
234 |
if (CommonFunctions::rfts('/proc/stat', $buf, 0, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
|
232 |
if (preg_match_all('/^(cpu[0-9]*) (.*)/m', $buf, $matches, PREG_SET_ORDER)) {
|
235 |
if (preg_match_all('/^(cpu[0-9]*) (.*)/m', $buf, $matches, PREG_SET_ORDER)) {
|
233 |
foreach ($matches as $line) {
|
236 |
foreach ($matches as $line) {
|
234 |
$cpu = $line[1];
|
237 |
$cpu = $line[1];
|
235 |
$buf2 = $line[2];
|
238 |
$buf2 = $line[2];
|
236 |
|
239 |
|
Line 247... |
Line 250... |
247 |
}
|
250 |
}
|
248 |
|
251 |
|
249 |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour)
|
252 |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour)
|
250 |
sleep(1);
|
253 |
sleep(1);
|
251 |
|
254 |
|
252 |
if (CommonFunctions::rfts('/proc/stat', $buf)) {
|
255 |
if (CommonFunctions::rfts('/proc/stat', $buf, 0, 4096, PSI_DEBUG)) {
|
253 |
if (preg_match_all('/^(cpu[0-9]*) (.*)/m', $buf, $matches, PREG_SET_ORDER)) {
|
256 |
if (preg_match_all('/^(cpu[0-9]*) (.*)/m', $buf, $matches, PREG_SET_ORDER)) {
|
254 |
foreach ($matches as $line) {
|
257 |
foreach ($matches as $line) {
|
255 |
$cpu = $line[1];
|
258 |
$cpu = $line[1];
|
256 |
if (isset($cpu_tmp[$cpu])) {
|
259 |
if (isset($cpu_tmp[$cpu])) {
|
257 |
$buf2 = $line[2];
|
260 |
$buf2 = $line[2];
|
Line 277... |
Line 280... |
277 |
}
|
280 |
}
|
278 |
|
281 |
|
279 |
if (isset($this->_cpu_loads[$cpuline])) {
|
282 |
if (isset($this->_cpu_loads[$cpuline])) {
|
280 |
return $this->_cpu_loads[$cpuline];
|
283 |
return $this->_cpu_loads[$cpuline];
|
281 |
} else {
|
284 |
} else {
|
282 |
return 0;
|
285 |
return null;
|
283 |
}
|
286 |
}
|
284 |
}
|
287 |
}
|
285 |
|
288 |
|
286 |
/**
|
289 |
/**
|
287 |
* CPU information
|
290 |
* CPU information
|
Line 610... |
Line 613... |
610 |
$booDevice = true;
|
613 |
$booDevice = true;
|
611 |
continue;
|
614 |
continue;
|
612 |
}
|
615 |
}
|
613 |
if ($booDevice) {
|
616 |
if ($booDevice) {
|
614 |
$dev = new HWDevice();
|
617 |
$dev = new HWDevice();
|
615 |
$dev->setName(preg_replace('/\([^\)]+\)\.$/', '', trim($strLine)));
|
618 |
$dev->setName(preg_replace('/\(rev\s[^\)]+\)\.$/', '', trim($strLine)));
|
616 |
$this->sys->setPciDevices($dev);
|
619 |
$this->sys->setPciDevices($dev);
|
617 |
/*
|
620 |
/*
|
618 |
list($strKey, $strValue) = preg_split('/: /', $strLine, 2);
|
621 |
list($strKey, $strValue) = preg_split('/: /', $strLine, 2);
|
619 |
if (!preg_match('/bridge/i', $strKey) && !preg_match('/USB/i ', $strKey)) {
|
622 |
if (!preg_match('/bridge/i', $strKey) && !preg_match('/USB/i ', $strKey)) {
|
620 |
$dev = new HWDevice();
|
623 |
$dev = new HWDevice();
|
621 |
$dev->setName(preg_replace('/\([^\)]+\)\.$/', '', trim($strValue)));
|
624 |
$dev->setName(preg_replace('/\(rev\s[^\)]+\)\.$/', '', trim($strValue)));
|
622 |
$this->sys->setPciDevices($dev);
|
625 |
$this->sys->setPciDevices($dev);
|
623 |
}
|
626 |
}
|
624 |
*/
|
627 |
*/
|
625 |
$booDevice = false;
|
628 |
$booDevice = false;
|
626 |
}
|
629 |
}
|
Line 771... |
Line 774... |
771 |
}
|
774 |
}
|
772 |
$product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product');
|
775 |
$product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product');
|
773 |
if ($product!==null) {
|
776 |
if ($product!==null) {
|
774 |
$usbarray[$usbid]['product'] = $product;
|
777 |
$usbarray[$usbid]['product'] = $product;
|
775 |
}
|
778 |
}
|
- |
|
779 |
$speed = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/speed');
|
- |
|
780 |
if ($product!==null) {
|
- |
|
781 |
$usbarray[$usbid]['speed'] = $speed;
|
- |
|
782 |
}
|
776 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
783 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
777 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
784 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
778 |
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial');
|
785 |
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial');
|
779 |
if (($serial!==null) && !preg_match('/\W/', $serial)) {
|
786 |
if (($serial!==null) && !preg_match('/\W/', $serial)) {
|
780 |
$usbarray[$usbid]['serial'] = $serial;
|
787 |
$usbarray[$usbid]['serial'] = $serial;
|
Line 783... |
Line 790... |
783 |
}
|
790 |
}
|
784 |
}
|
791 |
}
|
785 |
}
|
792 |
}
|
786 |
}
|
793 |
}
|
787 |
|
794 |
|
788 |
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) {
|
795 |
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { //usb-devices
|
789 |
$devnum = -1;
|
796 |
$devnum = -1;
|
790 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
797 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
791 |
foreach ($bufe as $buf) {
|
798 |
foreach ($bufe as $buf) {
|
792 |
if (preg_match('/^T/', $buf)) {
|
799 |
if (preg_match('/^T/', $buf)) {
|
793 |
$devnum++;
|
800 |
$devnum++;
|
- |
|
801 |
if (preg_match('/\sSpd=([\d\.]+)/', $buf, $bufr)
|
- |
|
802 |
&& isset($bufr[1]) && ($bufr[1]!=="")) {
|
- |
|
803 |
$usbarray[$devnum]['speed'] = $bufr[1];
|
- |
|
804 |
}
|
794 |
} elseif (preg_match('/^S:/', $buf)) {
|
805 |
} elseif (preg_match('/^S:/', $buf)) {
|
795 |
list($key, $value) = preg_split('/: /', $buf, 2);
|
806 |
list($key, $value) = preg_split('/: /', $buf, 2);
|
796 |
list($key, $value2) = preg_split('/=/', $value, 2);
|
807 |
list($key, $value2) = preg_split('/=/', $value, 2);
|
797 |
switch (trim($key)) {
|
808 |
switch (trim($key)) {
|
798 |
case 'Manufacturer':
|
809 |
case 'Manufacturer':
|
Line 857... |
Line 868... |
857 |
}
|
868 |
}
|
858 |
} else {
|
869 |
} else {
|
859 |
$product = '';
|
870 |
$product = '';
|
860 |
}
|
871 |
}
|
861 |
|
872 |
|
862 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
873 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
- |
|
874 |
if (isset($usbdev['speed'])) {
|
- |
|
875 |
$dev->setSpeed($usbdev['speed']);
|
- |
|
876 |
}
|
863 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL
|
877 |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL
|
864 |
&& isset($usbdev['serial'])) {
|
878 |
&& isset($usbdev['serial'])) {
|
865 |
$dev->setSerial($usbdev['serial']);
|
879 |
$dev->setSerial($usbdev['serial']);
|
- |
|
880 |
}
|
866 |
}
|
881 |
}
|
867 |
|
882 |
|
868 |
if (isset($usbdev['name']) && (($name=$usbdev['name']) !== 'unknown')) {
|
883 |
if (isset($usbdev['name']) && (($name=$usbdev['name']) !== 'unknown')) {
|
869 |
$dev->setName($name);
|
884 |
$dev->setName($name);
|
870 |
} else {
|
885 |
} else {
|
Line 1005... |
Line 1020... |
1005 |
foreach ($bufe2 as $buf2) {
|
1020 |
foreach ($bufe2 as $buf2) {
|
1006 |
// if (preg_match('/^'.trim($dev_name).'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
|
1021 |
// if (preg_match('/^'.trim($dev_name).'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
|
1007 |
if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
|
1022 |
if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
|
1008 |
|| preg_match('/\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $buf2, $ar_buf2)
|
1023 |
|| preg_match('/\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $buf2, $ar_buf2)
|
1009 |
|| preg_match('/^\s+ether\s+(\S+)\s+txqueuelen/i', $buf2, $ar_buf2)
|
1024 |
|| preg_match('/^\s+ether\s+(\S+)\s+txqueuelen/i', $buf2, $ar_buf2)
|
1010 |
|| preg_match('/^\s+link\/ether\s+(\S+)\s+brd/i', $buf2, $ar_buf2)
|
1025 |
|| preg_match('/^\s+link\/\S+\s+(\S+)\s+brd/i', $buf2, $ar_buf2)
|
1011 |
|| preg_match('/^\s+link\/ether\s+(\S+)$/i', $buf2, $ar_buf2)
|
1026 |
|| preg_match('/^\s+link\/\S+\s+(\S+)$/i', $buf2, $ar_buf2)) {
|
1012 |
|| preg_match('/^\s+link\/ieee802.11\s+(\S+)$/i', $buf2, $ar_buf2)) {
|
- |
|
1013 |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) {
|
1027 |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) {
|
1014 |
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
|
1028 |
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
|
1015 |
if ($macaddr === '00-00-00-00-00-00') { // empty
|
1029 |
if ($macaddr === '00-00-00-00-00-00') { // empty
|
1016 |
$macaddr = "";
|
1030 |
$macaddr = "";
|
1017 |
}
|
1031 |
}
|
Line 1036... |
Line 1050... |
1036 |
}
|
1050 |
}
|
1037 |
}
|
1051 |
}
|
1038 |
if ($macaddr != "") {
|
1052 |
if ($macaddr != "") {
|
1039 |
$dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
|
1053 |
$dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
|
1040 |
}
|
1054 |
}
|
- |
|
1055 |
if ((!CommonFunctions::rfts('/sys/class/net/'.trim($dev_name).'/operstate', $buf, 1, 4096, false) || (($down=strtolower(trim($buf)))=="") || ($down!=="down")) &&
|
1041 |
if (CommonFunctions::rfts('/sys/class/net/'.trim($dev_name).'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535)) {
|
1056 |
(CommonFunctions::rfts('/sys/class/net/'.trim($dev_name).'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535))) {
|
1042 |
if ($speed > 1000) {
|
1057 |
if ($speed > 1000) {
|
1043 |
$speed = $speed/1000;
|
1058 |
$speed = $speed/1000;
|
1044 |
$unit = "G";
|
1059 |
$unit = "G";
|
1045 |
} else {
|
1060 |
} else {
|
1046 |
$unit = "M";
|
1061 |
$unit = "M";
|
Line 1083... |
Line 1098... |
1083 |
$dev->setErrors($ar_buf2[2]+$ar_buf2[5]);
|
1098 |
$dev->setErrors($ar_buf2[2]+$ar_buf2[5]);
|
1084 |
$dev->setDrops($ar_buf2[3]+$ar_buf2[6]);
|
1099 |
$dev->setDrops($ar_buf2[3]+$ar_buf2[6]);
|
1085 |
}
|
1100 |
}
|
1086 |
$was = true;
|
1101 |
$was = true;
|
1087 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
1102 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
1088 |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (trim($buf)!="")) {
|
1103 |
if ((!CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/operstate', $buf, 1, 4096, false) || (($down=strtolower(trim($buf)))=="") || ($down!=="down")) &&
|
1089 |
$speed = trim($buf);
|
1104 |
(CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535))) {
|
1090 |
if ($speed > 1000) {
|
1105 |
if ($speed > 1000) {
|
1091 |
$speed = $speed/1000;
|
1106 |
$speed = $speed/1000;
|
1092 |
$unit = "G";
|
1107 |
$unit = "G";
|
1093 |
} else {
|
1108 |
} else {
|
1094 |
$unit = "M";
|
1109 |
$unit = "M";
|
1095 |
}
|
1110 |
}
|
1096 |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (trim($buf)!="")) {
|
1111 |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (($duplex=strtolower(trim($buf)))!="") && ($duplex!='unknown')) {
|
1097 |
$speedinfo = $speed.$unit.'b/s '.strtolower(trim($buf));
|
1112 |
$speedinfo = $speed.$unit.'b/s '.$duplex;
|
1098 |
} else {
|
1113 |
} else {
|
1099 |
$speedinfo = $speed.$unit.'b/s';
|
1114 |
$speedinfo = $speed.$unit.'b/s';
|
1100 |
}
|
1115 |
}
|
1101 |
}
|
1116 |
}
|
1102 |
}
|
1117 |
}
|
1103 |
} else {
|
1118 |
} else {
|
1104 |
if ($was) {
|
1119 |
if ($was) {
|
1105 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
1120 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
1106 |
if (preg_match('/^\s+link\/ether\s+(\S+)\s+brd/i', $line, $ar_buf2)) {
|
1121 |
if (preg_match('/^\s+link\/\S+\s+(\S+)\s+brd/i', $line, $ar_buf2)
|
- |
|
1122 |
|| preg_match('/^\s+link\/\S+\s+(\S+)$/i', $line, $ar_buf2)) {
|
1107 |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
|
1123 |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
|
1108 |
} elseif (preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $line, $ar_buf2)) {
|
1124 |
} elseif (preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $line, $ar_buf2)) {
|
1109 |
if ($ar_buf2[1] != $ar_buf2[2]) {
|
1125 |
if ($ar_buf2[1] != $ar_buf2[2]) {
|
1110 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
|
1126 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
|
1111 |
} else {
|
1127 |
} else {
|
Line 1155... |
Line 1171... |
1155 |
$macaddr = "";
|
1171 |
$macaddr = "";
|
1156 |
$dev = new NetDevice();
|
1172 |
$dev = new NetDevice();
|
1157 |
$dev->setName($ar_buf[1]);
|
1173 |
$dev->setName($ar_buf[1]);
|
1158 |
$was = true;
|
1174 |
$was = true;
|
1159 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
1175 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
1160 |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (trim($buf)!="")) {
|
1176 |
if ((!CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/operstate', $buf, 1, 4096, false) || (($down=strtolower(trim($buf)))=="") || ($down!=="down")) &&
|
1161 |
$speed = trim($buf);
|
1177 |
(CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535))) {
|
1162 |
if ($speed > 1000) {
|
1178 |
if ($speed > 1000) {
|
1163 |
$speed = $speed/1000;
|
1179 |
$speed = $speed/1000;
|
1164 |
$unit = "G";
|
1180 |
$unit = "G";
|
1165 |
} else {
|
1181 |
} else {
|
1166 |
$unit = "M";
|
1182 |
$unit = "M";
|
1167 |
}
|
1183 |
}
|
1168 |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (trim($buf)!="")) {
|
1184 |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (($duplex=strtolower(trim($buf)))!="") && ($duplex!='unknown')) {
|
1169 |
$speedinfo = $speed.$unit.'b/s '.strtolower(trim($buf));
|
1185 |
$speedinfo = $speed.$unit.'b/s '.$duplex;
|
1170 |
} else {
|
1186 |
} else {
|
1171 |
$speedinfo = $speed.$unit.'b/s';
|
1187 |
$speedinfo = $speed.$unit.'b/s';
|
1172 |
}
|
1188 |
}
|
1173 |
}
|
1189 |
}
|
1174 |
if (preg_match('/^'.$ar_buf[1].'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2))
|
1190 |
if (preg_match('/^'.$ar_buf[1].'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2)
|
- |
|
1191 |
|| preg_match('/^'.$ar_buf[1].'\s+Link\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $line, $ar_buf2)) {
|
1175 |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
|
1192 |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) {
|
- |
|
1193 |
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
|
- |
|
1194 |
if ($macaddr === '00-00-00-00-00-00') { // empty
|
- |
|
1195 |
$macaddr = "";
|
- |
|
1196 |
}
|
- |
|
1197 |
}
|
1176 |
elseif (preg_match('/^'.$ar_buf[1].':\s+ip\s+(\S+)\s+mask/i', $line, $ar_buf2))
|
1198 |
} elseif (preg_match('/^'.$ar_buf[1].':\s+ip\s+(\S+)\s+mask/i', $line, $ar_buf2))
|
1177 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
1199 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
1178 |
}
|
1200 |
}
|
1179 |
} else {
|
1201 |
} else {
|
1180 |
if ($was) {
|
1202 |
if ($was) {
|
1181 |
if (preg_match('/\sRX bytes:(\d+)\s/i', $line, $ar_buf2)) {
|
1203 |
if (preg_match('/\sRX bytes:(\d+)\s/i', $line, $ar_buf2)) {
|
Line 1193... |
Line 1215... |
1193 |
$drops +=$ar_buf2[2];
|
1215 |
$drops +=$ar_buf2[2];
|
1194 |
}
|
1216 |
}
|
1195 |
|
1217 |
|
1196 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
1218 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
1197 |
if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2)
|
1219 |
if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2)
|
- |
|
1220 |
|| preg_match('/\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $line, $ar_buf2)
|
1198 |
|| preg_match('/^\s+ether\s+(\S+)\s+txqueuelen/i', $line, $ar_buf2)) {
|
1221 |
|| preg_match('/^\s+ether\s+(\S+)\s+txqueuelen/i', $line, $ar_buf2)) {
|
1199 |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
|
1222 |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) {
|
- |
|
1223 |
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
|
- |
|
1224 |
if ($macaddr === '00-00-00-00-00-00') { // empty
|
- |
|
1225 |
$macaddr = "";
|
- |
|
1226 |
}
|
- |
|
1227 |
}
|
1200 |
} elseif (preg_match('/^\s+inet\saddr:(\S+)\s+P-t-P:(\S+)/i', $line, $ar_buf2)
|
1228 |
} elseif (preg_match('/^\s+inet\saddr:(\S+)\s+P-t-P:(\S+)/i', $line, $ar_buf2)
|
1201 |
|| preg_match('/^\s+inet\s+(\S+)\s+netmask.+destination\s+(\S+)/i', $line, $ar_buf2)) {
|
1229 |
|| preg_match('/^\s+inet\s+(\S+)\s+netmask.+destination\s+(\S+)/i', $line, $ar_buf2)) {
|
1202 |
if ($ar_buf2[1] != $ar_buf2[2]) {
|
1230 |
if ($ar_buf2[1] != $ar_buf2[2]) {
|
1203 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
|
1231 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
|
1204 |
} else {
|
1232 |
} else {
|