Subversion Repositories ALCASAR

Rev

Rev 2770 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2770 Rev 2976
1
<?php
1
<?php
2
/**
2
/**
3
 * Haiku System Class
3
 * Haiku System Class
4
 *
4
 *
5
 * PHP version 5
5
 * PHP version 5
6
 *
6
 *
7
 * @category  PHP
7
 * @category  PHP
8
 * @package   PSI Haiku OS class
8
 * @package   PSI Haiku OS class
9
 * @author    Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
9
 * @author    Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
10
 * @copyright 2012 phpSysInfo
10
 * @copyright 2012 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
12
 * @version   SVN: $Id: class.Haiku.inc.php 687 2012-09-06 20:54:49Z namiltd $
12
 * @version   SVN: $Id: class.Haiku.inc.php 687 2012-09-06 20:54:49Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
14
 */
15
 /**
15
 /**
16
 * Haiku sysinfo class
16
 * Haiku sysinfo class
17
 * get all the required information from Haiku system
17
 * get all the required information from Haiku system
18
 *
18
 *
19
 * @category  PHP
19
 * @category  PHP
20
 * @package   PSI Haiku OS class
20
 * @package   PSI Haiku OS class
21
 * @author    Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
21
 * @author    Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
22
 * @copyright 2012 phpSysInfo
22
 * @copyright 2012 phpSysInfo
23
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
23
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
24
 * @version   Release: 3.0
24
 * @version   Release: 3.0
25
 * @link      http://phpsysinfo.sourceforge.net
25
 * @link      http://phpsysinfo.sourceforge.net
26
 */
26
 */
