Subversion Repositories ALCASAR

Rev

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

Rev 2770 Rev 2976
Line 130... Line 130...
130
     *
130
     *
131
     * @return void
131
     * @return void
132
     */
132
     */
133
    protected function _ip()
133
    protected function _ip()
134
    {
134
    {
135
        if (PSI_USE_VHOST === true) {
135
        if ((PSI_USE_VHOST === true) && !defined('PSI_EMU_HOSTNAME')) {
136
           if ((CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result)) //is server address defined
136
           if ((CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result)) //is server address defined
137
               && !strstr($result, '.') && strstr($result, ':')) { //is IPv6, quick version of preg_match('/\(([[0-9A-Fa-f\:]+)\)/', $result)
137
              && !strstr($result, '.') && strstr($result, ':')) { //is IPv6, quick version of preg_match('/\(([[0-9A-Fa-f\:]+)\)/', $result)
138
                $dnsrec = dns_get_record($this->sys->getHostname(), DNS_AAAA);
138
                $dnsrec = dns_get_record($this->sys->getHostname(), DNS_AAAA);
139
                if (isset($dnsrec[0]['ipv6'])) { //is DNS IPv6 record
139
                if (isset($dnsrec[0]['ipv6'])) { //is DNS IPv6 record
140
                    $this->sys->setIp($dnsrec[0]['ipv6']); //from DNS (avoid IPv6 NAT translation)
140
                    $this->sys->setIp($dnsrec[0]['ipv6']); //from DNS (avoid IPv6 NAT translation)
141
                } else {
141
                } else {
142
                    $this->sys->setIp(preg_replace('/^::ffff:/i', '', $result)); //from SERVER_ADDR or LOCAL_ADDR
142
                    $this->sys->setIp(preg_replace('/^::ffff:/i', '', $result)); //from SERVER_ADDR or LOCAL_ADDR
143
                }
143
                }
144
            } else {
144
            } else {
145
                $this->sys->setIp(gethostbyname($this->sys->getHostname())); //IPv4 only
145
                $this->sys->setIp(gethostbyname($this->sys->getHostname())); //IPv4 only
146
            }
146
            }
-
 
147
        } elseif (((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) && (CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result))) {
-
 
148
            $this->sys->setIp(preg_replace('/^::ffff:/i', '', $result));
147
        } else {
149
        } else {
-
 
150
            //$this->sys->setIp(gethostbyname($this->sys->getHostname()));
-
 
151
            $hn = $this->sys->getHostname();
-
 
152
            $ghbn = gethostbyname($hn);
148
            if (CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result)) {
153
            if (defined('PSI_EMU_HOSTNAME') && ($hn === $ghbn)) {
149
                $this->sys->setIp(preg_replace('/^::ffff:/i', '', $result));
154
                $this->sys->setIp(PSI_EMU_HOSTNAME);
150
            } else {
155
            } else {
-
 
156
                $this->sys->setIp($ghbn);
-
 
157
            }
-
 
158
        }
-
 
159
    }
-
 
160
 
-
 
161
    /**
-
 
162
     * MEM information from dmidecode
-
 
163
     *
-
 
164
     * @return void
-
 
165
     */
-
 
166
    protected function _dmimeminfo()
-
 
