array_chunk() 函数
---------------------
hrSWRunTable 1.3.6.1.2.1.25.4.2
hrSWRunEntry 1.3.6.1.2.1.25.4.2.1
hrSWRunIndex 1.3.6.1.2.1.25.4.2.1.1
hrSWRunName 1.3.6.1.2.1.25.4.2.1.2
hrSWRunID 1.3.6.1.2.1.25.4.2.1.3
hrSWRunPath 1.3.6.1.2.1.25.4.2.1.4
hrSWRunParameters 1.3.6.1.2.1.25.4.2.1.5
hrSWRunType 1.3.6.1.2.1.25.4.2.1.6
hrSWRunStatus 1.3.6.1.2.1.25.4.2.1.7
---------------------
public function process(){
$process = array();
$result = snmpwalk($this->ip, $this->community, '1.3.6.1.2.1.25.4.2.1');
$process = array_chunk($result,count($result)/7);
return $process;
}
---------------------
tcpConnTable 1.3.6.1.2.1.6.13
tcpConnEntry 1.3.6.1.2.1.6.13.1
tcpConnState 1.3.6.1.2.1.6.13.1.1
tcpConnLocalAddress 1.3.6.1.2.1.6.13.1.2
tcpConnLocalPort 1.3.6.1.2.1.6.13.1.3
tcpConnRemAddress 1.3.6.1.2.1.6.13.1.4
tcpConnRemPort 1.3.6.1.2.1.6.13.1.5
---------------------
public function tcp(){
$tcp = array();
$result = snmpwalk($this->ip, $this->community, '1.3.6.1.2.1.6.13.1');
$tcp = array_chunk($result,count($result)/5);
return $tcp;
}
运行结果示例:
array(5) {
[0]=>
array(11) {
[0]=>
string(18) "INTEGER: listen(2)"
[1]=>
string(18) "INTEGER: listen(2)"
[2]=>
string(18) "INTEGER: listen(2)"
[3]=>
string(18) "INTEGER: listen(2)"
[4]=>
string(18) "INTEGER: listen(2)"
[5]=>
string(18) "INTEGER: listen(2)"
[6]=>
string(18) "INTEGER: listen(2)"
[7]=>
string(23) "INTEGER: established(5)"
[8]=>
string(23) "INTEGER: established(5)"
[9]=>
string(23) "INTEGER: synReceived(4)"
[10]=>
string(18) "INTEGER: listen(2)"
}
[1]=>
array(11) {
[0]=>
string(18) "IpAddress: 0.0.0.0"
[1]=>
string(18) "IpAddress: 0.0.0.0"
[2]=>
string(18) "IpAddress: 0.0.0.0"
[3]=>
string(18) "IpAddress: 0.0.0.0"
[4]=>
string(20) "IpAddress: 127.0.0.1"
[5]=>
string(20) "IpAddress: 127.0.0.1"
[6]=>
string(20) "IpAddress: 127.0.0.1"
[7]=>
string(26) "IpAddress: 192.168.111.139"
[8]=>
string(26) "IpAddress: 192.168.111.139"
[9]=>
string(26) "IpAddress: 192.168.111.139"
[10]=>
string(24) "IpAddress: 192.168.122.1"
}
[2]=>
array(11) {
[0]=>
string(11) "INTEGER: 22"
[1]=>
string(12) "INTEGER: 111"
[2]=>
string(13) "INTEGER: 3306"
[3]=>
string(13) "INTEGER: 6000"
[4]=>
string(11) "INTEGER: 25"
[5]=>
string(12) "INTEGER: 199"
[6]=>
string(12) "INTEGER: 631"
[7]=>
string(11) "INTEGER: 22"
[8]=>
string(11) "INTEGER: 22"
[9]=>
string(11) "INTEGER: 80"
[10]=>
string(11) "INTEGER: 53"
}
[3]=>
array(11) {
[0]=>
string(18) "IpAddress: 0.0.0.0"
[1]=>
string(18) "IpAddress: 0.0.0.0"
[2]=>
string(18) "IpAddress: 0.0.0.0"
[3]=>
string(18) "IpAddress: 0.0.0.0"
[4]=>
string(18) "IpAddress: 0.0.0.0"
[5]=>
string(18) "IpAddress: 0.0.0.0"
[6]=>
string(18) "IpAddress: 0.0.0.0"
[7]=>
string(24) "IpAddress: 192.168.111.1"
[8]=>
string(24) "IpAddress: 192.168.111.1"
[9]=>
string(24) "IpAddress: 192.168.111.1"
[10]=>
string(18) "IpAddress: 0.0.0.0"
}
[4]=>
array(11) {
[0]=>
string(10) "INTEGER: 0"
[1]=>
string(10) "INTEGER: 0"
[2]=>
string(10) "INTEGER: 0"
[3]=>
string(10) "INTEGER: 0"
[4]=>
string(10) "INTEGER: 0"
[5]=>
string(10) "INTEGER: 0"
[6]=>
string(10) "INTEGER: 0"
[7]=>
string(14) "INTEGER: 49711"
[8]=>
string(14) "INTEGER: 50128"
[9]=>
string(14) "INTEGER: 50248"
[10]=>
string(10) "INTEGER: 0"
}
}