27
class Haiku extends OS
27
class Haiku extends OS
28
{
28
{
29
    /**
29
    /**
30
     * get the cpu information
30
     * get the cpu information
31
     *
31
     *
32
     * @return void
32
     * @return void
33
     */
33
     */
34
    protected function _cpuinfo()
34
    protected function _cpuinfo()
35
    {
35
    {
36
 
36
 
37
        if (CommonFunctions::executeProgram('sysinfo', '-cpu', $bufr, PSI_DEBUG)) {
37
        if (CommonFunctions::executeProgram('sysinfo', '-cpu', $bufr, PSI_DEBUG)) {
38
            $cpus = preg_split("/\nCPU #\d+/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
38
            $cpus = preg_split("/\nCPU #\d+/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
39
            $cpuspeed = "";
39
            $cpuspeed = "";
40
            foreach ($cpus as $cpu) {
40
            foreach ($cpus as $cpu) {
41
                if (preg_match("/^.*running at (\d+)MHz/", $cpu, $ar_buf)) {
41
                if (preg_match("/^.*running at (\d+)MHz/", $cpu, $ar_buf)) {
42
                    $cpuspeed = $ar_buf[1];
42
                    $cpuspeed = $ar_buf[1];
43
                } elseif (preg_match("/^: \"(.*)\"/", $cpu, $ar_buf)) {
43
                } elseif (preg_match("/^: \"(.*)\"/", $cpu, $ar_buf)) {
44
                    $dev = new CpuDevice();
44
                    $dev = new CpuDevice();
45
                    $dev->setModel($ar_buf[1]);
45
                    $dev->setModel($ar_buf[1]);
46
                    $arrLines = preg_split("/\n/", $cpu, -1, PREG_SPLIT_NO_EMPTY);
46
                    $arrLines = preg_split("/\n/", $cpu, -1, PREG_SPLIT_NO_EMPTY);
47
                    foreach ($arrLines as $Line) {
47
                    foreach ($arrLines as $Line) {
48
                        if (preg_match("/^\s+Data TLB:\s+(.*)K-byte/", $Line, $Line_buf)) {
48
                        if (preg_match("/^\s+Data TLB:\s+(.*)K-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)K-byte/", $Line, $Line_buf)) {
49
                            $dev->setCache(max($Line_buf[1]*1024, $dev->getCache()));
49
                            $dev->setCache(max(intval($Line_buf[1])*1024, $dev->getCache()));
50
                        } elseif (preg_match("/^\s+Data TLB:\s+(.*)M-byte/", $Line, $Line_buf)) {
50
                        } elseif (preg_match("/^\s+Data TLB:\s+(.*)M-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)M-byte/", $Line, $Line_buf)) {
51
                            $dev->setCache(max($Line_buf[1]*1024*1024, $dev->getCache()));
51
                            $dev->setCache(max(intval($Line_buf[1])*1024*1024, $dev->getCache()));
52
                        } elseif (preg_match("/^\s+Data TLB:\s+(.*)G-byte/", $Line, $Line_buf)) {
52
                        } elseif (preg_match("/^\s+Data TLB:\s+(.*)G-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)G-byte/", $Line, $Line_buf)) {
53
                            $dev->setCache(max($Line_buf[1]*1024*1024*1024, $dev->getCache()));
53
                            $dev->setCache(max(intval($Line_buf[1])*1024*1024*1024, $dev->getCache()));
54
                        } elseif (preg_match("/\s+VMX/", $Line, $Line_buf)) {
54
                        } elseif (preg_match("/\s+VMX/", $Line, $Line_buf)) {
55
                            $dev->setVirt("vmx");
55
                            $dev->setVirt("vmx");
56
                        } elseif (preg_match("/\s+SVM/", $Line, $Line_buf)) {
56
                        } elseif (preg_match("/\s+SVM/", $Line, $Line_buf)) {
57
                            $dev->setVirt("svm");
57
                            $dev->setVirt("svm");
58
                        }
58
                        }
59
                    }
59
                    }
60
                    if ($cpuspeed != "") {
60
                    if ($cpuspeed != "") {
61
                        $dev->setCpuSpeed($cpuspeed);
61
                        $dev->setCpuSpeed($cpuspeed);
62
                    }
62
                    }
63
                    $this->sys->setCpus($dev);
63
                    $this->sys->setCpus($dev);
64
                }
64
                }
65
            }
65
            }
66
        }
66
        }
67
    }
67
    }
68
 
68
 
69
    /**
69
    /**
70
     * PCI devices
70
     * PCI devices
71
     * get the pci device information
71
     * get the pci device information
72
     *
72
     *
73
     * @return void
73
     * @return void
74
     */
74
     */
75
    protected function _pci()
75
    protected function _pci()
76
    {
76
    {
77
        if (CommonFunctions::executeProgram('listdev', '', $bufr, PSI_DEBUG)) {
77
        if (CommonFunctions::executeProgram('listdev', '', $bufr, PSI_DEBUG)) {
78
//            $devices = preg_split("/^device |\ndevice /", $bufr, -1, PREG_SPLIT_NO_EMPTY);
78
//            $devices = preg_split("/^device |\ndevice /", $bufr, -1, PREG_SPLIT_NO_EMPTY);
79
            $devices = preg_split("/^device /m", $bufr, -1, PREG_SPLIT_NO_EMPTY);
79
            $devices = preg_split("/^device /m", $bufr, -1, PREG_SPLIT_NO_EMPTY);
80
            foreach ($devices as $device) {
80
            foreach ($devices as $device) {
81
                $ar_buf = preg_split("/\n/", $device);
81
                $ar_buf = preg_split("/\n/", $device);
82
                if (count($ar_buf) >= 3) {
82
                if (count($ar_buf) >= 3) {
83
                    if (preg_match("/^([^\(\[\n]*)/", $device, $ar_buf2)) {
83
                    if (preg_match("/^([^\(\[\n]*)/", $device, $ar_buf2)) {
84
                        if (preg_match("/^[^\(]*\((.*)\)/", $device, $ar_buf3)) {
84
                        if (preg_match("/^[^\(]*\((.*)\)/", $device, $ar_buf3)) {
85
                            $ar_buf2[1] = $ar_buf3[1];
85
                            $ar_buf2[1] = $ar_buf3[1];
86
                        }
86
                        }
87
                        $name = trim($ar_buf2[1]).": ";
87
                        $name = trim($ar_buf2[1]).": ";
88
 
88
 
89
                        if (preg_match("/^\s+vendor\s+[0-9a-fA-F]{4}:\s+(.*)/", $ar_buf[1], $ar_buf3)) {
89
                        if (preg_match("/^\s+vendor\s+[0-9a-fA-F]{4}:\s+(.*)/", $ar_buf[1], $ar_buf3)) {
90
                            $name .=$ar_buf3[1]." ";
90
                            $name .=$ar_buf3[1]." ";
91
                        }
91
                        }
92
                        if (preg_match("/^\s+device\s+[0-9a-fA-F]{4}:\s+(.*)/", $ar_buf[2], $ar_buf3)) {
92
                        if (preg_match("/^\s+device\s+[0-9a-fA-F]{4}:\s+(.*)/", $ar_buf[2], $ar_buf3)) {
93
                            $name .=$ar_buf3[1]." ";
93
                            $name .=$ar_buf3[1]." ";
94
                        }
94
                        }
95
                        $dev = new HWDevice();
95
                        $dev = new HWDevice();
96
                        $dev->setName(trim($name));
96
                        $dev->setName(trim($name));
97
                        $this->sys->setPciDevices($dev);
97
                        $this->sys->setPciDevices($dev);
98
                    }
98
                    }
99
                }
99
                }
100
            }
100
            }
101
        }
101
        }
102
    }
102
    }
103
 
103
 
104
    /**
104
    /**
105
     * USB devices
105
     * USB devices
106
     * get the usb device information
106
     * get the usb device information
107
     *
107
     *
108
     * @return void
108
     * @return void
109
     */
109
     */
110
    protected function _usb()
110
    protected function _usb()
111
    {
111
    {
112
        if (CommonFunctions::executeProgram('listusb', '', $bufr, PSI_DEBUG)) {
112
        if (CommonFunctions::executeProgram('listusb', '', $bufr, PSI_DEBUG)) {
113
            $devices = preg_split("/\n/", $bufr);
113
            $devices = preg_split("/\n/", $bufr);
114
            foreach ($devices as $device) {
114
            foreach ($devices as $device) {
115
                if (preg_match("/^\S+\s+\S+\s+\"(.*)\"\s+\"(.*)\"/", $device, $ar_buf)) {
115
                if (preg_match("/^\S+\s+\S+\s+\"(.*)\"\s+\"(.*)\"/", $device, $ar_buf)) {
116
                    $dev = new HWDevice();
116
                    $dev = new HWDevice();
117
                    $dev->setName(trim($ar_buf[1]." ".$ar_buf[2]));
117
                    $dev->setName(trim($ar_buf[1]." ".$ar_buf[2]));
118
                    $this->sys->setUSBDevices($dev);
118
                    $this->sys->setUSBDevices($dev);
119
                }
119
                }
120
            }
120
            }
121
        }
121
        }
122
    }
122
    }
123
 
123
 
124
    /**
124
    /**
125
     * Haiku Version
125
     * Haiku Version
126
     *
126
     *
127
     * @return void
127
     * @return void
128
     */
128
     */
129
    private function _kernel()
129
    private function _kernel()
130
    {
130
    {
131
        if (CommonFunctions::executeProgram('uname', '-rvm', $ret)) {
131
        if (CommonFunctions::executeProgram('uname', '-rvm', $ret)) {
132
            $this->sys->setKernel($ret);
132
            $this->sys->setKernel($ret);
133
        }
133
        }
134
    }
134
    }
135
 
135
 
136
    /**
136
    /**
137
     * Distribution
137
     * Distribution
138
     *
138
     *
139
     * @return void
139
     * @return void
140
     */
140
     */
141
    protected function _distro()
141
    protected function _distro()
142
    {
142
    {
143
        if (CommonFunctions::executeProgram('uname', '-sr', $ret))
143
        if (CommonFunctions::executeProgram('uname', '-sr', $ret))
144
            $this->sys->setDistribution($ret);
144
            $this->sys->setDistribution($ret);
145
        else
145
        else
146
            $this->sys->setDistribution('Haiku');
146
            $this->sys->setDistribution('Haiku');
147
 
147
 
148
        $this->sys->setDistributionIcon('Haiku.png');
148
        $this->sys->setDistributionIcon('Haiku.png');
149
    }
149
    }
150
 
150
 
151
    /**
151
    /**
152
     * UpTime
152
     * UpTime
153
     * time the system is running
153
     * time the system is running
154
     *
154
     *
155
     * @return void
155
     * @return void
156
     */
156
     */
157
    private function _uptime()
157
    private function _uptime()
158
    {
158
    {
159
        if (CommonFunctions::executeProgram('uptime', '-u', $buf)) {
159
        if (CommonFunctions::executeProgram('uptime', '', $buf)) {
160
            if (preg_match("/^up (\d+) minute[s]?/", $buf, $ar_buf)) {
160
            if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $buf, $ar_buf)) {
161
                $min = $ar_buf[1];
161
                $min = $ar_buf[3];
-
 
162
                $hours = $ar_buf[2];
-
 
163
                $days = $ar_buf[1];
162
                $this->sys->setUptime($min * 60);
164
                $this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
163
            } elseif (preg_match("/^up (\d+) hour[s]?, (\d+) minute[s]?/", $buf, $ar_buf)) {
165
            } elseif (preg_match("/up[ ]+(\d+):(\d+),/", $buf, $ar_buf)) {
164
                $min = $ar_buf[2];
166
                $min = $ar_buf[2];
165
                $hours = $ar_buf[1];
167
                $hours = $ar_buf[1];
166
                $this->sys->setUptime($hours * 3600 + $min * 60);
168
                $this->sys->setUptime($hours * 3600 + $min * 60);
167
            } elseif (preg_match("/^up (\d+) day[s]?, (\d+) hour[s]?, (\d+) minute[s]?/", $buf, $ar_buf)) {
169
            } elseif (preg_match("/up (\d+) day[s]?, (\d+) hour[s]?, (\d+) minute[s]?$/", $buf, $ar_buf)) {
168
                $min = $ar_buf[3];
170
                $min = $ar_buf[3];
169
                $hours = $ar_buf[2];
171
                $hours = $ar_buf[2];
170
                $days = $ar_buf[1];
172
                $days = $ar_buf[1];
171
                $this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
173
                $this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
-
 
174
            } elseif (preg_match("/up (\d+) hour[s]?, (\d+) minute[s]?$/", $buf, $ar_buf)) {
-
 
175
                $min = $ar_buf[2];
-
 
176
                $hours = $ar_buf[1];
-
 
177
                $this->sys->setUptime($hours * 3600 + $min * 60);
-
 
178
            } elseif (preg_match("/up (\d+) minute[s]?$/", $buf, $ar_buf)) {
-
 
179
                $min = $ar_buf[1];
-
 
180
                $this->sys->setUptime($min * 60);
172
            }
181
            }
173
        }
182
        }
174
    }
183
    }
175
 
184
 
176
    /**
185
    /**
177
     * Processor Load
186
     * Processor Load
178
     * optionally create a loadbar
187
     * optionally create a loadbar
179
     *
188
     *
180
     * @return void
189
     * @return void
181
     */
190
     */
182
    private function _loadavg()
191
    private function _loadavg()
183
    {
192
    {
184
        if (CommonFunctions::executeProgram('top', '-n 1 -i 1', $buf)) {
193
        if (CommonFunctions::executeProgram('top', '-n 1 -i 1', $buf)) {
185
            if (preg_match("/\s+(\S+)%\s+TOTAL\s+\(\S+%\s+idle time/", $buf, $ar_buf)) {
194
            if (preg_match("/\s+(\S+)%\s+TOTAL\s+\(\S+%\s+idle time/", $buf, $ar_buf)) {
186
                $this->sys->setLoad($ar_buf[1]);
195
                $this->sys->setLoad($ar_buf[1]);
187
                if (PSI_LOAD_BAR) {
196
                if (PSI_LOAD_BAR) {
188
                    $this->sys->setLoadPercent(round($ar_buf[1]));
197
                    $this->sys->setLoadPercent(round($ar_buf[1]));
189
                }
198
                }
190
            }
199
            }
191
        }
200
        }
192
    }
201
    }
193
 
202
 
194
    /**
203
    /**
195
     * Number of Users
204
     * Number of Users
196
     *
205
     *
197
     * @return void
206
     * @return void
198
     */
207
     */
199
    protected function _users()
208
    protected function _users()
200
    {
209
    {
201
        $this->sys->setUsers(1);
210
        $this->sys->setUsers(1);
202
    }
211
    }
203
 
212
 
204
    /**
213
    /**
205
     * Virtual Host Name
214
     * Virtual Host Name
206
     *
215
     *
207
     * @return void
216
     * @return void
208
     */
217
     */
209
    private function _hostname()
218
    private function _hostname()
210
    {
219
    {
211
        if (PSI_USE_VHOST === true) {
220
        if (PSI_USE_VHOST === true) {
212
            if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
221
            if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
213
        } else {
222
        } else {
214
            if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
223
            if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
215
                $ip = gethostbyname($result);
224
                $ip = gethostbyname($result);
216
                if ($ip != $result) {
225
                if ($ip != $result) {
217
                    $this->sys->setHostname(gethostbyaddr($ip));
226
                    $this->sys->setHostname(gethostbyaddr($ip));
218
                }
227
                }
219
            }
228
            }
220
        }
229
        }
221
    }
230
    }
