//fix for ricoh devices returning garbage and devices returning percentage if ($os == 'ricoh') { if ($current == '-3') { $current = 50; } elseif ($current == '-100') { $current = 0; } else { $current = $current / $capacity * 100; } } else { //normal devices returning toner values $current = $current / $capacity * 100; } $type = 'jetdirect'; if (isHexString($descr)) { $descr = snmp_hexstring($descr); } discover_toner($valid_toner, $device, $toner_oid, $index, $type, $descr, $capacity_oid, $capacity, $current); } } } //end if } //end foreach } //end if // Delete removed toners d_echo("\n Checking ... \n"); d_echo($valid_toner); $sql = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'"; foreach (dbFetchRows($sql) as $test_toner) {
$marker_descr = "Printed " . nicecase($entry['prtMarkerCounterUnit']); list($hrDeviceIndex, $prtMarkerIndex) = explode('.', $index); $options = array('measured_class' => 'printersupply', 'measured_entity' => $printer_supply['supply_id'], 'sensor_unit' => $entry['prtMarkerCounterUnit']); // Lifetime counter (should be always single) $descr = "Total {$marker_descr}"; $oid_name = 'prtMarkerLifeCount'; $oid = '.1.3.6.1.2.1.43.10.2.1.4.' . $index; $value = $entry[$oid_name]; if (isset($entry[$oid_name])) { // CLEANME. Compatibility, remove in r8500, but not before CE 0.16.8 // Rename olf rrd filename and old ds name $new_rrd = 'sensor-counter-Printer-MIB-prtMarkerLifeCount-' . $index; $renamed = rename_rrd($device, 'pagecount', $new_rrd); if ($renamed) { rrdtool_rename_ds($device, $new_rrd, 'pagecount', 'sensor'); } discover_sensor($valid['sensor'], 'counter', $device, $oid, $index, $mib . '-' . $oid_name, $descr, 1, $value, $options); } // PowerOn counter $descr = "PowerOn {$marker_descr}"; if ($prt_supplies[$index]['prtMarkerSuppliesDescription']) { $descr .= ' - ' . snmp_hexstring($prt_supplies[$index]['prtMarkerSuppliesDescription']); } $oid_name = 'prtMarkerPowerOnCount'; $oid = '.1.3.6.1.2.1.43.10.2.1.5.' . $index; $value = $entry[$oid_name]; discover_sensor($valid['sensor'], 'counter', $device, $oid, $index, $mib . '-' . $oid_name, $descr, 1, $value, $options); // prtMarkerStatus // FIXME, binary statuses currently unsupported } // EOF
// Default scale $scale_min = 1 / 60; // Scale for minutes $inputs = snmp_get($device, 'upsPhaseNumInputs.0', '-Ovq', 'PowerNet-MIB'); $outputs = snmp_get($device, 'upsPhaseNumOutputs.0', '-Ovq', 'PowerNet-MIB'); echo 'Caching OIDs: '; $cache['apc'] = array(); // Check if we have values for these, if not, try other code paths below. if ($inputs || $outputs) { foreach (array('upsPhaseInputTable', 'upsPhaseOutputTable', 'upsPhaseInputPhaseTable', 'upsPhaseOutputPhaseTable') as $table) { echo "{$table} "; $cache['apc'] = snmpwalk_cache_multi_oid($device, $table, $cache['apc'], 'PowerNet-MIB'); } // Process each input, per phase for ($i = 1; $i <= $inputs; $i++) { $name = snmp_hexstring($cache['apc'][$i]['upsPhaseInputName']); $phases = $cache['apc'][$i]['upsPhaseNumInputPhases']; $tindex = $cache['apc'][$i]['upsPhaseInputTableIndex']; $itype = $cache['apc'][$i]['upsPhaseInputType']; if ($itype == 'bypass') { $name = 'Bypass'; } // Override "Input 2" in case of bypass. for ($p = 1; $p <= $phases; $p++) { $descr = "{$name} Phase {$p}"; $oid = ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.6.{$tindex}.1.{$p}"; $value = $cache['apc']["{$tindex}.1.{$p}"]['upsPhaseInputCurrent']; if ($value != '' && $value != -1) { discover_sensor($valid['sensor'], 'current', $device, $oid, "upsPhaseInputCurrent.{$tindex}.1.{$p}", 'apc', $descr, $scale, $value); } $oid = ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.3.{$tindex}.1.{$p}";
if ($oids) { echo "Jetdirect "; } foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($oid, $role) = explode(" ", $data); $split_oid = explode('.', $oid); $index = $split_oid[count($split_oid) - 1]; if (is_numeric($role)) { $type_oid = ".1.3.6.1.2.1.43.11.1.1.5.1.{$index}"; $descr_oid = ".1.3.6.1.2.1.43.11.1.1.6.1.{$index}"; $capacity_oid = ".1.3.6.1.2.1.43.11.1.1.8.1.{$index}"; $toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.1.{$index}"; $resourcetype = snmp_get($device, $type_oid, "-Oqv"); $descr = snmp_hexstring(trim(str_replace("\n", "", str_replace('"', '', snmp_get($device, $descr_oid, "-Oqv"))))); if ($descr != "") { switch ($resourcetype) { case 3: case 21: /* .1.3.6.1.2.1.43.11.1.1.8 prtMarkerSuppliesMaxCapacity * The value (-1) means other and specifically indicates that the sub-unit places * no restrictions on this parameter. The value (-2) means unknown. * * .1.3.6.1.2.1.43.11.1.1.9 prtMarkerSuppliesLevel * The value (-1) means other and specifically indicates that the sub-unit places * no restrictions on this parameter. The value (-2) means unknown. * A value of (-3) means that the printer knows that there is some supply/remaining space, * respectively. */ $level = snmp_get($device, $toner_oid, "-Oqv");
} } if ($remote_device_id) { $if = $lldp['lldpRemPortDesc']; $id = $lldp['lldpRemPortId']; // lldpPortIdSubtype -> lldpPortId // interfaceAlias(1), -> ifAlias // portComponent(2), -> entPhysicalAlias // macAddress(3), -> ifPhysAddress // networkAddress(4), -> IP address // interfaceName(5), -> ifName // agentCircuitId(6), -> agent-local identifier of the circuit (defined in RFC 3046) (FIXME, not know) // local(7) -> ifIndex switch ($lldp['lldpRemPortIdSubtype']) { case 'interfaceAlias': $id = snmp_hexstring($id); $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifAlias` = ? OR `ifDescr` = ?) AND `device_id` = ?", array($id, $if, $remote_device_id)); break; case 'interfaceName': $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ?) AND `device_id` = ?", array($id, $if, $remote_device_id)); break; case 'macAddress': $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE `ifPhysAddress` = ? AND `device_id` = ?", array(strtolower(str_replace(array(' ', '-'), '', $id)), $remote_device_id)); break; case 'networkAddress': $ip_version = get_ip_version($id); if ($ip_version) { $ip = $ip_version === 6 ? Net_IPv6::uncompress($id, TRUE) : $id; $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ipv" . $ip_version . "_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `ipv" . $ip_version . "_address` = ? AND `device_id` = ?", array($ip, $remote_device_id)); } break;
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ $hardware = trim(snmp_get($device, 'oaLdCardBackplanePN.0', '-OQv', 'OADWDM-MIB'), '"'); $serial = trim(snmp_get($device, 'oaLdCardBackplaneSN.0', '-OQv', 'OADWDM-MIB'), '"'); # Version is a null terminated hex-string, convert to normal string and strip null bytes $version = trim(snmp_hexstring(trim(snmp_get($device, 'oaLdSoftVersString.0', '-OQv', 'OADWDM-MIB'), '"')), ""); // EOF
<?php $hardware = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.1.1.1.0', '-OQv', '', ''), '"'); if (!$hardware) { $hardware = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.2.1.1.0', '-OQv', '', ''), '"'); } $version = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.1.1.4.0', '-OQv', '', ''), '"'); if (!$version) { $version = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.2.1.4.0', '-OQv', '', ''), '"'); } $serial = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.1.1.3.0', '-OQv', '', ''), '"'); if (!$serial) { $serial = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.2.1.3.0', '-OQv', '', ''), '"'); } if (isHexString($serial)) { // Sometimes firmware outputs serial as hex-string $serial = snmp_hexstring($serial); }
/** * @dataProvider providerSNMPHexString * @group hex */ public function testSNMPHexString($string, $result) { $this->assertSame($result, snmp_hexstring($string)); }
<?php $hardware = trim(snmp_get($device, "oaLdCardBackplanePN.0", "-OQv", "OADWDM-MIB"), '"'); $serial = trim(snmp_get($device, "oaLdCardBackplaneSN.0", "-OQv", "OADWDM-MIB"), '"'); $version = trim(snmp_get($device, "oaLdSoftVersString.0", "-OQv", "OADWDM-MIB"), '"'); #version is a null termianted hex-string, convert to normal string and strip null bytes $version = trim(snmp_hexstring($version), ""); # $features =
$current = 5; break; case '2': $current = 0; break; case '3': $current = 1; break; } } else { //normal devices returning toner values $current = $current / $capacity * 100; } $type = 'jetdirect'; if (isHexString($descr)) { $descr = preg_replace('/[^ \\w]+/', '', snmp_hexstring($descr)); } discover_toner($valid_toner, $device, $toner_oid, $index, $type, $descr, $capacity_oid, $capacity, $current); } } } //end if } //end foreach } //end if // Delete removed toners d_echo("\n Checking ... \n"); d_echo($valid_toner); $sql = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'"; foreach (dbFetchRows($sql) as $test_toner) {
// other(1), unknown(2), tenThousandthsOfInches(3), micrometers(4), // impressions(7), sheets(8), hours(11), thousandthsOfOunces(12), // tenthsOfGrams(13), hundrethsOfFluidOunces(14), tenthsOfMilliliters(15), // feet(16), meters(17), // -- Values for Finisher MIB // items(18), percent(19) default: $unit = 'percent'; } $update_array = array('description' => $descr, 'index' => $index, 'oid' => $oid, 'mib' => 'jetdirect', 'unit' => $unit, 'level' => $level, 'capacity' => $capacity, 'capacity_oid' => $capacity_oid); // Attach Colorant entry if exist list($hrDeviceIndex, $prtMarkerSuppliesIndex) = explode('.', $index); if (isset($entry['prtMarkerSuppliesColorantIndex']) && isset($prt_colorant[$hrDeviceIndex][$entry['prtMarkerSuppliesColorantIndex']])) { $entry = array_merge($entry, $prt_colorant[$hrDeviceIndex][$entry['prtMarkerSuppliesColorantIndex']]); if (isset($entry['prtMarkerColorantValue'])) { $update_array['colour'] = snmp_hexstring($entry['prtMarkerColorantValue']); } } // Colorant table empty, try detect colour by description if (!isset($update_array['colour'])) { foreach ($GLOBALS['config']['toner'] as $colour => $strings) { foreach ($strings as $str) { if (stripos($descr, $str) !== FALSE) { $update_array['colour'] = $colour; break 2; } } } } switch ($entry['prtMarkerSuppliesType']) { case 'toner':
BIANCA-BRICK-MIBRES-MIB::memoryBlockSize.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryBlockSize.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryTotal.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 4194304 BIANCA-BRICK-MIBRES-MIB::memoryTotal.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 16711680 BIANCA-BRICK-MIBRES-MIB::memoryTotal.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 96 BIANCA-BRICK-MIBRES-MIB::memoryInuse.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryInuse.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 13639380 BIANCA-BRICK-MIBRES-MIB::memoryInuse.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryDramUse.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryDramUse.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryDramUse.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 6528 BIANCA-BRICK-MIBRES-MIB::memoryNAllocs.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryNAllocs.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 3006 BIANCA-BRICK-MIBRES-MIB::memoryNAllocs.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 53354 BIANCA-BRICK-MIBRES-MIB::memoryNFrees.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryNFrees.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 89 BIANCA-BRICK-MIBRES-MIB::memoryNFrees.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 53434 BIANCA-BRICK-MIBRES-MIB::memoryNFails.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryNFails.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 BIANCA-BRICK-MIBRES-MIB::memoryNFails.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0 */ $mempool_array = snmpwalk_cache_multi_oid($device, 'memoryTable', array(), 'BIANCA-BRICK-MIBRES-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX); foreach ($mempool_array as $index => $entry) { if ($entry['memoryType'] == 'dpool') { continue; } $entry['memoryDescr'] = snmp_hexstring($entry['memoryDescr']); discover_mempool($valid['mempool'], $device, $index, 'BIANCA-BRICK-MIBRES-MIB', $entry['memoryDescr'], 1, $entry['memoryTotal'], $entry['memoryInuse']); } unset($mempool_array); // EOF