Subversion Repositories ALCASAR

Rev

Rev 3037 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3037 Rev 3100
Line 90... Line 90...
90
        if ($complete) {
90
        if ($complete) {
91
            $this->_complete_request = true;
91
            $this->_complete_request = true;
92
        } else {
92
        } else {
93
            $this->_complete_request = false;
93
            $this->_complete_request = false;
94
        }
94
        }
-
 
95
        if (defined('PSI_EMU_PORT')) {
-
 
96
            $os = 'SSH';
95
        if (defined('PSI_EMU_HOSTNAME')) {
97
        } elseif (defined('PSI_EMU_HOSTNAME')) {
96
            $os = 'WINNT';
98
            $os = 'WINNT';
97
        } else {
99
        } else {
98
            $os = PSI_OS;
100
            $os = PSI_OS;
99
        }
101
        }
100
        $this->_sysinfo = new $os($blockname);
102
        $this->_sysinfo = new $os($blockname);
Line 159... Line 161...
159
                    }
161
                    }
160
                }
162
                }
161
            }
163
            }
162
        }
164
        }
163
 
165
 
-
 
166
        if (($os = $this->_sys->getOS()) == 'Android') {
-
 
167
            $vitals->addAttribute('OS', 'Linux');
164
        if (defined('PSI_EMU_HOSTNAME')) {
168
        } elseif ($os == 'GNU') {
165
            $vitals->addAttribute('OS', 'WINNT');
169
            $vitals->addAttribute('OS', 'Hurd');
166
        } else {
170
        } else {
167
            $vitals->addAttribute('OS', (PSI_OS=='Android')?'Linux':PSI_OS);
171
            $vitals->addAttribute('OS', $os);
168
        }
172
        }
169
    }
173
    }
170
 
174
 
171
    /**
175
    /**
172
     * generate the network information
176
     * generate the network information
Line 201... Line 205...
201
                $hide =in_array(trim($dev->getName()), $hideDevices);
205
                $hide =in_array(trim($dev->getName()), $hideDevices);
202
            }
206
            }
203
            if (!$hide) {
207
            if (!$hide) {
204
                $device = $network->addChild('NetDevice');
208
                $device = $network->addChild('NetDevice');
205
                $device->addAttribute('Name', $dev->getName());
209
                $device->addAttribute('Name', $dev->getName());
-
 
210
                $rxbytes = $dev->getRxBytes();
-
 
211
                $txbytes = $dev->getTxBytes();
206
                $device->addAttribute('RxBytes', $dev->getRxBytes());
212
                $device->addAttribute('RxBytes', $rxbytes);
207
                $device->addAttribute('TxBytes', $dev->getTxBytes());
213
                $device->addAttribute('TxBytes', $txbytes);
-
 
214
                if (defined('PSI_SHOW_NETWORK_ACTIVE_SPEED') && PSI_SHOW_NETWORK_ACTIVE_SPEED) {
-
 
215
                    if (($rxbytes == 0) && ($txbytes == 0)) {
-
 
216
                        $rxrate = $dev->getRxRate();
-
 
217
                        $txrate = $dev->getTxRate();
-
 
218
                        if (($rxrate !== null) || ($txrate !== null)) {
-
 
219
                            if ($rxrate !== null) {
-
 
220
                                $device->addAttribute('RxRate', $rxrate);
-
 
221
                            } else {
-
 
222
                                $device->addAttribute('RxRate', 0);
-
 
223
                            }
-
 
224
                            if ($txrate !== null) {
-
 
225
                                $device->addAttribute('TxRate', $txrate);
-
 
226
                            } else {
-
 
227
                                $device->addAttribute('TxRate', 0);
-
 
228
                            }
-
 
229
                        }
-
 
230
                    }
-
 
231
                }
208
                $device->addAttribute('Err', $dev->getErrors());
232
                $device->addAttribute('Err', $dev->getErrors());
209
                $device->addAttribute('Drops', $dev->getDrops());
233
                $device->addAttribute('Drops', $dev->getDrops());
210
                if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS && $dev->getInfo())
234
                if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS && $dev->getInfo())
211
                    $device->addAttribute('Info', $dev->getInfo());
235
                    $device->addAttribute('Info', $dev->getInfo());
212
            }
236
            }
Line 220... Line 244...
220
     */
244
     */
221
    private function _buildHardware()
245
    private function _buildHardware()
222
    {
246
    {
223
        $hardware = $this->_xml->addChild('Hardware');
247
        $hardware = $this->_xml->addChild('Hardware');
224
        if (($machine = $this->_sys->getMachine()) != "") {
248
        if (($machine = $this->_sys->getMachine()) != "") {
-
 
249
            $machine = trim(preg_replace("/\s+/", " ", preg_replace("/^\s*[\/,]*/", "", preg_replace("/\/\s+,/", "/,", $machine)))); // remove leading slash or comma and unnecessary spaces
225
            if ((preg_match('/^(.* (.*\/.*\/.*))\/(.*\/.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
250
            if (preg_match('/, BIOS .*$/', $machine, $mbuf, PREG_OFFSET_CAPTURE)) {
-
 
251
                $comapos = $mbuf[0][1];
-
 
252
                $endstr = $mbuf[0][0];
-
 
253
                $offset = 0;
-
 
254
                while (($offset < $comapos)
226
               || preg_match('/^(.* (.*\/.*))\/(.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
255
                     && (($slashpos = strpos($machine, "/", $offset)) !== false)
-
 
256
                     && ($slashpos < $comapos)) {
227
               || preg_match('/^(.* (.*))\/(.*)(, BIOS .*)$/', $machine, $mbuf)
257
                    $len1 = $comapos - $slashpos - 1;
228
               || preg_match('/^((.*\/.*\/.*))\/(.*\/.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
258
                    $str1 = substr($machine, $slashpos + 1, $len1);
229
               || preg_match('/^((.*\/.*))\/(.*\/.*)(, BIOS .*)$/', $machine, $mbuf)
259
                    $begstr  = substr($machine, 0, $slashpos);
-
 
260
                    if ($len1 > 0) { // no empty
230
               || preg_match('/^((.*))\/(.*)(, BIOS .*)$/', $machine, $mbuf))
261
                        $str2 = substr($begstr, -$len1 - 1);
-
 
262
                    } else {
-
 
263
                        $str2 = " ";
-
 
264
                    }
231
               && ($mbuf[2] === $mbuf[3])) { // find duplicates
265
                    if ((" ".$str1 === $str2) || ($str1 === $begstr)) { // duplicates
232
                $machine = $mbuf[1].$mbuf[4]; // minimized machine name
266
                        $machine = $begstr.$endstr;
-
 
267
                        break;
-
 
268
                    }
-
 
269
                    $offset = $slashpos + 1;
-
 
270
                }
233
            }
271
            }
234
            $machine = trim(preg_replace("/^\s*\/?,?/", "", $machine)); // remove leading slash and comma
-
 
235
 
272
 
236
            if ($machine != "") {
273
            if ($machine != "") {
237
                $hardware->addAttribute('Name', $machine);
274
                $hardware->addAttribute('Name', $machine);
238
            }
275
            }
239
        }
276
        }