Сбор статистики с карт emr 2.1
<?php
$device = "10.0.0.1";
$community = "public";
getstat($device, $community);
function getstat($host, $community) {
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
$cards = snmp2_walk($host, $community, "1.3.6.1.4.1.32285.1.11.3.1.1.1");
foreach ($cards as $card => $val) {
$card++;
switch ($val) {
case 2004:getDVScardStat2004($host, $community, $card);
break;
case 2009:getDVScardStat2009($host, $community, $card);
break;
case 4002:getGECardStat($host, $community, $card);
break;
}
}
}
function getDVScardStat2004($host, $community, $card) {
$root_oid = "1.3.6.1.4.1.32285.1.11.3." . ($card + 1) . ".2";
$sys_bitrate = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.7.0"));
$valid_bitrate = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.8.0"));
$ber = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.19.0"));
$snr = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.11.0"));
$signal_level = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.10.0"));
echo "card: $card\t port: 1\t bitrate: $valid_bitrate / $sys_bitrate\t ber: $ber\t snr: $snr\t signal_level: $signal_level\n";
}
function getDVScardStat2009($host, $community, $card) {
for ($port = 1; $port <= 4; $port++) {
$root_oid = "1.3.6.1.4.1.32285.1.11.3." . ($card + 1) . "." . ($port + 1);
$sys_bitrate = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.7.0"));
$valid_bitrate = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.8.0"));
$ber = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.19.0"));
$snr = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.11.0"));
$signal_level = prettyBitrate(@snmp2_get($host, $community, "$root_oid.36.1.10.0"));
echo "card: $card\t port: $port\t bitrate: $valid_bitrate / $sys_bitrate\t ber: $ber\t snr: $snr\t signal_level: $signal_level\n";
}
}
function getGECardStat($host, $community, $card) {
for ($port = 1; $port <= 16; $port++) {
$root_oid = "1.3.6.1.4.1.32285.1.11.3." . ($card + 1) . "." . ($port + 1);
$ip = @snmp2_get($host, $community, "$root_oid.10.1.1.0");
$ip_port = @snmp2_get($host, $community, "$root_oid.10.1.2.0");
$sys_bitrate = @snmp2_get($host, $community, "$root_oid.8.1.1.0");
$valid_bitrate = prettyBitrate(@snmp2_get($host, $community, "$root_oid.8.1.2.0"));
if (strlen($ip) > 0)
echo "card: $card\t port: $port\t bitrate: $valid_bitrate / $sys_bitrate\t ip: $ip:$ip_port\n";
}
}
function prettyBitrate($bitrate) {
if (strpos($bitrate, "Mbps") > 0) {
return (int) $bitrate * 1024 * 1024;
}
if (strpos($bitrate, "Kbps") > 0) {
return (int) $bitrate * 1024;
}
if (strpos($bitrate, "bps") > 0) {
return (int) $bitrate;
}
return (float)$bitrate;
}
?>