222
 
231
 
223
    /**
232
    /**
224
     *  Physical memory information and Swap Space information
233
     *  Physical memory information and Swap Space information
225
     *
234
     *
226
     *  @return void
235
     *  @return void
227
     */
236
     */
228
    private function _memory()
237
    private function _memory()
229
    {
238
    {
230
        if (CommonFunctions::executeProgram('sysinfo', '-mem', $bufr, PSI_DEBUG)) {
239
        if (CommonFunctions::executeProgram('sysinfo', '-mem', $bufr, PSI_DEBUG)) {
231
            if (preg_match("/(.*)bytes free\s+\(used\/max\s+(.*)\s+\/\s+(.*)\)\s*\n\s+\(cached\s+(.*)\)/", $bufr, $ar_buf)) {
240
            if (preg_match("/(.*)bytes free\s+\(used\/max\s+(.*)\s+\/\s+(.*)\)\s*\n\s+\(cached\s+(.*)\)/", $bufr, $ar_buf)) {
232
                $this->sys->setMemTotal($ar_buf[3]);
241
                $this->sys->setMemTotal($ar_buf[3]);
233
                $this->sys->setMemFree($ar_buf[1]);
242
                $this->sys->setMemFree($ar_buf[1]);
234
                $this->sys->setMemCache($ar_buf[4]);
243
                $this->sys->setMemCache(min($ar_buf[4], $ar_buf[2]));
235
                $this->sys->setMemUsed($ar_buf[2]);
244
                $this->sys->setMemUsed($ar_buf[2]);
236
            }
245
            }
237
        }
246
        }
238
        if (CommonFunctions::executeProgram('vmstat', '', $bufr, PSI_DEBUG)) {
247
        if (CommonFunctions::executeProgram('vmstat', '', $bufr, PSI_DEBUG)) {
239
            if (preg_match("/max swap space:\s+(.*)\nfree swap space:\s+(.*)\n/", $bufr, $ar_buf)) {
248
            if (preg_match("/max swap space:\s+(.*)\nfree swap space:\s+(.*)\n/", $bufr, $ar_buf)) {
240
                if ($ar_buf[1]>0) {
249
                if ($ar_buf[1]>0) {
241
                    $dev = new DiskDevice();
250
                    $dev = new DiskDevice();
242
                    $dev->setMountPoint("/boot/common/var/swap");
251
                    $dev->setMountPoint("/boot/common/var/swap");
243
                    $dev->setName("SWAP");
252
                    $dev->setName("SWAP");
244
                    $dev->setTotal($ar_buf[1]);
253
                    $dev->setTotal($ar_buf[1]);
245
                    $dev->setFree($ar_buf[2]);
254
                    $dev->setFree($ar_buf[2]);
246
                    $dev->setUSed($ar_buf[1]-$ar_buf[2]);
255
                    $dev->setUSed($ar_buf[1]-$ar_buf[2]);
247
                    $this->sys->setSwapDevices($dev);
256
                    $this->sys->setSwapDevices($dev);
248
                }
257
                }
249
            }
258
            }
250
        }
259
        }
251
    }
260
    }
