9
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
10
* @copyright 2009 phpSysInfo
11
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
12
* @version SVN: $Id: class.SunOS.inc.php 287 2009-06-26 12:11:59Z bigmichi1 $
13
* @link http://phpsysinfo.sourceforge.net
17
* get all the required information from SunOS systems
21
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
22
* @copyright 2009 phpSysInfo
23
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
24
* @version Release: 3.0
25
* @link http://phpsysinfo.sourceforge.net
27
class SunOS extends OS
30
* add warning to errors
32
public function __construct()
34
$this->error->addError("WARN", "The SunOS version of phpSysInfo is work in progress, some things currently don't work");
38
* Extract kernel values via kstat() interface
40
* @param string $key key for kstat programm
44
private function _kstat($key)
46
if (CommonFunctions::executeProgram('kstat', '-p d '.$key, $m, PSI_DEBUG)) {
47
list($key, $value) = preg_split("/\t/", trim($m), 2);
59
private function _hostname()
61
if (PSI_USE_VHOST === true) {
62
$this->sys->setHostname(getenv('SERVER_NAME'));
64
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
65
$ip = gethostbyname($result);
67
$this->sys->setHostname(gethostbyaddr($ip));
74
* IP of the Virtual Host Name
78
private function _ip()
80
if (PSI_USE_VHOST === true) {
81
$this->sys->setIp(gethostbyname($this->_hostname()));
83
if (!($result = getenv('SERVER_ADDR'))) {
84
$this->sys->setIp(gethostbyname($this->_hostname()));
86
$this->sys->setIp($result);
96
private function _kernel()
98
if (CommonFunctions::executeProgram('uname', '-s', $os, PSI_DEBUG)) {
99
if (CommonFunctions::executeProgram('uname', '-r', $version, PSI_DEBUG)) {
100
$this->sys->setKernel($os.' '.$version);
102
$this->sys->setKernel($os);
109
* time the system is running
113
private function _uptime()
115
$this->sys->setUptime(time() - $this->_kstat('unix:0:system_misc:boot_time'));
123
private function _users()
125
if (CommonFunctions::executeProgram('who', '-q', $buf, PSI_DEBUG)) {
126
$who = preg_split('/=/', $buf);
127
$this->sys->setUsers($who[1]);
133
* optionally create a loadbar
137
private function _loadavg()
139
$load1 = $this->_kstat('unix:0:system_misc:avenrun_1min');
140
$load5 = $this->_kstat('unix:0:system_misc:avenrun_5min');
141
$load15 = $this->_kstat('unix:0:system_misc:avenrun_15min');
142
$this->sys->setLoad(round($load1 / 256, 2).' '.round($load5 / 256, 2).' '.round($load15 / 256, 2));
150
private function _cpuinfo()
152
$dev = new CpuDevice();
153
if (CommonFunctions::executeProgram('uname', '-i', $buf, PSI_DEBUG)) {
154
$dev->setModel(trim($buf));
156
$dev->setCpuSpeed($this->_kstat('cpu_info:0:cpu_info0:clock_MHz'));
157
$dev->setCache($this->_kstat('cpu_info:0:cpu_info0:cpu_type') * 1024);
158
$this->sys->setCpus($dev);
166
private function _network()
168
if (CommonFunctions::executeProgram('netstat', '-ni | awk \'(NF ==10){print;}\'', $netstat, PSI_DEBUG)) {
169
$lines = preg_split("/\n/", $netstat, -1, PREG_SPLIT_NO_EMPTY);
170
foreach ($lines as $line) {
171
$ar_buf = preg_split("/\s+/", $line);
172
if (! empty($ar_buf[0]) && $ar_buf[0] !== 'Name') {
173
$dev = new NetDevice();
174
$dev->setName($ar_buf[0]);
175
$results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[7];
176
preg_match('/^(\D+)(\d+)$/', $ar_buf[0], $intf);
177
$prefix = $intf[1].':'.$intf[2].':'.$intf[1].$intf[2].':';
178
$cnt = $this->_kstat($prefix.'drop');
180
$dev->setDrops($cnt);
182
$cnt = $this->_kstat($prefix.'obytes64');
184
$dev->setTxBytes($cnt);
186
$cnt = $this->_kstat($prefix.'rbytes64');
188
$dev->setRxBytes($cnt);
190
$this->sys->setNetDevices($dev);
197
* Physical memory information and Swap Space information
201
private function _memory()
203
$pagesize = $this->_kstat('unix:0:seg_cache:slab_size');
204
$this->sys->setMemTotal($this->_kstat('unix:0:system_pages:pagestotal') * $pagesize);
205
$this->sys->setMemUsed($this->_kstat('unix:0:system_pages:pageslocked') * $pagesize);
206
$this->sys->setMemFree($this->_kstat('unix:0:system_pages:pagesfree') * $pagesize);
207
$dev = new DiskDevice();
208
$dev->setName('SWAP');
209
$dev->setFsType('swap');
210
$dev->setTotal($this->_kstat('unix:0:vminfo:swap_avail') / 1024);
211
$dev->setUsed($this->_kstat('unix:0:vminfo:swap_alloc') / 1024);
212
$dev->setFree($this->_kstat('unix:0:vminfo:swap_free') / 1024);
213
$this->sys->setSwapDevices($dev);
217
* filesystem information
221
private function _filesystems()
223
if (CommonFunctions::executeProgram('df', '-k', $df, PSI_DEBUG)) {
224
$mounts = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
225
foreach ($mounts as $mount) {
226
$ar_buf = preg_split('/\s+/', $mount, 6);
227
$dev = new DiskDevice();
228
$dev->setName($ar_buf[0]);
229
$dev->setTotal($ar_buf[1] * 1024);
230
$dev->setUsed($ar_buf[2] * 1024);
231
$dev->setFree($ar_buf[3] * 1024);
232
$dev->setMountPoint($ar_buf[5]);
233
if (CommonFunctions::executeProgram('df', '-n', $dftypes, PSI_DEBUG)) {
234
$mounttypes = preg_split("/\n/", $dftypes, -1, PREG_SPLIT_NO_EMPTY);
235
foreach ($mounttypes as $type) {
236
$ty_buf = preg_split('/:/', $type, 2);
237
if ($ty_buf == $dev->getName()) {
238
$dev->setFsType($ty_buf[1]);
243
$this->sys->setDiskDevices($dev);
253
private function _distro()
255
$this->sys->setDistribution('SunOS');
256
$this->sys->setDistributionIcon('SunOS.png');
260
* get the information
262
* @see PSI_Interface_OS::build()
278
$this->_filesystems();