两年小技巧更新 :)
<?php
$snmpcommunity = 'PUBLIC'; $ips = 'test1.com,test2.com'; $system_number = '1';
for ($i = 0; $i <= $system_number; $i++) {
$sysip = explode(",",$ips);
$sysname[0] = snmpget($sysip[$i], $snmpcommunity, "sysName.0");
$sysname[1] = eregi_replace("STRING:","",$sysname[0]);
echo '系统名称: '.$sysname[1].'<br>';
$sysdesc[0] = snmpget($sysip[$i], $snmpcommunity, "sysDescr.0");
$sysdesc[1] = eregi_replace("STRING:","",$sysdesc[0]);
echo '系统描述: '.$sysdesc[1].'<br>';
$sysloc[0] = snmpget($sysip[$i], $snmpcommunity, "sysLocation.0");
$sysloc[1] = eregi_replace("STRING:","",$sysloc[0]);
echo '系统位置: '.$sysloc[1].'<br>';
$tcpcons[0] = snmpget($sysip[$i], $snmpcommunity, "tcpCurrEstab.0");
$tcpcons[1] = eregi_replace("Gauge32:","",$tcpcons[0]);
echo '打开的 TCP/IP 连接: '.$tcpcons[1].'<br>';
$sysuptime[0] = snmpget($sysip[$i], $snmpcommunity, "system.sysUpTime.0");
$sysuptime[1] = eregi_replace("Timeticks:","",$sysuptime[0]);
echo '系统正常运行时间: Timeticks -'.$sysuptime[1].'<br>';
if(eregi('Windows',$sysdesc[1])){
$mem[0] = snmpget($sysip[$i], $snmpcommunity, "HOST-RESOURCES-MIB::hrMemorySize.0");
$mem[1] = eregi_replace("INTEGER:","",$mem[0]);
$mem[2] = eregi_replace("KBytes","",$mem[1]);
echo '已安装内存: '.$mem[2].' 千字节<br>';
}
echo '<br><br>';
}?>