252
 
261
 
253
    /**
262
    /**
254
     * filesystem information
263
     * filesystem information
255
     *
264
     *
256
     * @return void
265
     * @return void
257
     */
266
     */
258
    private function _filesystems()
267
    private function _filesystems()
259
    {
268
    {
260
        if (CommonFunctions::executeProgram('df', '-b', $df, PSI_DEBUG)) {
269
        if (CommonFunctions::executeProgram('df', '-b', $df, PSI_DEBUG)) {
261
        $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
270
        $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
262
            foreach ($df as $df_line) {
271
            foreach ($df as $df_line) {
263
                $ar_buf = preg_split("/\s+/", $df_line);
272
                $ar_buf = preg_split("/\s+/", $df_line);
264
                if ((substr($df_line, 0, 1) == "/") && (count($ar_buf) == 6)) {
273
                if ((substr($df_line, 0, 1) == "/") && (count($ar_buf) == 6)) {
265
                    $dev = new DiskDevice();
274
                    $dev = new DiskDevice();
266
                    $dev->setMountPoint($ar_buf[0]);
275
                    $dev->setMountPoint($ar_buf[0]);
267
                    $dev->setName($ar_buf[5]);
276
                    $dev->setName($ar_buf[5]);
268
                    $dev->setFsType($ar_buf[1]);
277
                    $dev->setFsType($ar_buf[1]);
269
                    $dev->setOptions($ar_buf[4]);
278
                    $dev->setOptions($ar_buf[4]);
270
                    $dev->setTotal($ar_buf[2] * 1024);
279
                    $dev->setTotal($ar_buf[2] * 1024);
271
                    $dev->setFree($ar_buf[3] * 1024);
280
                    $dev->setFree($ar_buf[3] * 1024);
272
                    $dev->setUsed($dev->getTotal() - $dev->getFree());
281
                    $dev->setUsed($dev->getTotal() - $dev->getFree());
273
                    $this->sys->setDiskDevices($dev);
282
                    $this->sys->setDiskDevices($dev);
274
                }
283
                }
275
            }
284
            }
276
        }
285
        }
277
    }
286
    }
