PHP SNMP 获取WEBLOGIC版本号代码段

if(snmpwalk($this->host_address.':'.$this->port, $this->community, '1.3.6.1.4.1.140.625.360.1.65') != FALSE)
            {
                $this->data_fetched = 'yes';
                $data = snmpwalk($this->host_address.':'.$this->port, $this->community, '1.3.6.1.4.1.140.625.360.1.65');
                //print_r($data);
                if(strlen($data[0]) == 0)
                {
                    $data[0] = '<span id="no_data_received">No data received</span>';
                }
                else
                {
                    if($data[0] == 'STRING: ')
                    {
                        $data[0] = '<span id="no_data_received">No data received</span>';
                    }
                    else
                    {
                        if(substr_count($data[0], 'STRING: ') > 0)
                        {
                            $data[0] = substr($data[0], strlen('STRING: '), strlen($data[0]));
                        }
                        else
                        {
                            $data[0] = $data[0];
                        }
                        $data_lower = strtolower($data[0]);
                        //print_r($data_lower);
                        if(substr_count($data_lower, 'weblogic') > 0)
                        {
                            $this->operating_system = 'weblogic';
                        }
            if(substr_count($data_lower, ' 8.1 ') > 0)
                        {
                            $this->version = '8.1';
                        }
            if(substr_count($data_lower, ' 10.3.6.0 ') > 0)
                        {
                            $this->version = '10.3.6.0';
                        }
            if(substr_count($data_lower, ' 10.3.3.0 ') > 0)
                        {
                            $this->version = '10.3.3.0';
                        }
            if(substr_count($data_lower, ' 10.3 ') > 0)
                        {
                            $this->version = '10.3';
                        }
            //print $this->version;
                    }
                }
            }

猜你喜欢

转载自blog.csdn.net/allway2/article/details/94611406