Exemplo n.º 1
0
<?php

print_r(snmpwalk_cache_oid($device, "system", array()));
print_r(snmp_cache_oid("system", $device, array()));
Exemplo n.º 2
0
<?php

$storage_array = snmp_cache_oid("hrStorageEntry", $device, array(), "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
if (is_array($storage_array)) {
    echo "hrStorage : ";
    foreach ($storage_array[$device[device_id]] as $index => $storage) {
        $fstype = $storage['hrStorageType'];
        $descr = $storage['hrStorageDescr'];
        $size = $storage['hrStorageSize'] * $storage['hrStorageAllocationUnits'];
        $used = $storage['hrStorageUsed'] * $storage['hrStorageAllocationUnits'];
        $units = $storage['hrStorageAllocationUnits'];
        $deny = 1;
        if ($fstype == "hrStorageVirtualMemory" || $fstype == "hrStorageRam") {
            $deny = 0;
        }
        if (strstr($descr, "MALLOC") || strstr($descr, "UMA")) {
            $deny = 1;
        }
        ## Ignore FreeBSD INSANITY
        if (!$deny && is_numeric($index)) {
            discover_mempool($valid_mempool, $device, $index, "hrstorage", $descr, $units, NULL, NULL);
        }
        unset($deny, $fstype, $descr, $size, $used, $units, $storage_rrd, $old_storage_rrd, $storage_array);
    }
}
<?php

if ($device['os_group'] == "unix" || $device['os'] == "windows") {
    echo "hrDevice ";
    $hrDevice_oids = array('hrDevice', 'hrProcessorLoad');
    if ($debug) {
        print_r($processors_array);
    }
    foreach ($hrDevice_oids as $oid) {
        $hrDevice_array = snmp_cache_oid($oid, $device, $hrDevice_array, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
    }
    foreach ($hrDevice_array[$device['device_id']] as $index => $entry) {
        if ($entry['hrDeviceType'] == "hrDeviceProcessor") {
            $hrDeviceIndex = $entry['hrDeviceIndex'];
            $usage_oid = ".1.3.6.1.2.1.25.3.3.1.2." . $index;
            $usage = $entry['hrProcessorLoad'];
            $descr = $entry['hrDeviceDescr'];
            $descr_array = explode(":", $entry['hrDeviceDescr']);
            if ($descr_array['1']) {
                $descr = $descr_array['1'];
            } else {
                $descr = $descr_array['0'];
            }
            $descr = str_replace("CPU ", "", $descr);
            $descr = str_replace("(TM)", "", $descr);
            $descr = str_replace("(R)", "", $descr);
            $old_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("hrProcessor-" . $index . ".rrd");
            $new_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("processor-hr-" . $index . ".rrd");
            if ($debug) {
                echo "{$old_rrd} {$new_rrd}";
            }
Exemplo n.º 4
0
<?php

echo "OLD-CISCO-MEMORY-POOL: ";
$cmp_oids = array('ciscoMemoryPoolName', 'ciscoMemoryPoolAlternate', 'ciscoMemoryPoolValid', 'ciscoMemoryPoolUsed', 'ciscoMemoryPoolFree', 'ciscoMemoryPoolLargestFree');
foreach ($cmp_oids as $oid) {
    echo "{$oid} ";
    $cmp_array = snmp_cache_oid($oid, $device, $cmp_array, "CISCO-MEMORY-POOL-MIB");
}
foreach ($cmp_array[$device[device_id]] as $index => $cmp) {
    if (is_array($cmp)) {
        if (mysql_result(mysql_query("SELECT count(cmp_id) FROM `cmpMemPool` WHERE `Index` = '{$index}' AND `device_id` = '" . $device['device_id'] . "'"), 0) == '0') {
            $query = "INSERT INTO cmpMemPool (`Index`,`cmpName`,`cmpAlternate`,`cmpValid`,`cmpUsed`,`cmpFree`,`cmpLargestFree`,`device_id`)\n                                values ('{$index}', '" . $cmp['ciscoMemoryPoolName'] . "', '" . $cmp['ciscoMemoryPoolAlternate'] . "', \n                                        '" . $cmp['ciscoMemoryPoolValid'] . "', '" . $cmp['ciscoMemoryPoolUsed'] . "', '" . $cmp['ciscoMemoryPoolFree'] . "', \n                                        '" . $cmp['ciscoMemoryPoolLargestFree'] . "', '" . $device['device_id'] . "')";
            mysql_query($query);
            echo "+";
        } else {
        }
        $valid_cmp[$index] = 1;
    }
}
$sql = "SELECT * FROM `cmpMemPool` WHERE `device_id`  = '" . $device['device_id'] . "'";
$query = mysql_query($sql);
while ($test_ciscoMemoryPool = mysql_fetch_array($query)) {
    if (!$valid_cmp[$test_ciscoMemoryPool[Index]]) {
        echo "-";
        mysql_query("DELETE FROM `ciscoMemoryPool` WHERE ciscoMemoryPool_id = '" . $test['ciscoMemoryPool_id'] . "'");
    }
}
unset($valid_ciscoMemoryPool);
echo "\n";
Exemplo n.º 5
0
<?php

print_r(snmpwalk_cache_oid($device, 'system', array()));
print_r(snmp_cache_oid('system', $device, array()));
Exemplo n.º 6
0
$stat_oids = array('ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInNUcastPkts', 'ifOutNUcastPkts', 'ifHCInMulticastPkts', 'ifHCInBroadcastPkts', 'ifHCOutMulticastPkts', 'ifHCOutBroadcastPkts', 'ifInOctets', 'ifOutOctets', 'ifHCInOctets', 'ifHCOutOctets');
$stat_oids_db = array('ifInOctets', 'ifOutOctets', 'ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts');
// From above for DB
$etherlike_oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames', 'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions', 'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors', 'dot3StatsSymbolErrors');
$cisco_oids = array('locIfHardType', 'locIfInRunts', 'locIfInGiants', 'locIfInCRC', 'locIfInFrame', 'locIfInOverrun', 'locIfInIgnored', 'locIfInAbort', 'locIfCollisions', 'locIfInputQueueDrops', 'locIfOutputQueueDrops');
$pagp_oids = array('pagpOperationMode', 'pagpPortState', 'pagpPartnerDeviceId', 'pagpPartnerLearnMethod', 'pagpPartnerIfIndex', 'pagpPartnerGroupIfIndex', 'pagpPartnerDeviceName', 'pagpEthcOperationMode', 'pagpDeviceId', 'pagpGroupIfIndex');
$ifmib_oids = array_merge($data_oids, $stat_oids);
$ifmib_oids = array('ifEntry', 'ifXEntry');
echo "Caching Oids: ";
foreach ($ifmib_oids as $oid) {
    echo "{$oid} ";
    $array = snmp_cache_oid($oid, $device, $array, "IF-MIB");
}
if ($config['enable_ports_etherlike']) {
    echo "dot3Stats ";
    $array = snmp_cache_oid("dot3StatsEntry", $device, $array, "EtherLike-MIB");
}
echo "\n";
#foreach ($etherlike_oids as $oid) { $array = snmp_cache_oid($oid, $device, $array, "EtherLike-MIB"); }
#foreach ($cisco_oids as $oid)     { $array = snmp_cache_oid($oid, $device, $array, "OLD-CISCO-INTERFACES-MIB"); }
#foreach ($pagp_oids as $oid)      { $array = snmp_cache_oid($oid, $device, $array, "CISCO-PAGP-MIB"); }
if ($device['os_group'] == "ios") {
    $array = snmp_cache_portIfIndex($device, $array);
    $array = snmp_cache_portName($device, $array);
    $data_oids[] = "portName";
    #$array = snmp_cache_oid("vmVlan", $device, $array, "CISCO-VLAN-MEMBERSHIP-MIB");
    #$array = snmp_cache_oid("vlanTrunkPortEncapsulationOperType", $device, $array, "CISCO-VTP-MIB");
    #$array = snmp_cache_oid("vlanTrunkPortNativeVlan", $device, $array, "CISCO-VTP-MIB");
}
$polled = time();
/// End Building SNMP Cache Array