278
 
287
 
279
    /**
288
    /**
280
     * network information
289
     * network information
281
     *
290
     *
282
     * @return void
291
     * @return void
283
     */
292
     */
284
    private function _network()
293
    private function _network()
285
    {
294
    {
286
        if (CommonFunctions::executeProgram('ifconfig', '', $bufr, PSI_DEBUG)) {
295
        if (CommonFunctions::executeProgram('ifconfig', '', $bufr, PSI_DEBUG)) {
287
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
296
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
288
            $was = false;
297
            $was = false;
289
            $errors = 0;
298
            $errors = 0;
290
            $drops = 0;
299
            $drops = 0;
291
            $dev = null;
300
            $dev = null;
292
            foreach ($lines as $line) {
301
            foreach ($lines as $line) {
293
                if (preg_match("/^(\S+)/", $line, $ar_buf)) {
302
                if (preg_match("/^(\S+)/", $line, $ar_buf)) {
294
                    if ($was) {
303
                    if ($was) {
295
                        $dev->setErrors($errors);
304
                        $dev->setErrors($errors);
296
                        $dev->setDrops($drops);
305
                        $dev->setDrops($drops);
297
                        $this->sys->setNetDevices($dev);
306
                        $this->sys->setNetDevices($dev);
298
                    }
307
                    }
299
                    $errors = 0;
308
                    $errors = 0;
300
                    $drops = 0;
309
                    $drops = 0;
301
                    $dev = new NetDevice();
310
                    $dev = new NetDevice();
302
                    $dev->setName($ar_buf[1]);
311
                    $dev->setName($ar_buf[1]);
303
                    $was = true;
312
                    $was = true;
304
                } else {
313
                } else {
305
                    if ($was) {
314
                    if ($was) {
306
                        if (preg_match('/\sReceive:\s\d+\spackets,\s(\d+)\serrors,\s(\d+)\sbytes,\s\d+\smcasts,\s(\d+)\sdropped/i', $line, $ar_buf2)) {
315
                        if (preg_match('/\sReceive:\s\d+\spackets,\s(\d+)\serrors,\s(\d+)\sbytes,\s\d+\smcasts,\s(\d+)\sdropped/i', $line, $ar_buf2)) {
307
                            $errors +=$ar_buf2[1];
316
                            $errors +=$ar_buf2[1];
308
                            $drops +=$ar_buf2[3];
317
                            $drops +=$ar_buf2[3];
309
                            $dev->setRxBytes($ar_buf2[2]);
318
                            $dev->setRxBytes($ar_buf2[2]);
310
                        } elseif (preg_match('/\sTransmit:\s\d+\spackets,\s(\d+)\serrors,\s(\d+)\sbytes,\s\d+\smcasts,\s(\d+)\sdropped/i', $line, $ar_buf2)) {
319
                        } elseif (preg_match('/\sTransmit:\s\d+\spackets,\s(\d+)\serrors,\s(\d+)\sbytes,\s\d+\smcasts,\s(\d+)\sdropped/i', $line, $ar_buf2)) {
311
                            $errors +=$ar_buf2[1];
320
                            $errors +=$ar_buf2[1];
312
                            $drops +=$ar_buf2[3];
321
                            $drops +=$ar_buf2[3];
313
                            $dev->setTxBytes($ar_buf2[2]);
322
                            $dev->setTxBytes($ar_buf2[2]);
314
                        }
323
                        }
315
 
324
 
316
                        if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
325
                        if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
317
                            if (preg_match('/\sEthernet,\s+Address:\s(\S*)/i', $line, $ar_buf2)) {
326
                            if (preg_match('/\sEthernet,\s+Address:\s(\S*)/i', $line, $ar_buf2)) {
318
                                if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $dev->setInfo(preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
327
                                if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $dev->setInfo(preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
319
                            } elseif (preg_match('/^\s+inet\saddr:\s(\S*),/i', $line, $ar_buf2)) {
328
                            } elseif (preg_match('/^\s+inet\saddr:\s(\S*),/i', $line, $ar_buf2)) {
320
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
329
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
321
                            } elseif (preg_match('/^\s+inet6\saddr:\s(\S*),/i', $line, $ar_buf2)
330
                            } elseif (preg_match('/^\s+inet6\saddr:\s(\S*),/i', $line, $ar_buf2)
322
                                     && ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
331
                                     && ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
323
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
332
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
324
                            }
333
                            }
325
                        }
334
                        }
326
                    }
335
                    }
327
                }
336
                }
328
            }
337
            }
329
            if ($was) {
338
            if ($was) {
330
                $dev->setErrors($errors);
339
                $dev->setErrors($errors);
331
                $dev->setDrops($drops);
340
                $dev->setDrops($drops);
332
                $this->sys->setNetDevices($dev);
341
                $this->sys->setNetDevices($dev);
333
            }
342
            }
334
        }
343
        }
335
    }
344
    }
