* Mon May 12 2025 Brian Read <brianr@koozali.org> 11.0.0-1.sme
- Adding SM2 panel [SME: 13004] - Upgrade to phpsysinfo 3.4.4 - Add code to delete inline styles and add css to make it look better. - version saved / built uses the static version, which means no drops downs and choices.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* @package PSI SunOS OS class
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version SVN: $Id: class.SunOS.inc.php 687 2012-09-06 20:54:49Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -20,12 +20,89 @@
|
||||
* @package PSI SunOS OS class
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class SunOS extends OS
|
||||
{
|
||||
|
||||
/**
|
||||
* content of prtconf -v
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_prtconf = null;
|
||||
|
||||
/**
|
||||
* Execute prtconf -v and save ass array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function prtconf()
|
||||
{
|
||||
if ($this->_prtconf === null) {
|
||||
$this->_prtconf = array();
|
||||
if (CommonFunctions::executeProgram('prtconf', '-v', $buf, PSI_DEBUG) && ($buf!="")) {
|
||||
$blocks = preg_split('/\n(?= \S)/', $buf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($blocks) && (count($blocks)>2)) {
|
||||
array_shift($blocks);
|
||||
foreach ($blocks as $block) {
|
||||
if (preg_match('/^ (\S+) /', $block, $ar_buf)) {
|
||||
$group = trim($ar_buf[1], ',');
|
||||
$grouparr = array();
|
||||
$blocks1 = preg_split('/\n(?= \S)/', $block, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($blocks1) && count($blocks1)) {
|
||||
array_shift($blocks1);
|
||||
foreach ($blocks1 as $block1) {
|
||||
if (!preg_match('/^ name=\'([^\']+)\'/', $block1)
|
||||
&& preg_match('/^ (\S+) /', $block1, $ar_buf)) {
|
||||
$device = trim($ar_buf[1], ',');
|
||||
$devicearr = array();
|
||||
$blocks2 = preg_split('/\n(?= \S)/', $block1, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($blocks2) && count($blocks2)) {
|
||||
array_shift($blocks2);
|
||||
foreach ($blocks2 as $block2) {
|
||||
if (!preg_match('/^ name=\'([^\']+)\'/', $block2)
|
||||
&& preg_match('/^ (\S+) /', $block2, $ar_buf)) {
|
||||
$subdev = trim($ar_buf[1], ',');
|
||||
$subdevarr = array();
|
||||
$blocks3 = preg_split('/\n(?= \S)/', $block2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (!empty($blocks3) && count($blocks3)) {
|
||||
array_shift($blocks3);
|
||||
foreach ($blocks3 as $block3) {
|
||||
if (preg_match('/^ name=\'([^\']+)\' [\s\S]+ value=\'?([^\']+)\'?/m', $block3, $ar_buf)) {
|
||||
if ($subdev==='Hardware') {
|
||||
$subdevarr[$ar_buf[1]] = $ar_buf[2];
|
||||
$subdevarr['device'] = $device;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($subdevarr)) {
|
||||
$devicearr = $subdevarr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($devicearr)) {
|
||||
$grouparr[$device][] = $devicearr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($grouparr)) {
|
||||
$this->_prtconf[$group][] = $grouparr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_prtconf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract kernel values via kstat() interface
|
||||
*
|
||||
@@ -35,11 +112,10 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _kstat($key)
|
||||
{
|
||||
if (CommonFunctions::executeProgram('kstat', '-p d '.$key, $m, PSI_DEBUG) &&
|
||||
!is_null($m) && (trim($m)!=="")) {
|
||||
list($key, $value) = preg_split("/\t/", trim($m), 2);
|
||||
if (CommonFunctions::executeProgram('kstat', '-p d '.$key, $m, PSI_DEBUG) && ($m!=="")) {
|
||||
list($key, $value) = preg_split("/\t/", $m, 2);
|
||||
|
||||
return $value;
|
||||
return trim($value);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@@ -52,8 +128,8 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _hostname()
|
||||
{
|
||||
if (PSI_USE_VHOST === true) {
|
||||
$this->sys->setHostname(getenv('SERVER_NAME'));
|
||||
if (PSI_USE_VHOST) {
|
||||
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
|
||||
} else {
|
||||
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
|
||||
$ip = gethostbyname($result);
|
||||
@@ -64,24 +140,6 @@ class SunOS extends OS
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IP of the Virtual Host Name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _ip()
|
||||
{
|
||||
if (PSI_USE_VHOST === true) {
|
||||
$this->sys->setIp(gethostbyname($this->sys->getHostname()));
|
||||
} else {
|
||||
if (!($result = getenv('SERVER_ADDR'))) {
|
||||
$this->sys->setIp(gethostbyname($this->sys->getHostname()));
|
||||
} else {
|
||||
$this->sys->setIp($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kernel Version
|
||||
*
|
||||
@@ -89,12 +147,17 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _kernel()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('uname', '-s', $os, PSI_DEBUG)) {
|
||||
if (CommonFunctions::executeProgram('uname', '-r', $version, PSI_DEBUG)) {
|
||||
$this->sys->setKernel($os.' '.$version);
|
||||
} else {
|
||||
$this->sys->setKernel($os);
|
||||
if (CommonFunctions::executeProgram('uname', '-s', $kernel, PSI_DEBUG) && ($kernel != "")) {
|
||||
if (CommonFunctions::executeProgram('uname', '-r', $version, PSI_DEBUG) && ($version != "")) {
|
||||
$kernel.=' '.$version;
|
||||
}
|
||||
if (CommonFunctions::executeProgram('uname', '-v', $subversion, PSI_DEBUG) && ($subversion != "")) {
|
||||
$kernel.=' ('.$subversion.')';
|
||||
}
|
||||
if (CommonFunctions::executeProgram('uname', '-i', $platform, PSI_DEBUG) && ($platform != "")) {
|
||||
$kernel.=' '.$platform;
|
||||
}
|
||||
$this->sys->setKernel($kernel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,19 +172,6 @@ class SunOS extends OS
|
||||
$this->sys->setUptime(time() - $this->_kstat('unix:0:system_misc:boot_time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Users
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _users()
|
||||
{
|
||||
if (CommonFunctions::executeProgram('who', '-q', $buf, PSI_DEBUG)) {
|
||||
$who = preg_split('/=/', $buf);
|
||||
$this->sys->setUsers($who[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processor Load
|
||||
* optionally create a loadbar
|
||||
@@ -143,13 +193,75 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _cpuinfo()
|
||||
{
|
||||
$dev = new CpuDevice();
|
||||
if (CommonFunctions::executeProgram('uname', '-i', $buf, PSI_DEBUG)) {
|
||||
$dev->setModel(trim($buf));
|
||||
if (CommonFunctions::executeProgram('kstat', '-p d cpu_info:*:cpu_info*:core_id', $m, PSI_DEBUG) && ($m!=="")) {
|
||||
$cpuc = count(preg_split('/\n/', $m, -1, PREG_SPLIT_NO_EMPTY));
|
||||
for ($cpu=0; $cpu < $cpuc; $cpu++) {
|
||||
$dev = new CpuDevice();
|
||||
if (($buf = $this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':current_clock_Hz')) !== "") {
|
||||
$dev->setCpuSpeed($buf/1000000);
|
||||
} elseif (($buf = $this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':clock_MHz')) !== "") {
|
||||
$dev->setCpuSpeed($buf);
|
||||
}
|
||||
if (($buf = $this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':supported_frequencies_Hz')) !== "") {
|
||||
$cpuarr = preg_split('/:/', $buf, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (($cpuarrc=count($cpuarr))>1) {
|
||||
$dev->setCpuSpeedMin($cpuarr[0]/1000000);
|
||||
$dev->setCpuSpeedMax($cpuarr[$cpuarrc-1]/1000000);
|
||||
}
|
||||
}
|
||||
if (($buf =$this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':brand')) !== "") {
|
||||
$dev->setModel($buf);
|
||||
} elseif (($buf =$this->_kstat('cpu_info:'.$cpu.':cpu_info'.$cpu.':cpu_type')) !== "") {
|
||||
$dev->setModel($buf);
|
||||
} elseif (CommonFunctions::executeProgram('uname', '-p', $buf, PSI_DEBUG) && ($buf!="")) {
|
||||
$dev->setModel($buf);
|
||||
} elseif (CommonFunctions::executeProgram('uname', '-i', $buf, PSI_DEBUG) && ($buf!="")) {
|
||||
$dev->setModel($buf);
|
||||
}
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PCI devices
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _pci()
|
||||
{
|
||||
$prtconf = $this->prtconf();
|
||||
if ((count($prtconf)>1) && isset($prtconf['pci'])) {
|
||||
foreach ($prtconf['pci'] as $prt) {
|
||||
foreach ($prt as $pci) {
|
||||
foreach ($pci as $pcidev) {
|
||||
if (isset($pcidev['device'])) {
|
||||
$dev = new HWDevice();
|
||||
if (isset($pcidev['model'])) {
|
||||
$name = $pcidev['model'];
|
||||
} else {
|
||||
$name = $pcidev['device'];
|
||||
}
|
||||
if (isset($pcidev['device-name'])) {
|
||||
$name .= ': '.$pcidev['device-name'];
|
||||
}
|
||||
$dev->setName($name);
|
||||
|
||||
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
||||
if (isset($pcidev['subsystem-name']) && ($pcidev['subsystem-name']!=='unknown subsystem')) {
|
||||
$dev->setProduct($pcidev['subsystem-name']);
|
||||
}
|
||||
if (isset($pcidev['vendor-name'])) {
|
||||
$dev->setManufacturer($pcidev['vendor-name']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys->setPciDevices($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$dev->setCpuSpeed($this->_kstat('cpu_info:0:cpu_info0:clock_MHz'));
|
||||
$dev->setCache($this->_kstat('cpu_info:0:cpu_info0:cpu_type') * 1024);
|
||||
$this->sys->setCpus($dev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,23 +301,22 @@ class SunOS extends OS
|
||||
}
|
||||
}
|
||||
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
|
||||
if (CommonFunctions::executeProgram('ifconfig', $ar_buf[0], $bufr2, PSI_DEBUG)
|
||||
&& !is_null($bufr2) && (trim($bufr2) !== "")) {
|
||||
if (CommonFunctions::executeProgram('ifconfig', $ar_buf[0], $bufr2, PSI_DEBUG) && ($bufr2!=="")) {
|
||||
$bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe2 as $buf2) {
|
||||
if (preg_match('/^\s+ether\s+(\S+)/i', $buf2, $ar_buf2))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', $ar_buf2[1]));
|
||||
elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2))
|
||||
if (preg_match('/^\s+ether\s+(\S+)/i', $buf2, $ar_buf2)) {
|
||||
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
|
||||
} elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2)) {
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CommonFunctions::executeProgram('ifconfig', $ar_buf[0].' inet6', $bufr2, PSI_DEBUG)
|
||||
&& !is_null($bufr2) && (trim($bufr2) !== "")) {
|
||||
if (CommonFunctions::executeProgram('ifconfig', $ar_buf[0].' inet6', $bufr2, PSI_DEBUG) && ($bufr2!=="")) {
|
||||
$bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($bufe2 as $buf2) {
|
||||
if (preg_match('/^\s+inet6\s+([^\s\/]+)/i', $buf2, $ar_buf2)
|
||||
&& !preg_match('/^fe80::/i', $ar_buf2[1]))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
||||
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1]))
|
||||
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,14 +338,16 @@ class SunOS extends OS
|
||||
$this->sys->setMemTotal($this->_kstat('unix:0:system_pages:pagestotal') * $pagesize);
|
||||
$this->sys->setMemUsed($this->_kstat('unix:0:system_pages:pageslocked') * $pagesize);
|
||||
$this->sys->setMemFree($this->_kstat('unix:0:system_pages:pagesfree') * $pagesize);
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName('SWAP');
|
||||
$dev->setFsType('swap');
|
||||
$dev->setMountPoint('SWAP');
|
||||
$dev->setTotal($this->_kstat('unix:0:vminfo:swap_avail') / 1024);
|
||||
$dev->setUsed($this->_kstat('unix:0:vminfo:swap_alloc') / 1024);
|
||||
$dev->setFree($this->_kstat('unix:0:vminfo:swap_free') / 1024);
|
||||
$this->sys->setSwapDevices($dev);
|
||||
if (($swap=$this->_kstat('unix:0:vminfo:swap_avail')) > 0) {
|
||||
$dev = new DiskDevice();
|
||||
$dev->setName('SWAP');
|
||||
$dev->setFsType('swap');
|
||||
$dev->setMountPoint('SWAP');
|
||||
$dev->setTotal($swap / 1024);
|
||||
$dev->setUsed($this->_kstat('unix:0:vminfo:swap_alloc') / 1024);
|
||||
$dev->setFree($this->_kstat('unix:0:vminfo:swap_free') / 1024);
|
||||
$this->sys->setSwapDevices($dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,8 +402,21 @@ class SunOS extends OS
|
||||
*/
|
||||
private function _distro()
|
||||
{
|
||||
$this->sys->setDistribution('SunOS');
|
||||
$this->sys->setDistributionIcon('SunOS.png');
|
||||
if (CommonFunctions::rfts('/etc/release', $buf, 1, 4096, false) && (trim($buf)!="")) {
|
||||
$this->sys->setDistribution(trim($buf));
|
||||
$list = @parse_ini_file(PSI_APP_ROOT."/data/distros.ini", true);
|
||||
if ($list && preg_match('/^(\S+)\s*/', preg_replace('/^open\s+/', 'open', preg_replace('/^oracle\s+/', 'oracle', strtolower(trim($buf)))), $id_buf) && isset($list[$distid=(trim($id_buf[1].' sunos'))]['Image'])) {
|
||||
$this->sys->setDistributionIcon($list[$distid]['Image']);
|
||||
if (isset($list[trim($distid)]['Name'])) {
|
||||
$this->sys->setDistribution(trim($list[$distid]['Name']).' '.$this->sys->getDistribution());
|
||||
}
|
||||
} else {
|
||||
$this->sys->setDistributionIcon('SunOS.png');
|
||||
}
|
||||
} else {
|
||||
$this->sys->setDistribution('SunOS');
|
||||
$this->sys->setDistributionIcon('SunOS.png');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,22 +454,32 @@ class SunOS extends OS
|
||||
*
|
||||
* @see PSI_Interface_OS::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->error->addError("WARN", "The SunOS version of phpSysInfo is a work in progress, some things currently don't work");
|
||||
$this->_distro();
|
||||
$this->_hostname();
|
||||
$this->_ip();
|
||||
$this->_kernel();
|
||||
$this->_uptime();
|
||||
$this->_users();
|
||||
$this->_loadavg();
|
||||
$this->_cpuinfo();
|
||||
$this->_network();
|
||||
$this->_memory();
|
||||
$this->_filesystems();
|
||||
$this->_processes();
|
||||
$this->error->addWarning("The SunOS version of phpSysInfo is a work in progress, some things currently don't work");
|
||||
if (!$this->blockname || $this->blockname==='vitals') {
|
||||
$this->_distro();
|
||||
$this->_hostname();
|
||||
$this->_kernel();
|
||||
$this->_uptime();
|
||||
$this->_users();
|
||||
$this->_loadavg();
|
||||
$this->_processes();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='hardware') {
|
||||
$this->_cpuinfo();
|
||||
$this->_pci();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='memory') {
|
||||
$this->_memory();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='filesystem') {
|
||||
$this->_filesystems();
|
||||
}
|
||||
if (!$this->blockname || $this->blockname==='network') {
|
||||
$this->_network();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user