本文整理汇总了PHP中mib_dirs函数的典型用法代码示例。如果您正苦于以下问题:PHP mib_dirs函数的具体用法?PHP mib_dirs怎么用?PHP mib_dirs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mib_dirs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: snmp_translate
function snmp_translate($oid, $mib = NULL, $mibdir = NULL)
{
// $rewrite_oids set in rewrites.php
global $rewrite_oids, $config, $debug;
if ($mib) {
// If $mib::$oid known in $rewrite_oids use this value instead shell command snmptranslate.
if (isset($rewrite_oids[$mib][$oid])) {
if ($debug) {
echo "TRANSLATE (REWRITE):[" . $rewrite_oids[$mib][$oid] . "]\n";
}
return $rewrite_oids[$mib][$oid];
}
$oid = "{$mib}::{$oid}";
}
$cmd = $config['snmptranslate'];
if ($options) {
$cmd .= ' ' . $options;
} else {
$cmd .= ' -On';
}
if ($mib) {
$cmd .= ' -m ' . $mib;
}
if ($mibdir) {
$cmd .= ' -M ' . $mibdir;
} else {
$cmd .= ' -M ' . mib_dirs();
}
$cmd .= ' ' . $oid;
if (!$debug) {
$cmd .= ' 2>/dev/null';
}
$data = trim(external_exec($cmd));
if ($data && !strstr($data, 'Unknown')) {
if ($debug) {
echo "TRANSLATE (CMD): {$oid} [" . $data . "]";
}
return $data;
} else {
return '';
}
}
示例2: snmpwalk_cache_oid
<?php
// Ignore this discovery module if we have already discovered things in CISCO-ENHANCED-MEMPOOL-MIB. Dirty duplication.
if (!isset($valid['mempool']['cisco-enhanced-mempool-mib'])) {
$mib = 'CISCO-MEMORY-POOL-MIB';
echo " {$mib} ";
$mempool_array = snmpwalk_cache_oid($device, 'ciscoMemoryPool', NULL, $mib, mib_dirs('cisco'));
if (is_array($mempool_array)) {
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['ciscoMemoryPoolUsed']) && is_numeric($index)) {
$descr = $entry['ciscoMemoryPoolName'];
$used = $entry['ciscoMemoryPoolUsed'];
$free = $entry['ciscoMemoryPoolFree'];
$total = $used + $free;
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, 1, $total, $used);
}
}
}
unset($mempool_array, $index, $descr, $total, $used, $free);
}
// EOF
示例3: snmpwalk_cache_oid
<?php
# NETSWITCH-MIB::hpGlobalMemSlotIndex.1 = INTEGER: 1
# NETSWITCH-MIB::hpGlobalMemSlabCnt.1 = Counter32: 3966
# NETSWITCH-MIB::hpGlobalMemFreeSegCnt.1 = Counter32: 166
# NETSWITCH-MIB::hpGlobalMemAllocSegCnt.1 = Counter32: 3803
# NETSWITCH-MIB::hpGlobalMemTotalBytes.1 = INTEGER: 11337704
# NETSWITCH-MIB::hpGlobalMemFreeBytes.1 = INTEGER: 9669104
# NETSWITCH-MIB::hpGlobalMemAllocBytes.1 = INTEGER: 1668728
if (!is_array($mempool_cache['hpGlobal'])) {
$mempool_cache['hpGlobal'] = snmpwalk_cache_oid($device, "hpGlobal", NULL, "NETSWITCH-MIB", mib_dirs('hp'));
if ($debug) {
print_r($mempool_cache);
}
} else {
if ($debug) {
echo "Cached!";
}
}
$entry = $mempool_cache['hpGlobal'][$mempool[mempool_index]];
$mempool['units'] = "1";
$mempool['used'] = $entry['hpGlobalMemAllocBytes'];
$mempool['total'] = $entry['hpGlobalMemTotalBytes'];
$mempool['free'] = $entry['hpGlobalMemFreeBytes'];
示例4: snmp_get
<?php
///
// Hardcoded discovery of cpu usage on HP Procurve devices.
///
// STATISTICS-MIB::hpSwitchCpuStat.0 = INTEGER: 10
if ($device['os'] == "procurve") {
echo "Procurve : ";
$descr = "Processor";
$usage = snmp_get($device, ".1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "-OQUvs", "STATISTICS-MIB", mib_dirs('hp'));
if (is_numeric($usage)) {
discover_processor($valid['processor'], $device, "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "0", "procurve-fixed", $descr, "1", $usage, NULL, NULL);
}
}
unset($processors_array);
示例5: str_replace
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
#NS-ROOT-MIB::sysHardwareVersionDesc.0 = STRING: "7000 v1 6*EZ+2*EM"
#NS-ROOT-MIB::sysBuildVersion.0 = STRING: "NetScaler NS8.1: Build 69.4, Date: Jan 28 2010, 02:00:43 "
$hardware = str_replace("\"", "", snmp_get($device, "sysHardwareVersionDesc.0", "-Osqv", "SNMPv2-MIB:NS-ROOT-MIB", mib_dirs('citrix')));
$version = str_replace("\"", "", snmp_get($device, "sysBuildVersion.0", "-Osqv", "SNMPv2-MIB:NS-ROOT-MIB", mib_dirs('citrix')));
$serial = str_replace("\"", "", snmp_get($device, "sysHardwareSerialNumber.0", "-Osqv", "SNMPv2-MIB:NS-ROOT-MIB", mib_dirs('citrix')));
list($version, $features) = explode(":", $version);
list(, $version) = explode(" ", $version);
list($features) = explode(",", trim($features));
// EOF
示例6: trim
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
// Yes, that's the Kenel version.
$version = "Kernel " . trim(snmp_get($device, "entKenelVersion.0", "-OQv", "SENAO-ENTERPRISE-INDOOR-AP-CB-MIB", mib_dirs('senao')), '" ');
$version .= " / Apps " . trim(snmp_get($device, "entAppVersion.0", "-OQv", "SENAO-ENTERPRISE-INDOOR-AP-CB-MIB", mib_dirs('senao')), '" ');
$serial = trim(snmp_get($device, "entSN.0", "-OQv", "SENAO-ENTERPRISE-INDOOR-AP-CB-MIB", mib_dirs('senao')), '" ');
// There doesn't seem to be a real hardware identification.. sysName will have to do?
$hardware = str_replace("EnGenius ", "", snmp_get($device, "sysName.0", "-OQv")) . " v" . trim(snmp_get($device, "entHwVersion.0", "-OQv", "SENAO-ENTERPRISE-INDOOR-AP-CB-MIB", mib_dirs('senao')), '" .');
$mode = snmp_get($device, "entSysMode.0", "-OQv", "SENAO-ENTERPRISE-INDOOR-AP-CB-MIB", mib_dirs('senao'));
switch ($mode) {
case 0:
$features = "Router mode";
break;
case 1:
$features = "Universal repeater mode";
break;
case 2:
$features = "Access Point mode";
break;
case 3:
$features = "Client Bridge mode";
break;
case 4:
$features = "Client router mode";
示例7: trim
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
$hardware = trim(snmp_get($device, "spManufName.0", "-OQv", "SPAGENT-MIB", mib_dirs('akcp')), '"');
$hardware .= ' ' . trim(snmp_get($device, "spProductName.0", "-OQv", "SPAGENT-MIB", mib_dirs('akcp')), '" ');
// EOF
示例8: createHost
function createHost($hostname, $snmp_community = NULL, $snmp_version, $snmp_port = 161, $snmp_transport = 'udp', $snmp_v3 = array())
{
$hostname = trim(strtolower($hostname));
$device = array('hostname' => $hostname, 'sysName' => $hostname, 'status' => '1', 'snmp_community' => $snmp_community, 'snmp_port' => $snmp_port, 'snmp_transport' => $snmp_transport, 'snmp_version' => $snmp_version);
// Add snmp v3 auth params
foreach (array('authlevel', 'authname', 'authpass', 'authalgo', 'cryptopass', 'cryptoalgo') as $v3_key) {
if (isset($snmp_v3['snmp_' . $v3_key])) {
// Or $snmp_v3['snmp_authlevel']
$device['snmp_' . $v3_key] = $snmp_v3['snmp_' . $v3_key];
} else {
if (isset($snmp_v3[$v3_key])) {
// Or $snmp_v3['authlevel']
$device['snmp_' . $v3_key] = $snmp_v3[$v3_key];
}
}
}
// This is compatibility code after refactor in r6306, for keep devices up before DB updated
if (get_db_version() < 189) {
// FIXME. Remove this in r7000
$device['snmpver'] = $device['snmp_version'];
unset($device['snmp_version']);
foreach (array('transport', 'port', 'timeout', 'retries', 'community', 'authlevel', 'authname', 'authpass', 'authalgo', 'cryptopass', 'cryptoalgo') as $old_key) {
if (isset($device['snmp_' . $old_key])) {
// Convert to old device snmp keys
$device[$old_key] = $device['snmp_' . $old_key];
unset($device['snmp_' . $old_key]);
}
}
}
$device['os'] = get_device_os($device);
$device['snmpEngineID'] = snmp_cache_snmpEngineID($device);
$device['sysName'] = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
$device['location'] = snmp_get($device, "sysLocation.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
$device['sysContact'] = snmp_get($device, "sysContact.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
if ($device['os']) {
$device_id = dbInsert($device, 'devices');
if ($device_id) {
log_event("设备添加: {$hostname}", $device_id, 'device', $device_id, 5);
// severity 5, for logging user/console info
if (is_cli()) {
print_success("正在使用自动发现功能 " . $device['hostname'] . " (id = " . $device_id . ")");
$device['device_id'] = $device_id;
// Discover things we need when linking this to other hosts.
discover_device($device, $options = array('m' => 'ports'));
discover_device($device, $options = array('m' => 'ipv4-addresses'));
discover_device($device, $options = array('m' => 'ipv6-addresses'));
log_event("snmpEngineID -> " . $device['snmpEngineID'], $device, 'device', $device['device_id']);
// Reset `last_discovered` for full rediscover device by cron
dbUpdate(array('last_discovered' => 'NULL'), 'devices', '`device_id` = ?', array($device_id));
array_push($GLOBALS['devices'], $device_id);
}
return $device_id;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
示例9: snmpwalk_cache_multi_oid
*/
echo " GUDEADS-EPC8X-MIB ";
// GUDEADS-EPC8X-MIB::epc8TempSensor.1 = INTEGER: -9999 10th of degree Celsius
// GUDEADS-EPC8X-MIB::epc8TempSensor.2 = INTEGER: -9999 10th of degree Celsius
// GUDEADS-EPC8X-MIB::epc8HygroSensor.1 = INTEGER: -9999 10th of percentage humidity
// GUDEADS-EPC8X-MIB::epc8HygroSensor.2 = INTEGER: -9999 10th of percentage humidity
$cache['epc8x'] = snmpwalk_cache_multi_oid($device, "epc8SensorTable", array(), "GUDEADS-EPC8X-MIB", mib_dirs('gude'));
$scale = 0.1;
foreach ($cache['epc8x'] as $index => $entry) {
$oid = ".1.3.6.1.4.1.28507.1.1.3.2.1.2.{$index}";
$descr = "Temp Sensor {$index}";
$value = $entry['epc8TempSensor'];
if ($value != '' && $value != -9999) {
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'epc8TempSensor.' . $index, 'epc8x', $descr, $scale, $value * $scale);
}
$oid = ".1.3.6.1.4.1.28507.1.1.3.2.1.3.{$index}";
$descr = "Hygro Sensor {$index}";
$value = $entry['epc8HygroSensor'];
if ($value != '' && $value != -9999) {
discover_sensor($valid['sensor'], 'humidity', $device, $oid, 'epc8HygroSensor.' . $index, 'epc8x', $descr, $scale, $value * $scale);
}
}
// GUDEADS-EPC8X-MIB::epc8Irms.0 = INTEGER: 3121 mA
$oid = ".1.3.6.1.4.1.28507.1.1.3.1.0";
$descr = "Output";
$value = snmp_get($device, "epc8Irms.0", "-Oqv", "GUDEADS-EPC8X-MIB", mib_dirs('gude'));
$scale = 0.001;
if ($value != '' && $value != -9999) {
discover_sensor($valid['sensor'], 'current', $device, $oid, 'epc8Irms.0', 'epc8x', $descr, $scale, $value * $scale);
}
// EOF
示例10: snmpwalk_cache_triple_oid
echo " FOUNDRY-SN-AGENT-MIB ";
$processors_array = snmpwalk_cache_triple_oid($device, "snAgentCpuUtilEntry", $processors_array, "FOUNDRY-SN-AGENT-MIB", mib_dirs('foundry'));
if ($debug) {
print_vars($processors_array);
}
foreach ($processors_array as $index => $entry) {
if ((isset($entry['snAgentCpuUtilValue']) || isset($entry['snAgentCpuUtil100thPercent'])) && $entry['snAgentCpuUtilInterval'] == "300") {
#$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
if ($entry['snAgentCpuUtil100thPercent']) {
$usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.6." . $index;
$usage = $entry['snAgentCpuUtil100thPercent'];
$precision = 100;
} elseif ($entry['snAgentCpuUtilValue']) {
$usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.4." . $index;
$usage = $entry['snAgentCpuUtilValue'];
$precision = 100;
}
list($slot, $instance, $interval) = explode(".", $index);
$descr_oid = "snAgentConfigModuleDescription." . $entry['snAgentCpuUtilSlotNum'];
$descr = snmp_get($device, $descr_oid, "-Oqv", "FOUNDRY-SN-AGENT-MIB", mib_dirs('foundry'));
$descr = str_replace("\"", "", $descr);
list($descr) = explode(" ", $descr);
$descr = "Slot " . $entry['snAgentCpuUtilSlotNum'] . " " . $descr;
$descr = $descr . " [" . $instance . "]";
if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "") {
discover_processor($valid['processor'], $device, $usage_oid, $index, "ironware", $descr, $precision, $usage, $entPhysicalIndex, NULL);
}
}
}
unset($processors_array);
// EOF
示例11: snmp_get
<?php
// Hardcoded discovery of cpu usage on WatchGuard devices.
//
// WATCHGUARD-SYSTEM-STATISTICS-MIB::wgSystemCpuUtil5.0 = COUNTER: 123
echo " WATCHGUARD-SYSTEM-STATISTICS-MIB ";
$descr = "Processor";
$usage = snmp_get($device, ".1.3.6.1.4.1.3097.6.3.78.0", "-OQUvs", "WATCHGUARD-SYSTEM-STATISTICS-MIB", $config['mib_dir'] . ':' . mib_dirs('watchguard'));
if (is_numeric($usage)) {
discover_processor($valid['processor'], $device, "1.3.6.1.4.1.3097.6.3.78.0", "0", "firebox-fixed", $descr, "100", $usage, NULL, NULL);
}
// EOF
示例12: trim
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
// This could do with a decent rewrite using SNMP multi functions, instead of trim() and str_replace() voodoo.
echo " FOUNDRY-SN-AGENT-MIB ";
$oids = trim(snmp_walk($device, "snAgentTempSensorDescr", "-Osqn", "FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB", mib_dirs('foundry')));
$oids = str_replace(".1.3.6.1.4.1.1991.1.1.2.13.1.1.3.", "", $oids);
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data != "") {
list($oid) = explode(" ", $data);
$temperature_oid = ".1.3.6.1.4.1.1991.1.1.2.13.1.1.4.{$oid}";
$descr_oid = ".1.3.6.1.4.1.1991.1.1.2.13.1.1.3.{$oid}";
$descr = snmp_get($device, $descr_oid, "-Oqv", "");
$temperature = snmp_get($device, $temperature_oid, "-Oqv", "");
if (!strstr($descr, "No") && !strstr($temperature, "No") && $descr != "" && $temperature != "0") {
$descr = str_replace("\"", "", $descr);
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("sensor", "Sensor", $descr);
$descr = str_replace("Line module", "Slot", $descr);
$descr = str_replace("Switch Fabric module", "Fabric", $descr);
示例13: createHost
function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array())
{
$host = trim(strtolower($host));
$device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver);
$device = array_merge($device, $v3);
$device['os'] = get_device_os($device);
$device['snmpEngineID'] = snmp_cache_snmpEngineID($device);
$device['sysName'] = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
$device['location'] = snmp_get($device, "sysLocation.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
$device['sysContact'] = snmp_get($device, "sysContact.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
if ($device['os']) {
$device_id = dbInsert($device, 'devices');
if ($device_id) {
log_event("Device added: {$host}", $device_id, 'device');
if (is_cli()) {
print_success("Now discovering " . $device['hostname'] . " (id = " . $device_id . ")");
$device['device_id'] = $device_id;
// Discover things we need when linking this to other hosts.
discover_device($device, $options = array('m' => 'ports'));
discover_device($device, $options = array('m' => 'ipv4-addresses'));
discover_device($device, $options = array('m' => 'ipv6-addresses'));
log_event("snmpEngineID -> " . $device['snmpEngineID'], $device, 'system');
// Reset `last_discovered` for full rediscover device by cron
dbUpdate(array('last_discovered' => 'NULL'), 'devices', '`device_id` = ?', array($device_id));
array_push($GLOBALS['devices'], $device_id);
}
return $device_id;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
示例14: snmpwalk_cache_oid
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
$mib = 'HOST-RESOURCES-MIB';
echo " {$mib} ";
$mempool_array = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES", mib_dirs());
if (is_array($mempool_array)) {
foreach ($mempool_array as $index => $entry) {
$descr = $entry['hrStorageDescr'];
$units = $entry['hrStorageAllocationUnits'];
$total = $entry['hrStorageSize'] * $units;
$used = $entry['hrStorageUsed'] * $units;
$deny = TRUE;
switch ($entry['hrStorageType']) {
case 'hrStorageVirtualMemory':
case 'hrStorageRam':
case 'hrStorageOther':
case 'hrStorageTypes.20':
case 'nwhrStorageDOSMemory':
case 'nwhrStorageMemoryAlloc':
case 'nwhrStorageMemoryPermanent':
case 'nwhrStorageCacheBuffers':
示例15: snmpwalk_cache_oid
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutOctWraps.0 = Counter32: 126 Integral units
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutUncompOctets.0 = Counter32: 3486168696 Octets
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalHcOutUncompOctets.0 = Counter64: 544652047992 Octets
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutUncompOctWraps.0 = Counter32: 126 Integral units
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutPkts.0 = Counter32: 828696339 Packets
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutDrops.0 = Counter32: 4520 Packets
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutAuths.0 = Counter32: 828696339 Events
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutAuthFails.0 = Counter32: 0 Failures
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutEncrypts.0 = Counter32: 828696318 Packets
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalOutEncryptFails.0 = Counter32: 0 Failures
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalProtocolUseFails.0 = Counter32: 0 Failures
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalNoSaFails.0 = Counter32: 5 Failures
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalSysCapFails.0 = Counter32: 0 Failures
// FIXME. Candidate for migrate to graphs module with table_collect()
if (is_device_mib($device, 'CISCO-IPSEC-FLOW-MONITOR-MIB')) {
$data = snmpwalk_cache_oid($device, "cipSecGlobalStats", NULL, "CISCO-IPSEC-FLOW-MONITOR-MIB", mib_dirs('cisco'));
$data = $data[0];
// Use HC Counters if they exist
if (is_numeric($data['cipSecGlobalHcInOctets'])) {
$data['cipSecGlobalInOctets'] = $data['cipSecGlobalHcInOctets'];
}
if (is_numeric($data['cipSecGlobalHcOutOctets'])) {
$data['cipSecGlobalOutOctets'] = $data['cipSecGlobalHcOutOctets'];
}
if (is_numeric($data['cipSecGlobalHcInDecompOctets'])) {
$data['cipSecGlobalInDecompOctets'] = $data['cipSecGlobalHcInDecompOctets'];
}
if (is_numeric($data['cipSecGlobalHcOutUncompOctets'])) {
$data['cipSecGlobalOutUncompOctets'] = $data['cipSecGlobalHcOutUncompOctets'];
}
$rrd_filename = "cipsec_flow.rrd";