336
 
345
 
337
    /**
346
    /**
338
     * Processes
347
     * Processes
339
     *
348
     *
340
     * @return void
349
     * @return void
341
     */
350
     */
342
    protected function _processes()
351
    protected function _processes()
343
    {
352
    {
344
        if (CommonFunctions::executeProgram('ps', '', $bufr, PSI_DEBUG)) {
353
        if (CommonFunctions::executeProgram('ps', '', $bufr, PSI_DEBUG)) {
345
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
354
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
346
            $processes['*'] = 0;
355
            $processes['*'] = 0;
347
            foreach ($lines as $line) {
356
            foreach ($lines as $line) {
348
                if (preg_match("/^(kernel_team|\/)/", $line, $ar_buf)) {
357
                if (preg_match("/^(kernel_team|\/)/", $line, $ar_buf)) {
349
                    $processes['*']++;
358
                    $processes['*']++;
350
                }
359
                }
351
            }
360
            }
352
            if ($processes['*'] > 0) {
361
            if ($processes['*'] > 0) {
353
                $processes[' '] = $processes['*'];
362
                $processes[' '] = $processes['*'];
354
                $this->sys->setProcesses($processes);
363
                $this->sys->setProcesses($processes);
355
            }
364
            }
356
        }
365
        }
357
    }
366
    }
