$host predavej jako IP: napr 10.10.10.10
Muj skript jako napoveda :) chodi na nekterych 3 verzich, snad ti to nejak pomuze. Nepsal sem to vsechno ja, neco je okopirovany, ale dohromady to fakci. :)
<?
$community = "public";
function fsnmpget($host, $community, $mib) {
$str = snmpget($host, $community, $mib);
$str = str_replace("STRING: ", "", $str);
$str = str_replace("GAUGE32: ", "", $str);
$str = str_replace("COUNTER32: ", "", $str);
$str = str_replace("HEX: ", "", $str);
$str = str_replace("INTEGER: ", "", $str);
$str = str_replace("\"", "", $str);
$str = str_replace("Timeticks: ", "", $str);
return $str;
}
function fsnmpwalk($host, $community, $mib) {
$str = snmpwalk($host, $community, $mib);
$str = str_replace("STRING: ", "", $str);
$str = str_replace("COUNTER32: ", "", $str);
$str = str_replace("GAUGE32: ", "", $str);
$str = str_replace("INTEGER: ", "", $str);
$str = str_replace("HEX: ", "", $str);
$str = str_replace("\"", "", $str);
return $str;
}
function fsnmpwalkoid($host, $community, $mib) {
$str = snmpwalkoid($host, $community, $mib);
$str = str_replace("STRING: ", "", $str);
$str = str_replace("COUNTER32: ", "", $str);
$str = str_replace("GAUGE32: ", "", $str);
$str = str_replace("INTEGER: ", "", $str);
$str = str_replace("HEX: ", "", $str);
$str = str_replace("\"", "", $str);
return $str;
}
$host = $GLOBALS["host"];
$community = $GLOBALS["community"];
$time = date("U");
#
# Get Description, Location and Name from AP
$systemDescription = fsnmpget($host, $community, "system.sysDescr.0");
$systemLocation = fsnmpget($host, $community, "system.sysLocation.0");
$systemName = fsnmpget($host, $community, "system.sysName.0");
$strength = fsnmpwalkoid($host, $community, ".1.3.6.1.4.1.14988.1.1.1.2.1.3");
$interfaces = fsnmpwalkoid($host, $community, ".1.3.6.1.2.1.2.2.1.2");
$procload=fsnmpget($host, $community, ".1.3.6.1.2.1.25.3.3.1.2.1");
$uptime=fsnmpget($host, $community, ".1.3.6.1.2.1.1.3.0");
$teplota=fsnmpget($host, $community, ".1.3.6.1.4.1.14988.1.1.3.10.0");
$teplota=fsnmpget($host, $community, ".1.3.6.1.4.1.14988.1.1.3.10.0");
$napeti=fsnmpget($host, $community, ".1.3.6.1.4.1.14988.1.1.3.8.0");
echo 'Připojená zařízení:';
echo '<br>';
echo '<br>';
array_walk($strength, 'signal_strength');
function dec2hex($value) {
return str_replace(" ", "0", sprintf("%2X", $value));
}
function format_mac($key, $num = 3) {
$mac_parse = str_replace("SNMPv2-SMI::enterprises.14988.1.1.1.2.1.$num.", "", $key);
$mac_decimal = substr($mac_parse, 0, strlen($mac_parse)-2);
list($first, $second, $third, $fourth, $fifth, $sixth) = split("[:.-]", $mac_decimal);
return dec2hex($first).":".dec2hex($second).":".dec2hex($third).":".dec2hex($fourth).":".dec2hex($fifth).":".dec2hex($sixth);
}
function get_interface($key, $num = 3) {
$mac_parse = str_replace("SNMPv2-SMI::enterprises.14988.1.1.1.2.1.$num.", "", $key);
$mac_decimal = substr($mac_parse, 0, strlen($mac_parse));
list($first, $second, $third, $fourth, $fifth, $sixth, $int) = split("[:.-]", $mac_decimal);
return "$int";
}
function flipmac($mac) {
return hexdec(substr($mac, 0, 2)).".".hexdec(substr($mac, 2, 2)).".".hexdec(substr($mac, 4, 2)).".".hexdec(substr($mac, 6, 2)).".".hexdec(substr($mac, 8, 2)).".".hexdec(substr($mac, 10, 2));
}
echo '<br>';
echo '<br>';
echo 'Vytížení procesoru: '.$procload.'<br>';
echo 'Mikrotik: '.$systemName.'<br>';
echo 'Uptime: '.$uptime.'<br>';
echo 'Teplota: '.$teplota.'<br>';
echo 'Napetí: '.$napeti.'<br>';
echo '<br>';
function signal_strength($value, $key) {
global $host, $community, $time, $interfaces;
$mac = format_mac($key);
$interfacenum = get_interface($key);
$interfacename = $interfaces["IF-MIB::ifDescr.".$interfacenum];
echo $interfaces[0];
$signal = $value." dBm";
$macfind = str_replace(":", "", $mac);
?>
<?
echo ''.$mac.' | '.$signal.' | '.$interfacename.'<br>';
?>
<?
}
?>