167
    {
-
 
168
        $banks = array();
-
 
169
        $buffer = '';
-
 
170
        if (defined('PSI_DMIDECODE_ACCESS') && (strtolower(PSI_DMIDECODE_ACCESS)=="data")) {
-
 
171
            CommonFunctions::rfts(PSI_APP_ROOT.'/data/dmidecode.txt', $buffer);
-
 
172
        } elseif (CommonFunctions::_findProgram('dmidecode')) {
-
 
173
            CommonFunctions::executeProgram('dmidecode', '-t 17', $buffer, PSI_DEBUG);
-
 
174
        }
-
 
175
        if (!empty($buffer)) {
-
 
176
            $banks = preg_split('/^(?=Handle\s)/m', $buffer, -1, PREG_SPLIT_NO_EMPTY);
-
 
177
            foreach ($banks as $bank) if (preg_match('/^Handle\s/', $bank)) {
-
 
178
                $lines = preg_split("/\n/", $bank, -1, PREG_SPLIT_NO_EMPTY);
-
 
179
                $mem = array();
-
 
180
                foreach ($lines as $line) if (preg_match('/^\s+([^:]+):(.+)/' ,$line, $params)) {
-
 
181
                    if (preg_match('/^0x([A-F\d]+)/', $params2 = trim($params[2]), $buff)) {
-
 
182
                        $mem[trim($params[1])] = trim($buff[1]);
-
 
183
                    } elseif ($params2 != '') {
-
 
184
                        $mem[trim($params[1])] = $params2;
-
 
185
                    }
-
 
186
                }
-
 
187
                if (isset($mem['Size']) && preg_match('/^(\d+)\s(M|G)B$/', $mem['Size'], $size) && ($size[1] > 0)) {
-
 
188
                    $dev = new HWDevice();
-
 
189
                    $name = '';
-
 
190
                    if (isset($mem['Part Number']) && !preg_match("/^PartNum\d+$/", $part = $mem['Part Number']) && ($part != 'None') && ($part != 'N/A') && ($part != 'Not Specified') && ($part != 'NOT AVAILABLE')) {
-
 
191
                        $name = $part;
-
 
192
                    }
-
 
193
                    if (isset($mem['Locator']) && (($dloc = $mem['Locator']) != 'None') && ($dloc != 'N/A') && ($dloc != 'Not Specified')) {
-
 
194
                        if ($name != '') {
-
 
195
                            $name .= ' - '.$dloc;
-
 
196
                        } else {
-
 
197
                            $name = $dloc;
-
 
198
                        }
-
 
199
                    }
-
 
200
                    if (isset($mem['Bank Locator']) && (($bank = $mem['Bank Locator']) != 'None') && ($bank != 'N/A') && ($bank != 'Not Specified')) {
-
 
201
                        if ($name != '') {
-
 
202
                            $name .= ' in '.$bank;
-
 
203
                        } else {
-
 
204
                            $name = 'Physical Memory in '.$bank;
-
 
205
                        }
-
 
206
                    }
-
 
207
                    if ($name != '') {
-
 
208
                        $dev->setName(trim($name));
-
 
209
                    } else {
-
 
210
                        $dev->setName('Physical Memory');
-
 
211
                    }
-
 
212
                    if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
151
                $this->sys->setIp(gethostbyname($this->sys->getHostname()));
213
                        if (isset($mem['Manufacturer']) && !preg_match("/^([A-F\d]{4}|[A-F\d]{12}|[A-F\d]{16})$/", $manufacturer = $mem['Manufacturer']) && !preg_match("/^Manufacturer\d+$/", $manufacturer) && !preg_match("/^Mfg \d+$/", $manufacturer) && !preg_match("/^JEDEC ID:/", $manufacturer) && ($manufacturer != 'None') && ($manufacturer != 'N/A') && ($manufacturer != 'Not Specified') && ($manufacturer != 'UNKNOWN')) {
-
 
214
                            $dev->setManufacturer($manufacturer);
-
 
215
                        }
-
 
216
                        if ($size[2] == 'G') {
-
 
217
                            $dev->setCapacity($size[1]*1024*1024*1024);
-
 
218
                        } else {
-
 
219
                            $dev->setCapacity($size[1]*1024*1024);
-
 
220
                        }
-
 
221
                        $memtype = '';
-
 
222
                        if (isset($mem['Type']) && (($type = $mem['Type']) != 'None') && ($type != 'N/A') && ($type != 'Not Specified') && ($type != 'Other') && ($type != 'Unknown') && ($type != '<OUT OF SPEC>')) {
-
 
223
                            if (isset($mem['Speed']) && preg_match('/^(\d+)\s(MHz|MT\/s)/', $mem['Speed'], $speed) && ($speed[1] > 0) && (preg_match('/^(DDR\d*)(.*)/', $type, $dr) || preg_match('/^(SDR)AM(.*)/', $type, $dr))) {
-
 
224
                               if (isset($mem['Minimum Voltage']) && isset($mem['Total Width']) &&
-
 
225
                                  preg_match('/^([\d\.]+)\sV$/', $mem['Minimum Voltage'], $minv) && preg_match('/^([\d\.]+)\sV$/', $mem['Maximum Voltage'], $maxv) &&
-
 
226
                                  ($minv[1]  > 0) && ($maxv[1] >0) && ($minv[1] < $maxv[1])) {
-
 
227
                                    $lv = 'L';
-
 
228
                                } else {
-
 
229
                                    $lv = '';
-
 
230
                                }
-
 
231
                                if (isset($dr[2])) {
-
 
232
                                    $memtype = $dr[1].$lv.'-'.$speed[1].' '.$dr[2];
-
 
233
                                } else {
-
 
234
                                    $memtype = $dr[1].$lv.'-'.$speed[1];
-
 
235
                                }
-
 
236
                            } else {
-
 
237
                                $memtype = $type;
-
 
238
                            }
-
 
239
                        }
-
 
240
                        if (isset($mem['Form Factor']) && (($form = $mem['Form Factor']) != 'None') && ($form != 'N/A') && ($form != 'Not Specified') && ($form != 'Other') && ($form != 'Unknown') && !preg_match('/ '.$form.'$/', $memtype)) {
-
 
241
                            $memtype .= ' '.$form;
-
 
242
                        }
-
 
243
                        if (isset($mem['Data Width']) && isset($mem['Total Width']) &&
-
 
244
                           preg_match('/^(\d+)\sbits$/', $mem['Data Width'], $dataw) && preg_match('/^(\d+)\sbits$/', $mem['Total Width'], $totalw) &&
-
 
245
                           ($dataw[1]  > 0) && ($totalw[1] >0) && ($dataw[1] < $totalw[1])) {
-
 
246
                            $memtype .= ' ECC';
-
 
247
                        }
-
 
248
                        if (isset($mem['Type Detail']) && preg_match('/Registered/', $mem['Type Detail'])) {
-
 
249
                            $memtype .= ' REG';
-
 
250
                        }
-
 
251
                        if (($memtype = trim($memtype)) != '') {
-
 
252
                            $dev->setProduct($memtype);
-
 
253
                        }
-
 
254
                        if (isset($mem['Configured Clock Speed']) && preg_match('/^(\d+)\s(MHz|MT\/s)$/', $mem['Configured Clock Speed'], $clock) && ($clock[1] > 0)) {
-
 
255
                            $dev->setSpeed($clock[1]);
-
 
256
                        }
-
 
257
                        if (isset($mem['Configured Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Configured Voltage'], $voltage) && ($voltage[1] > 0)) {
-
 
258
                            $dev->setVoltage($voltage[1]);
-
 
259
                        }
-
 
260
                        if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL &&
-
 
261
                           isset($mem['Serial Number']) && !preg_match("/^SerNum\d+$/", $serial = $mem['Serial Number']) && ($serial != 'None') && ($serial != 'Not Specified')) {
-
 
262
                            $dev->setSerial($serial);
-
 
263
                        }
-
 
264
                    }
-
 
265
                    $this->sys->setMemDevices($dev);
-
 
266
                }
152
            }
267
            }
153
        }
268
        }
154
    }
269
    }
155
 
270
 
156
    /**
271
    /**
Line 164... Line 279...
164
    {
279
    {
165
        $this->build();
280
        $this->build();
166
        if (!$this->blockname || $this->blockname==='vitals') {
281
        if (!$this->blockname || $this->blockname==='vitals') {
167
            $this->_ip();
282
            $this->_ip();
168
        }
283
        }
-
 
284
        if ((!$this->blockname || $this->blockname==='hardware') && (PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
-
 
285
            $this->_dmimeminfo();
-
 
286
        }
169
 
287
 
170
        return $this->sys;
288
        return $this->sys;
171
    }
289
    }
172
}
290
}