358
 
367
 
359
    /**
368
    /**
360
     * get the information
369
     * get the information
361
     *
370
     *
362
     * @return Void
371
     * @return Void
363
     */
372
     */
364
    public function build()
373
    public function build()
365
    {
374
    {
366
        $this->error->addError("WARN", "The Haiku version of phpSysInfo is a work in progress, some things currently don't work");
375
        $this->error->addError("WARN", "The Haiku version of phpSysInfo is a work in progress, some things currently don't work");
367
        if (!$this->blockname || $this->blockname==='vitals') {
376
        if (!$this->blockname || $this->blockname==='vitals') {
368
            $this->_distro();
377
            $this->_distro();
369
            $this->_hostname();
378
            $this->_hostname();
370
            $this->_kernel();
379
            $this->_kernel();
371
            $this->_uptime();
380
            $this->_uptime();
372
            $this->_users();
381
            $this->_users();
373
            $this->_loadavg();
382
            $this->_loadavg();
374
            $this->_processes();
383
            $this->_processes();
375
        }
384
        }
376
        if (!$this->blockname || $this->blockname==='hardware') {
385
        if (!$this->blockname || $this->blockname==='hardware') {
377
           $this->_cpuinfo();
386
           $this->_cpuinfo();
378
           $this->_pci();
387
           $this->_pci();
379
           $this->_usb();
388
           $this->_usb();
380
        }
389
        }
381
        if (!$this->blockname || $this->blockname==='network') {
390
        if (!$this->blockname || $this->blockname==='network') {
382
            $this->_network();
391
            $this->_network();
383
        }
392
        }
384
        if (!$this->blockname || $this->blockname==='memory') {
393
        if (!$this->blockname || $this->blockname==='memory') {
385
            $this->_memory();
394
            $this->_memory();
386
        }
395
        }
387
        if (!$this->blockname || $this->blockname==='filesystem') {
396
        if (!$this->blockname || $this->blockname==='filesystem') {
388
            $this->_filesystems();
397
            $this->_filesystems();
389
        }
398
        }
390
    }
399
    }
391
}
400
}
392
 
401