diff --git a/includes/discovery/arp-table.inc.php b/includes/discovery/arp-table.inc.php index a292bf25b..69b0d9b75 100644 --- a/includes/discovery/arp-table.inc.php +++ b/includes/discovery/arp-table.inc.php @@ -43,9 +43,7 @@ foreach (explode("\n", $ipNetToMedia_data) as $data) { $old_mac = dbFetchCell('SELECT mac_address from ipv4_mac WHERE ipv4_address=? AND port_id=?', array($ip, $interface['port_id'])); if ($clean_mac != $old_mac && $clean_mac != '' && $old_mac != '') { - if ($debug) { - echo "Changed mac address for $ip from $old_mac to $clean_mac\n"; - } + d_echo("Changed mac address for $ip from $old_mac to $clean_mac\n"); log_event("MAC change: $ip : ".mac_clean_to_readable($old_mac).' -> '.mac_clean_to_readable($clean_mac), $device, 'interface', $interface['port_id']); } @@ -73,9 +71,7 @@ foreach (dbFetchRows($sql) as $entry) { $entry_if = $entry['port_id']; if (!$mac_table[$entry_if][$entry_mac]) { dbDelete('ipv4_mac', '`port_id` = ? AND `mac_address` = ?', array($entry_if, $entry_mac)); - if ($debug) { - echo "Removing MAC $entry_mac from interface ".$interface['ifName']; - } + d_echo("Removing MAC $entry_mac from interface ".$interface['ifName']); echo '-'; } diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index 304bbc6b1..b9f3c16a0 100644 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -1,7 +1,5 @@ $peer_ip, @@ -70,9 +64,7 @@ if ($config['enable_bgp']) { $peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16))))); if ($peer) { - if ($debug) { - echo "Found peer $peer_ip (AS$peer_as)\n"; - } + d_echo("Found peer $peer_ip (AS$peer_as)\n"); $peerlist[] = array( 'ip' => $peer_ip, @@ -121,19 +113,15 @@ if ($config['enable_bgp']) { $af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']); } - if ($debug) { - echo 'afi data :: '; - print_r($af_data); - } + d_echo('afi data :: '; + d_echo($af_data); foreach ($af_data as $k => $v) { if ($peer2 === true) { list(,$k) = explode('.', $k, 2); } - if ($debug) { - echo "AFISAFI = $k\n"; - } + d_echo("AFISAFI = $k\n"); $afisafi_tmp = explode('.', $k); $safi = array_pop($afisafi_tmp); @@ -162,9 +150,7 @@ if ($config['enable_bgp']) { switch ($entry['jnxBgpM2PeerRemoteAddrType']) { case 'ipv4': $ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr'])); - if ($debug) { - echo "peerindex for ipv4 $ip is ".$entry['jnxBgpM2PeerIndex']."\n"; - } + d_echo("peerindex for ipv4 $ip is ".$entry['jnxBgpM2PeerIndex']."\n"); $j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex']; break; @@ -173,9 +159,7 @@ if ($config['enable_bgp']) { $ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"'); $ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4); $ip6 = Net_IPv6::compress($ip6); - if ($debug) { - echo "peerindex for ipv6 $ip6 is ".$entry['jnxBgpM2PeerIndex']."\n"; - } + d_echo("peerindex for ipv6 $ip6 is ".$entry['jnxBgpM2PeerIndex']."\n"); $j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex']; break; diff --git a/includes/discovery/charge.inc.php b/includes/discovery/charge.inc.php index c82863d0f..eeea0961f 100644 --- a/includes/discovery/charge.inc.php +++ b/includes/discovery/charge.inc.php @@ -6,9 +6,7 @@ echo 'Battery Charge: '; $include_dir = 'includes/discovery/charge'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['charge']); -} +d_echo($valid['sensor']['charge']); check_valid_sensors($device, 'charge', $valid['sensor']); diff --git a/includes/discovery/charge/apc.inc.php b/includes/discovery/charge/apc.inc.php index b9858b958..ce98b4b9d 100644 --- a/includes/discovery/charge/apc.inc.php +++ b/includes/discovery/charge/apc.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'apc') { $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.2.3.1.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); // Try High-Precision First if (!empty($oids)) { @@ -27,9 +25,7 @@ if ($device['os'] == 'apc') { else { // Try to just get capacity $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.2.2.1.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if (!empty($oids)) { echo 'APC UPS Battery Charge'; diff --git a/includes/discovery/charge/rfc1628.inc.php b/includes/discovery/charge/rfc1628.inc.php index c7d5742c7..02b85e03f 100644 --- a/includes/discovery/charge/rfc1628.inc.php +++ b/includes/discovery/charge/rfc1628.inc.php @@ -5,9 +5,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul echo 'RFC1628 '; $oids = snmp_walk($device, '1.3.6.1.2.1.33.1.2.4', '-Osqn', 'UPS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { diff --git a/includes/discovery/cisco-cef.inc.php b/includes/discovery/cisco-cef.inc.php index 7b8ef3a80..5f9ef1ca6 100644 --- a/includes/discovery/cisco-cef.inc.php +++ b/includes/discovery/cisco-cef.inc.php @@ -4,9 +4,7 @@ echo 'Cisco CEF Switching Path: '; $cefs = array(); $cefs = snmpwalk_cache_threepart_oid($device, 'CISCO-CEF-MIB::cefSwitchingPath', $cefs); -if ($debug) { - print_r($cefs); -} +d_echo($cefs); if (is_array($cefs)) { if (!is_array($entity_array)) { diff --git a/includes/discovery/cisco-entity-sensor.inc.php b/includes/discovery/cisco-entity-sensor.inc.php index e7053a20d..66340dedb 100644 --- a/includes/discovery/cisco-entity-sensor.inc.php +++ b/includes/discovery/cisco-entity-sensor.inc.php @@ -33,9 +33,7 @@ if ($device['os_group'] == 'cisco') { echo ' entSensorThresholdValue'; $t_oids = snmpwalk_cache_twopart_oid($device, 'entSensorThresholdValue', $t_oids, 'CISCO-ENTITY-SENSOR-MIB'); - if ($debug) { - print_r($oids); - } + d_echo($oids); $entitysensor['voltsDC'] = 'voltage'; $entitysensor['voltsAC'] = 'voltage'; diff --git a/includes/discovery/cisco-vrf.inc.php b/includes/discovery/cisco-vrf.inc.php index 39928b734..aceef192f 100644 --- a/includes/discovery/cisco-vrf.inc.php +++ b/includes/discovery/cisco-vrf.inc.php @@ -34,10 +34,8 @@ if ($config['enable_vrfs']) { $ports_oid = '.1.3.6.1.2.1.10.166.11.1.2.1.1.2'; } - if ($debug) { - echo "\n[DEBUG]\nUsing $vpnmib\n[/DEBUG]\n"; - echo "\n[DEBUG OIDS]\n$rds\n[/DEBUG]\n"; - } + d_echo("\n[DEBUG]\nUsing $vpnmib\n[/DEBUG]\n"); + d_echo("\n[DEBUG OIDS]\n$rds\n[/DEBUG]\n"); $rds = trim($rds); diff --git a/includes/discovery/current.inc.php b/includes/discovery/current.inc.php index c28644184..143d6068c 100644 --- a/includes/discovery/current.inc.php +++ b/includes/discovery/current.inc.php @@ -5,9 +5,7 @@ echo 'Current: '; $include_dir = 'includes/discovery/current'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['current']); -} +d_echo($valid['sensor']['current']); check_valid_sensors($device, 'current', $valid['sensor']); diff --git a/includes/discovery/current/apc.inc.php b/includes/discovery/current/apc.inc.php index e57f26640..8e35df882 100644 --- a/includes/discovery/current/apc.inc.php +++ b/includes/discovery/current/apc.inc.php @@ -9,9 +9,7 @@ if ($device['os'] == 'apc') { } if ($oids) { - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { @@ -64,9 +62,7 @@ if ($device['os'] == 'apc') { // should work with firmware v2 and v3 if ($oids) { echo 'APC PowerNet-MIB Banks '; - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); $type = 'apc'; @@ -132,9 +128,7 @@ if ($device['os'] == 'apc') { $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.26.9.4.3.1.1', '-t 30 -OsqnU', 'PowerNet-MIB'); if ($oids) { echo 'APC PowerNet-MIB Outlets '; - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); $type = 'apc'; @@ -179,9 +173,7 @@ if ($device['os'] == 'apc') { $oids = snmp_walk($device, 'atsConfigPhaseTableIndex', '-OsqnU', 'PowerNet-MIB'); if ($oids) { $type = 'apc'; - if ($debug) { - print_r($oids); - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { @@ -239,9 +231,7 @@ if ($device['os'] == 'apc') { } if (!empty($oids)) { - if ($debug) { - print_r($oids); - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/current/mgeups.inc.php b/includes/discovery/current/mgeups.inc.php index c2a7b77a7..bc80a0b16 100644 --- a/includes/discovery/current/mgeups.inc.php +++ b/includes/discovery/current/mgeups.inc.php @@ -4,9 +4,7 @@ if ($device['os'] == 'mgeups') { echo 'MGE '; $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.7.1', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $numPhase = count(explode("\n", $oids)); for ($i = 1; $i <= $numPhase; $i++) { @@ -36,9 +34,7 @@ if ($device['os'] == 'mgeups') { }//end for $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.6.1', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $numPhase = count(explode("\n", $oids)); for ($i = 1; $i <= $numPhase; $i++) { diff --git a/includes/discovery/current/rfc1628.inc.php b/includes/discovery/current/rfc1628.inc.php index d86b70808..73811ae10 100644 --- a/includes/discovery/current/rfc1628.inc.php +++ b/includes/discovery/current/rfc1628.inc.php @@ -5,9 +5,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul echo 'RFC1628 '; $oids = snmp_walk($device, '1.3.6.1.2.1.33.1.2.6', '-Osqn', 'UPS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { @@ -28,9 +26,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.4.3.0', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { @@ -49,9 +45,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.3.2.0', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { @@ -70,9 +64,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.5.2.0', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { diff --git a/includes/discovery/current/sentry3.inc.php b/includes/discovery/current/sentry3.inc.php index 6946d3770..45bcc6d9f 100644 --- a/includes/discovery/current/sentry3.inc.php +++ b/includes/discovery/current/sentry3.inc.php @@ -12,9 +12,7 @@ if ($device['os'] == 'sentry3') { // // Check for Infeeds $infeed_oids = snmp_walk($device, "infeedID.$towers.1", '-Osqn', 'Sentry3-MIB'); - if ($debug) { - echo $infeed_oids."\n"; - } + d_echo($infeed_oids."\n"); $infeed_oids = trim($infeed_oids); diff --git a/includes/discovery/current/xups.inc.php b/includes/discovery/current/xups.inc.php index 328ed9801..d6dff4d3f 100644 --- a/includes/discovery/current/xups.inc.php +++ b/includes/discovery/current/xups.inc.php @@ -5,9 +5,7 @@ if ($device['os'] == 'powerware') { echo 'XUPS-MIB '; $oids = snmp_walk($device, 'xupsBatCurrent', '-Osqn', 'XUPS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { @@ -28,9 +26,7 @@ if ($device['os'] == 'powerware') { } $oids = trim(snmp_walk($device, 'xupsOutputCurrent', '-OsqnU', 'XUPS-MIB')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { @@ -49,9 +45,7 @@ if ($device['os'] == 'powerware') { } $oids = trim(snmp_walk($device, 'xupsInputCurrent', '-OsqnU', 'XUPS-MIB')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { diff --git a/includes/discovery/discovery-protocols.inc.php b/includes/discovery/discovery-protocols.inc.php index 0e5d540f1..0afe43311 100644 --- a/includes/discovery/discovery-protocols.inc.php +++ b/includes/discovery/discovery-protocols.inc.php @@ -186,25 +186,19 @@ else { echo "disabled\n"; } -if ($debug) { - print_r($link_exists); -} +d_echo($link_exists); $sql = "SELECT * FROM `links` AS L, `ports` AS I WHERE L.local_port_id = I.port_id AND I.device_id = '".$device['device_id']."'"; foreach (dbFetchRows($sql) as $test) { $local_port_id = $test['local_port_id']; $remote_hostname = $test['remote_hostname']; $remote_port = $test['remote_port']; - if ($debug) { - echo "$local_port_id -> $remote_hostname -> $remote_port \n"; - } + d_echo("$local_port_id -> $remote_hostname -> $remote_port \n"); if (!$link_exists[$local_port_id][$remote_hostname][$remote_port]) { echo '-'; $rows = dbDelete('links', '`id` = ?', array($test['id'])); - if ($debug) { - echo "$rows deleted "; - } + d_echo("$rows deleted "); } } diff --git a/includes/discovery/fanspeeds.inc.php b/includes/discovery/fanspeeds.inc.php index 6ad629549..536232149 100644 --- a/includes/discovery/fanspeeds.inc.php +++ b/includes/discovery/fanspeeds.inc.php @@ -6,9 +6,7 @@ echo 'Fanspeeds : '; $include_dir = 'includes/discovery/fanspeeds'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['fanspeed']); -} +d_echo($valid['sensor']['fanspeed']); check_valid_sensors($device, 'fanspeed', $valid['sensor']); diff --git a/includes/discovery/fanspeeds/areca.inc.php b/includes/discovery/fanspeeds/areca.inc.php index 831cd78a5..cdb0fb791 100644 --- a/includes/discovery/fanspeeds/areca.inc.php +++ b/includes/discovery/fanspeeds/areca.inc.php @@ -3,9 +3,7 @@ // Areca Fanspeeds if ($device['os'] == 'areca') { $oids = snmp_walk($device, '1.3.6.1.4.1.18928.1.2.2.1.9.1.2', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo 'Areca '; diff --git a/includes/discovery/fanspeeds/dell.inc.php b/includes/discovery/fanspeeds/dell.inc.php index f1ee40d94..d1522a656 100644 --- a/includes/discovery/fanspeeds/dell.inc.php +++ b/includes/discovery/fanspeeds/dell.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'linux') { $oids = snmp_walk($device, 'coolingDevicechassisIndex.1', '-OsqnU', 'MIB-Dell-10892'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/fanspeeds/drac.inc.php b/includes/discovery/fanspeeds/drac.inc.php index 38b80c340..3d9e0bf41 100644 --- a/includes/discovery/fanspeeds/drac.inc.php +++ b/includes/discovery/fanspeeds/drac.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'drac') { $oids = snmp_walk($device, 'coolingDevicechassisIndex.1', '-OsqnU', 'IDRAC-MIB-SMIv2'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/fanspeeds/lmsensors.inc.php b/includes/discovery/fanspeeds/lmsensors.inc.php index a4aa7c6ca..8e288e73d 100644 --- a/includes/discovery/fanspeeds/lmsensors.inc.php +++ b/includes/discovery/fanspeeds/lmsensors.inc.php @@ -3,9 +3,7 @@ // LMSensors Fanspeeds if ($device['os'] == 'linux') { $oids = snmp_walk($device, 'lmFanSensorsDevice', '-OsqnU', 'LM-SENSORS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/fanspeeds/mikrotik.inc.php b/includes/discovery/fanspeeds/mikrotik.inc.php index 9908fdbf0..789769f7d 100644 --- a/includes/discovery/fanspeeds/mikrotik.inc.php +++ b/includes/discovery/fanspeeds/mikrotik.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'routeros') { $oids = snmp_walk($device, 'mtxrHlActiveFan', '-OsqnU', 'MIKROTIK-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids !== false) { echo 'MIKROTIK-MIB '; diff --git a/includes/discovery/fanspeeds/supermicro.inc.php b/includes/discovery/fanspeeds/supermicro.inc.php index be56aec02..c16eb1b09 100644 --- a/includes/discovery/fanspeeds/supermicro.inc.php +++ b/includes/discovery/fanspeeds/supermicro.inc.php @@ -3,9 +3,7 @@ // Supermicro Fanspeeds if ($device['os'] == 'linux') { $oids = snmp_walk($device, '1.3.6.1.4.1.10876.2.1.1.1.1.3', '-OsqnU', 'SUPERMICRO-HEALTH-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/frequencies.inc.php b/includes/discovery/frequencies.inc.php index 23b30b092..93fa17117 100644 --- a/includes/discovery/frequencies.inc.php +++ b/includes/discovery/frequencies.inc.php @@ -6,9 +6,7 @@ echo 'Frequencies: '; $include_dir = 'includes/discovery/frequencies'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['frequency']); -} +d_echo($valid['sensor']['frequency']); check_valid_sensors($device, 'frequency', $valid['sensor']); diff --git a/includes/discovery/frequencies/apc.inc.php b/includes/discovery/frequencies/apc.inc.php index cfb4d08ef..794fe5fc5 100644 --- a/includes/discovery/frequencies/apc.inc.php +++ b/includes/discovery/frequencies/apc.inc.php @@ -3,9 +3,7 @@ // APC if ($device['os'] == 'apc') { $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.8.5.3.2.1.4', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo 'APC In '; @@ -26,9 +24,7 @@ if ($device['os'] == 'apc') { } $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.8.5.4.2.1.4', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo ' APC Out '; @@ -53,9 +49,7 @@ if ($device['os'] == 'apc') { } $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.3.2.4.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo ' APC In '; @@ -68,9 +62,7 @@ if ($device['os'] == 'apc') { } $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.4.2.2.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo ' APC Out '; diff --git a/includes/discovery/frequencies/mgeups.inc.php b/includes/discovery/frequencies/mgeups.inc.php index 67a31218c..1815a30c6 100644 --- a/includes/discovery/frequencies/mgeups.inc.php +++ b/includes/discovery/frequencies/mgeups.inc.php @@ -4,9 +4,7 @@ if ($device['os'] == 'mgeups') { echo 'MGE '; $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.7.1', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $numPhase = count(explode("\n", $oids)); for ($i = 1; $i <= $numPhase; $i++) { @@ -30,9 +28,7 @@ if ($device['os'] == 'mgeups') { } $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.6.1', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $numPhase = count(explode("\n", $oids)); for ($i = 1; $i <= $numPhase; $i++) { diff --git a/includes/discovery/frequencies/rfc1628.inc.php b/includes/discovery/frequencies/rfc1628.inc.php index aeadbf3e6..707318154 100644 --- a/includes/discovery/frequencies/rfc1628.inc.php +++ b/includes/discovery/frequencies/rfc1628.inc.php @@ -5,9 +5,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul echo 'RFC1628 '; $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.3.2.0', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 512f39cff..dbe5d08dd 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -14,7 +14,7 @@ function discover_new_device($hostname, $device='', $method='', $interface='') { - global $config, $debug; + global $config; if (!empty($config['mydomain']) && isDomainResolves($hostname.'.'.$config['mydomain'])) { $dst_host = $hostname.'.'.$config['mydomain']; @@ -23,32 +23,24 @@ function discover_new_device($hostname, $device='', $method='', $interface='') { $dst_host = $hostname; } - if ($debug) { - echo "discovering $dst_host\n"; - } + d_echo("discovering $dst_host\n"); $ip = gethostbyname($dst_host); if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) { // $ip isn't a valid IP so it must be a name. if ($ip == $dst_host) { - if ($debug) { - echo "name lookup of $dst_host failed\n"; - } + d_echo("name lookup of $dst_host failed\n"); return false; } } - if ($debug) { - echo "ip lookup result: $ip\n"; - } + d_echo("ip lookup result: $ip\n"); $dst_host = rtrim($dst_host, '.'); // remove trailing dot if (match_network($config['autodiscovery']['nets-exclude'], $ip)) { - if ($debug) { - echo "$ip in an excluded network - skipping\n"; - } + d_echo("$ip in an excluded network - skipping\n"); return false; } @@ -77,9 +69,7 @@ function discover_new_device($hostname, $device='', $method='', $interface='') { } } else { - if ($debug) { - echo "$ip not in a matched network - skipping\n"; - } + d_echo("$ip not in a matched network - skipping\n"); }//end if }//end discover_new_device() @@ -161,11 +151,9 @@ function discover_device($device, $options=null) { function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor='1', $multiplier='1', $low_limit=null, $low_warn_limit=null, $warn_limit=null, $high_limit=null, $current=null, $poller_type='snmp', $entPhysicalIndex=null, $entPhysicalIndex_measured=null) { - global $config, $debug; + global $config; - if ($debug) { - echo "Discover sensor: $oid, $index, $type, $descr, $poller_type, $precision, $entPhysicalIndex\n"; - } + d_echo("Discover sensor: $oid, $index, $type, $descr, $poller_type, $precision, $entPhysicalIndex\n"); if (is_null($low_warn_limit) && !is_null($warn_limit)) { // Warn limits only make sense when we have both a high and a low limit @@ -218,9 +206,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $inserted = dbInsert($insert, 'sensors'); - if ($debug) { - echo "( $inserted inserted )\n"; - } + d_echo("( $inserted inserted )\n"); echo '+'; log_event('Sensor Added: '.mres($class).' '.mres($type).' '.mres($index).' '.mres($descr), $device, 'sensor', $inserted); @@ -258,9 +244,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, if ($high_limit != $sensor_entry['sensor_limit'] && $sensor_entry['sensor_custom'] == 'No') { $update = array('sensor_limit' => ($high_limit == null ? array('NULL') : $high_limit)); $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id'])); - if ($debug) { - echo "( $updated updated )\n"; - } + d_echo("( $updated updated )\n"); echo 'H'; log_event('Sensor High Limit Updated: '.mres($class).' '.mres($type).' '.mres($index).' '.mres($descr).' ('.$high_limit.')', $device, 'sensor', $sensor_id); @@ -269,9 +253,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, if ($sensor_entry['sensor_limit_low'] != $low_limit && $sensor_entry['sensor_custom'] == 'No') { $update = array('sensor_limit_low' => ($low_limit == null ? array('NULL') : $low_limit)); $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id'])); - if ($debug) { - echo "( $updated updated )\n"; - } + d_echo("( $updated updated )\n"); echo 'L'; log_event('Sensor Low Limit Updated: '.mres($class).' '.mres($type).' '.mres($index).' '.mres($descr).' ('.$low_limit.')', $device, 'sensor', $sensor_id); @@ -280,9 +262,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, if ($warn_limit != $sensor_entry['sensor_limit_warn'] && $sensor_entry['sensor_custom'] == 'No') { $update = array('sensor_limit_warn' => ($warn_limit == null ? array('NULL') : $warn_limit)); $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id'])); - if ($debug) { - echo "( $updated updated )\n"; - } + d_echo("( $updated updated )\n"); echo 'WH'; log_event('Sensor Warn High Limit Updated: '.mres($class).' '.mres($type).' '.mres($index).' '.mres($descr).' ('.$warn_limit.')', $device, 'sensor', $sensor_id); @@ -291,9 +271,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, if ($sensor_entry['sensor_limit_low_warn'] != $low_warn_limit && $sensor_entry['sensor_custom'] == 'No') { $update = array('sensor_limit_low_warn' => ($low_warn_limit == null ? array('NULL') : $low_warn_limit)); $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id'])); - if ($debug) { - echo "( $updated updated )\n"; - } + d_echo("( $updated updated )\n"); echo 'WL'; log_event('Sensor Warn Low Limit Updated: '.mres($class).' '.mres($type).' '.mres($index).' '.mres($descr).' ('.$low_warn_limit.')', $device, 'sensor', $sensor_id); @@ -314,9 +292,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id'])); echo 'U'; log_event('Sensor Updated: '.mres($class).' '.mres($type).' '.mres($index).' '.mres($descr), $device, 'sensor', $sensor_id); - if ($debug) { - echo "( $updated updated )\n"; - } + d_echo("( $updated updated )\n"); } }//end if $valid[$class][$type][$index] = 1; @@ -417,9 +393,7 @@ function check_valid_sensors($device, $class, $valid, $poller_type='snmp') { foreach ($entries as $entry) { $index = $entry['sensor_index']; $type = $entry['sensor_type']; - if ($debug) { - echo $index.' -> '.$type."\n"; - } + d_echo($index.' -> '.$type."\n"); if (!$valid[$class][$type][$index]) { echo '-'; @@ -436,13 +410,11 @@ function check_valid_sensors($device, $class, $valid, $poller_type='snmp') { function discover_juniAtmVp(&$valid, $port_id, $vp_id, $vp_descr) { - global $config, $debug; + global $config; if (dbFetchCell('SELECT COUNT(*) FROM `juniAtmVp` WHERE `port_id` = ? AND `vp_id` = ?', array($port_id, $vp_id)) == '0') { $inserted = dbInsert(array('port_id' => $port_id, 'vp_id' => $vp_id, 'vp_descr' => $vp_descr), 'juniAtmVp'); - if ($debug) { - echo "( $inserted inserted )\n"; - } + d_echo("( $inserted inserted )\n"); // FIXME vv no $device! log_event('Juniper ATM VP Added: port '.mres($port_id).' vp '.mres($vp_id).' descr'.mres($vp_descr), 'juniAtmVp', $inserted); @@ -457,7 +429,7 @@ function discover_juniAtmVp(&$valid, $port_id, $vp_id, $vp_descr) { function discover_link($local_port_id, $protocol, $remote_port_id, $remote_hostname, $remote_port, $remote_platform, $remote_version, $local_device_id, $remote_device_id) { - global $config, $debug, $link_exists; + global $config, $link_exists; d_echo("$local_port_id, $protocol, $remote_port_id, $remote_hostname, $remote_port, $remote_platform, $remote_version"); @@ -488,9 +460,7 @@ function discover_link($local_port_id, $protocol, $remote_port_id, $remote_hostn $inserted = dbInsert($insert_data, 'links'); echo '+'; - if ($debug) { - echo "( $inserted inserted )"; - } + d_echo("( $inserted inserted )"); } else { $data = dbFetchRow('SELECT * FROM `links` WHERE `remote_hostname` = ? AND `local_port_id` = ? AND `protocol` = ? AND `remote_port` = ?', array($remote_hostname, $local_port_id, $protocol, $remote_port)); @@ -512,9 +482,7 @@ function discover_link($local_port_id, $protocol, $remote_port_id, $remote_hostn $updated = dbUpdate($update_data, 'links', '`id` = ?', array($data['id'])); echo 'U'; - if ($debug) { - echo "( $updated updated )"; - } + d_echo("( $updated updated )"); }//end if }//end if $link_exists[$local_port_id][$remote_hostname][$remote_port] = 1; @@ -523,11 +491,9 @@ function discover_link($local_port_id, $protocol, $remote_port_id, $remote_hostn function discover_storage(&$valid, $device, $index, $type, $mib, $descr, $size, $units, $used=null) { - global $config, $debug; + global $config; - if ($debug) { - echo "$device, $index, $type, $mib, $descr, $units, $used, $size\n"; - } + d_echo("$device, $index, $type, $mib, $descr, $units, $used, $size\n"); if ($descr && $size > '0') { $storage = dbFetchRow('SELECT * FROM `storage` WHERE `storage_index` = ? AND `device_id` = ? AND `storage_mib` = ?', array($index, $device['device_id'], $mib)); @@ -565,11 +531,9 @@ function discover_storage(&$valid, $device, $index, $type, $mib, $descr, $size, function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $precision='1', $current=null, $entPhysicalIndex=null, $hrDeviceIndex=null) { - global $config, $debug; + global $config; - if ($debug) { - echo "$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"; - } + d_echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"); if ($descr) { $descr = trim(str_replace('"', '', $descr)); @@ -604,9 +568,7 @@ function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $prec 'processor_precision' => $precision, ); dbUpdate($update_data, 'processors', '`device_id`=? AND `processor_index`=? AND `processor_type`=?', array($device['device_id'], $index, $type)); - if ($debug) { - print $query."\n"; - } + d_echo($query."\n"); }//end if $valid[$type][$index] = 1; }//end if @@ -615,11 +577,9 @@ function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $prec function discover_mempool(&$valid, $device, $index, $type, $descr, $precision='1', $entPhysicalIndex=null, $hrDeviceIndex=null) { - global $config, $debug; + global $config; - if ($debug) { - echo "$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"; - } + d_echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"); // FIXME implement the mempool_perc, mempool_used, etc. if ($descr) { @@ -663,9 +623,7 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision='1 } dbUpdate($update_data, 'mempools', 'device_id=? AND mempool_index=? AND mempool_type=?', array($device['device_id'], $index, $type)); - if ($debug) { - print $query."\n"; - } + d_echo($query."\n"); }//end if $valid[$type][$index] = 1; }//end if @@ -674,11 +632,9 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision='1 function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity_oid=null, $capacity=null, $current=null) { - global $config, $debug; + global $config; - if ($debug) { - echo "$oid, $index, $type, $descr, $capacity, $capacity_oid\n"; - } + d_echo("$oid, $index, $type, $descr, $capacity, $capacity_oid\n"); if (dbFetchCell('SELECT COUNT(toner_id) FROM `toner` WHERE device_id = ? AND toner_type = ? AND `toner_index` = ? AND `toner_capacity_oid` =?', array($device['device_id'], $type, $index, $capacity_oid)) == '0') { $inserted = dbInsert(array('device_id' => $device['device_id'], 'toner_oid' => $oid, 'toner_capacity_oid' => $capacity_oid, 'toner_index' => $index, 'toner_type' => $type, 'toner_descr' => $descr, 'toner_capacity' => $capacity, 'toner_current' => $current), 'toner'); diff --git a/includes/discovery/hr-device.inc.php b/includes/discovery/hr-device.inc.php index aa168da8c..a00ddc887 100644 --- a/includes/discovery/hr-device.inc.php +++ b/includes/discovery/hr-device.inc.php @@ -6,18 +6,14 @@ $hrDevice_oids = array( 'hrDeviceEntry', 'hrProcessorEntry', ); -if ($debug) { - print_r($hrDevices); -} +d_echo($hrDevices); $hrDevices = array(); foreach ($hrDevice_oids as $oid) { $hrDevices = snmpwalk_cache_oid($device, $oid, $hrDevices, 'HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES'); } -if ($debug) { - print_r($hrDevices); -} +d_echo($hrDevices); if (is_array($hrDevices)) { $hrDevices = $hrDevices; @@ -40,10 +36,8 @@ if (is_array($hrDevices)) { else { $inserted_rows = dbInsert(array('hrDeviceIndex' => mres($hrDevice['hrDeviceIndex']), 'device_id' => mres($device['device_id']), 'hrDeviceType' => mres($hrDevice['hrDeviceType']), 'hrDeviceDescr' => mres($hrDevice['hrDeviceDescr']), 'hrDeviceStatus' => mres($hrDevice['hrDeviceStatus']), 'hrDeviceErrors' => (int) mres($hrDevice['hrDeviceErrors'])), 'hrDevice'); echo '+'; - if ($debug) { - print_r($hrDevice); - echo "$inserted_rows row inserted"; - } + d_echo($hrDevice); + d_echo("$inserted_rows row inserted"); }//end if $valid_hrDevice[$hrDevice['hrDeviceIndex']] = 1; @@ -57,9 +51,7 @@ foreach (dbFetchRows($sql) as $test_hrDevice) { if (!$valid_hrDevice[$test_hrDevice['hrDeviceIndex']]) { echo '-'; dbDelete('hrDevice', '`hrDevice_id` = ?', array($test_hrDevice['hrDevice_id'])); - if ($debug) { - print_r($test_hrDevice); - } + d_echo($test_hrDevice); } } diff --git a/includes/discovery/humidity.inc.php b/includes/discovery/humidity.inc.php index 69b3d9d97..d32be07e4 100644 --- a/includes/discovery/humidity.inc.php +++ b/includes/discovery/humidity.inc.php @@ -6,9 +6,7 @@ echo 'Humidity : '; $include_dir = 'includes/discovery/humidity'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['humidity']); -} +d_echo($valid['sensor']['humidity']); check_valid_sensors($device, 'humidity', $valid['sensor']); diff --git a/includes/discovery/humidity/akcp.inc.php b/includes/discovery/humidity/akcp.inc.php index 07dc0864c..d32406ba2 100644 --- a/includes/discovery/humidity/akcp.inc.php +++ b/includes/discovery/humidity/akcp.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'akcp' || $device['os'] == 'minkelsrms') { $oids = snmp_walk($device, '.1.3.6.1.4.1.3854.1.2.2.1.16.1.4', '-Osqn', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/humidity/mgeups.inc.php b/includes/discovery/humidity/mgeups.inc.php index 3d524d259..0f15b3c24 100644 --- a/includes/discovery/humidity/mgeups.inc.php +++ b/includes/discovery/humidity/mgeups.inc.php @@ -1,7 +1,5 @@ Sensor not available diff --git a/includes/discovery/humidity/netbotz.inc.php b/includes/discovery/humidity/netbotz.inc.php index e4dd44dab..e3f686fd9 100644 --- a/includes/discovery/humidity/netbotz.inc.php +++ b/includes/discovery/humidity/netbotz.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'netbotz') { $oids = snmp_walk($device, '.1.3.6.1.4.1.5528.100.4.1.2.1.4', '-Osqn', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/humidity/sentry3.inc.php b/includes/discovery/humidity/sentry3.inc.php index c3e4ff440..e1417993c 100644 --- a/includes/discovery/humidity/sentry3.inc.php +++ b/includes/discovery/humidity/sentry3.inc.php @@ -4,9 +4,7 @@ if ($device['os'] == 'sentry3') { $oids = snmp_walk($device, 'tempHumidSensorHumidValue', '-Osqn', 'Sentry3-MIB'); $divisor = '1'; $multiplier = '1'; - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/junose-atm-vp.inc.php b/includes/discovery/junose-atm-vp.inc.php index 53916e8dc..f65320fcc 100644 --- a/includes/discovery/junose-atm-vp.inc.php +++ b/includes/discovery/junose-atm-vp.inc.php @@ -7,9 +7,7 @@ if ($device['os'] == 'junose' && $config['enable_ports_junoseatmvp']) { echo 'JunOSe ATM vps : '; $vp_array = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsInCells', $vp_array, 'Juniper-UNI-ATM-MIB', $config['install_dir'].'/mibs/junose'); $valid_vp = array(); - if ($debug) { - print_r($vp_array); - } + d_echo($vp_array); if (is_array($vp_array)) { foreach ($vp_array as $index => $entry) { @@ -28,16 +26,12 @@ if ($device['os'] == 'junose' && $config['enable_ports_junoseatmvp']) { // Remove ATM vps which weren't redetected here $sql = "SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = '".$device['device_id']."' AND J.port_id = P.port_id"; - if ($debug) { - print_r($valid_vp); - } + d_echo($valid_vp); foreach (dbFetchRows($sql) as $test) { $port_id = $test['port_id']; $vp_id = $test['vp_id']; - if ($debug) { - echo $port_id.' -> '.$vp_id."\n"; - } + d_echo($port_id.' -> '.$vp_id."\n"); if (!$valid_vp[$port_id][$vp_id]) { echo '-'; diff --git a/includes/discovery/libvirt-vminfo.inc.php b/includes/discovery/libvirt-vminfo.inc.php index 38777b902..8825bf7b4 100644 --- a/includes/discovery/libvirt-vminfo.inc.php +++ b/includes/discovery/libvirt-vminfo.inc.php @@ -59,9 +59,7 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') { } $xml = simplexml_load_string(' '.$vm_info_xml); - if ($debug) { - print_r($xml); - } + d_echo($xml); $vmwVmDisplayName = $xml->name; $vmwVmGuestOS = ''; diff --git a/includes/discovery/load.inc.php b/includes/discovery/load.inc.php index aa28fe866..f09ae86e3 100644 --- a/includes/discovery/load.inc.php +++ b/includes/discovery/load.inc.php @@ -5,9 +5,7 @@ echo 'Load: '; $include_dir = 'includes/discovery/load'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['load']); -} +d_echo($valid['sensor']['load']); check_valid_sensors($device, 'load', $valid['sensor']); diff --git a/includes/discovery/load/apc.inc.php b/includes/discovery/load/apc.inc.php index 39927b59f..1d0c7ce5e 100644 --- a/includes/discovery/load/apc.inc.php +++ b/includes/discovery/load/apc.inc.php @@ -30,9 +30,7 @@ if ($device['os'] == 'apc') { } if (!empty($oids)) { - if ($debug) { - print_r($oids); - } + d_echo($oids); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/load/rfc1628.inc.php b/includes/discovery/load/rfc1628.inc.php index c11522f45..01f006782 100644 --- a/includes/discovery/load/rfc1628.inc.php +++ b/includes/discovery/load/rfc1628.inc.php @@ -5,9 +5,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul echo 'RFC1628 '; $oids = snmp_walk($device, '1.3.6.1.2.1.33.1.4.4.1.5', '-Osqn', 'UPS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { diff --git a/includes/discovery/mempools.inc.php b/includes/discovery/mempools.inc.php index 9435b0207..b865b9f43 100644 --- a/includes/discovery/mempools.inc.php +++ b/includes/discovery/mempools.inc.php @@ -9,16 +9,12 @@ require 'includes/include-dir.inc.php'; // Remove memory pools which weren't redetected here $sql = "SELECT * FROM `mempools` WHERE `device_id` = '".$device['device_id']."'"; -if ($debug) { - print_r($valid_mempool); -} +d_echo($valid_mempool); foreach (dbFetchRows($sql) as $test_mempool) { $mempool_index = $test_mempool['mempool_index']; $mempool_type = $test_mempool['mempool_type']; - if ($debug) { - echo $mempool_index.' -> '.$mempool_type."\n"; - } + d_echo($mempool_index.' -> '.$mempool_type."\n"); if (!$valid_mempool[$mempool_type][$mempool_index]) { echo '-'; diff --git a/includes/discovery/mempools/junos.inc.php b/includes/discovery/mempools/junos.inc.php index f3a30c139..2a9ed6bd2 100644 --- a/includes/discovery/mempools/junos.inc.php +++ b/includes/discovery/mempools/junos.inc.php @@ -7,9 +7,7 @@ if ($device['os'] == 'junos') { $mempools_array = snmpwalk_cache_multi_oid($device, 'jnxOperatingDRAMSize', $mempools_array, 'JUNIPER-MIB', $config['install_dir'].'/mibs/junos'); $mempools_array = snmpwalk_cache_multi_oid($device, 'jnxOperatingMemory', $mempools_array, 'JUNIPER-MIB', $config['install_dir'].'/mibs/junos'); $mempools_array = snmpwalk_cache_multi_oid($device, 'jnxOperatingDescr', $mempools_array, 'JUNIPER-MIB', $config['install_dir'].'/mibs/junos'); - if ($debug) { - print_r($mempools_array); - } + d_echo($mempools_array); if (is_array($mempools_array)) { foreach ($mempools_array as $index => $entry) { @@ -18,9 +16,7 @@ if ($device['os'] == 'junos') { continue; } - if ($debug) { - echo $index.' '.$entry['jnxOperatingDescr'].' -> '.$entry['jnxOperatingBuffer'].' -> '.$entry['jnxOperatingDRAMSize']."\n"; - } + d_echo($index.' '.$entry['jnxOperatingDescr'].' -> '.$entry['jnxOperatingBuffer'].' -> '.$entry['jnxOperatingDRAMSize']."\n"); $usage_oid = '.1.3.6.1.4.1.2636.3.1.13.1.8.'.$index; $descr = $entry['jnxOperatingDescr']; diff --git a/includes/discovery/mempools/vrp.inc.php b/includes/discovery/mempools/vrp.inc.php index 180514368..ca06a851e 100644 --- a/includes/discovery/mempools/vrp.inc.php +++ b/includes/discovery/mempools/vrp.inc.php @@ -6,16 +6,12 @@ if ($device['os'] == 'vrp') { $mempools_array = snmpwalk_cache_multi_oid($device, 'hwEntityMemUsage', $mempools_array, 'HUAWEI-ENTITY-EXTENT-MIB', $config['install_dir'].'/mibs'); $mempools_array = snmpwalk_cache_multi_oid($device, 'hwEntityMemSize', $mempools_array, 'HUAWEI-ENTITY-EXTENT-MIB', $config['install_dir'].'/mibs'); $mempools_array = snmpwalk_cache_multi_oid($device, 'hwEntityBomEnDesc', $mempools_array, 'HUAWEI-ENTITY-EXTENT-MIB', $config['install_dir'].'/mibs'); - if ($debug) { - print_r($mempools_array); - } + d_echo($mempools_array); if (is_array($mempools_array)) { foreach ($mempools_array as $index => $entry) { if ($entry['hwEntityMemSize'] != 0) { - if ($debug) { - echo $index.' '.$entry['hwEntityBomEnDesc'].' -> '.$entry['hwEntityMemUsage'].' -> '.$entry['hwEntityMemSize']."\n"; - } + d_echo($index.' '.$entry['hwEntityBomEnDesc'].' -> '.$entry['hwEntityMemUsage'].' -> '.$entry['hwEntityMemSize']."\n"); $usage_oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.1.1.7.'.$index; $descr = $entry['hwEntityBomEnDesc']; diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index 3a8a2eb60..32067fa05 100644 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -7,9 +7,7 @@ $port_stats = snmpwalk_cache_oid($device, 'ifName', $port_stats, 'IF-MIB'); $port_stats = snmpwalk_cache_oid($device, 'ifType', $port_stats, 'IF-MIB'); // End Building SNMP Cache Array -if ($debug) { - print_r($port_stats); -} +d_echo($port_stats); // Build array of ports in the database // FIXME -- this stuff is a little messy, looping the array to make an array just seems wrong. :> diff --git a/includes/discovery/power.inc.php b/includes/discovery/power.inc.php index 2161e5ec2..d204c4b5c 100644 --- a/includes/discovery/power.inc.php +++ b/includes/discovery/power.inc.php @@ -6,9 +6,7 @@ echo 'Power: '; $include_dir = 'includes/discovery/power'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['power']); -} +d_echo($valid['sensor']['power']); check_valid_sensors($device, 'power', $valid['sensor']); diff --git a/includes/discovery/power/rfc1628.inc.php b/includes/discovery/power/rfc1628.inc.php index 8816ff9b4..adaa5c918 100644 --- a/includes/discovery/power/rfc1628.inc.php +++ b/includes/discovery/power/rfc1628.inc.php @@ -5,9 +5,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul echo("RFC1628 "); $oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.4.3.0", "-OsqnU")); - if ($debug) { - echo($oids."\n"); - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ',$oids); for($i = 1; $i <= $numPhase;$i++) { $current_oid = ".1.3.6.1.2.1.33.1.4.4.1.4.$i"; @@ -22,9 +20,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.3.2.0", "-OsqnU")); - if ($debug) { - echo($oids."\n"); - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ',$oids); for($i = 1; $i <= $numPhase;$i++) { $current_oid = "1.3.6.1.2.1.33.1.3.3.1.5.$i"; @@ -39,9 +35,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.5.2.0", "-OsqnU")); - if ($debug) { - echo($oids."\n"); - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ',$oids); for($i = 1; $i <= $numPhase;$i++) { $current_oid = ".1.3.6.1.2.1.33.1.5.3.1.4.$i"; diff --git a/includes/discovery/processors.inc.php b/includes/discovery/processors.inc.php index 3d0eb0cb4..c09501598 100644 --- a/includes/discovery/processors.inc.php +++ b/includes/discovery/processors.inc.php @@ -12,16 +12,12 @@ require 'processors-ucd-old.inc.php'; // Remove processors which weren't redetected here $sql = "SELECT * FROM `processors` WHERE `device_id` = '".$device['device_id']."'"; -if ($debug) { - print_r($valid['processor']); -} +d_echo($valid['processor']); foreach (dbFetchRows($sql) as $test_processor) { $processor_index = $test_processor['processor_index']; $processor_type = $test_processor['processor_type']; - if ($debug) { - echo $processor_index.' -> '.$processor_type."\n"; - } + d_echo($processor_index.' -> '.$processor_type."\n"); if (!$valid['processor'][$processor_type][$processor_index]) { echo '-'; diff --git a/includes/discovery/processors/hrdevice.inc.php b/includes/discovery/processors/hrdevice.inc.php index 2f6c152b7..97d021745 100644 --- a/includes/discovery/processors/hrdevice.inc.php +++ b/includes/discovery/processors/hrdevice.inc.php @@ -60,9 +60,7 @@ if (is_array($hrDevice_array)) { $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"; - } + d_echo("$old_rrd $new_rrd"); if (is_file($old_rrd)) { rename($old_rrd, $new_rrd); diff --git a/includes/discovery/processors/ios.inc.php b/includes/discovery/processors/ios.inc.php index 36a18493f..4bcaa0ffa 100644 --- a/includes/discovery/processors/ios.inc.php +++ b/includes/discovery/processors/ios.inc.php @@ -3,9 +3,7 @@ if ($device['os_group'] == 'cisco' || $device['os'] == 'acsw') { echo 'CISCO-PROCESS-MIB: '; $processors_array = snmpwalk_cache_oid($device, 'cpmCPU', null, 'CISCO-PROCESS-MIB'); - if ($debug) { - print_r($processors_array); - } + d_echo($processors_array); foreach ($processors_array as $index => $entry) { if (is_numeric($entry['cpmCPUTotal5minRev']) || is_numeric($entry['cpmCPUTotal5min'])) { @@ -34,9 +32,7 @@ if ($device['os_group'] == 'cisco' || $device['os'] == 'acsw') { if (is_file($old_rrd)) { rename($old_rrd, $new_rrd); - if ($debug) { - echo "$old_rrd $new_rrd"; - } + d_echo("$old_rrd $new_rrd"); echo 'Moved RRD '; } diff --git a/includes/discovery/processors/ironware.inc.php b/includes/discovery/processors/ironware.inc.php index b3f995c87..7acb763d7 100644 --- a/includes/discovery/processors/ironware.inc.php +++ b/includes/discovery/processors/ironware.inc.php @@ -3,9 +3,7 @@ if ($device['os'] == 'ironware' || $device['os_group'] == 'ironware') { echo 'IronWare : '; $processors_array = snmpwalk_cache_triple_oid($device, 'snAgentCpuUtilEntry', $processors_array, 'FOUNDRY-SN-AGENT-MIB'); - if ($debug) { - print_r($processors_array); - } + d_echo($processors_array); foreach ($processors_array as $index => $entry) { if (($entry['snAgentCpuUtilValue'] || $entry['snAgentCpuUtil100thPercent']) && $entry['snAgentCpuUtilInterval'] == '300') { diff --git a/includes/discovery/processors/junos.inc.php b/includes/discovery/processors/junos.inc.php index d15c898f6..c66785ddc 100644 --- a/includes/discovery/processors/junos.inc.php +++ b/includes/discovery/processors/junos.inc.php @@ -7,9 +7,7 @@ if ($device['os'] == 'junos') { $processors_array = snmpwalk_cache_multi_oid($device, 'jnxOperatingDRAMSize', $processors_array, 'JUNIPER-MIB', '+'.$config['install_dir'].'/mibs/junos'); $processors_array = snmpwalk_cache_multi_oid($device, 'jnxOperatingMemory', $processors_array, 'JUNIPER-MIB', '+'.$config['install_dir'].'/mibs/junos'); $processors_array = snmpwalk_cache_multi_oid($device, 'jnxOperatingDescr', $processors_array, 'JUNIPER-MIB', '+'.$config['install_dir'].'/mibs/junos'); - if ($debug) { - print_r($processors_array); - } + d_echo($processors_array); if (is_array($processors_array)) { foreach ($processors_array as $index => $entry) { @@ -18,9 +16,7 @@ if ($device['os'] == 'junos') { continue; } - if ($debug) { - echo $index.' '.$entry['jnxOperatingDescr'].' -> '.$entry['jnxOperatingCPU'].' -> '.$entry['jnxOperatingDRAMSize']."\n"; - } + d_echo($index.' '.$entry['jnxOperatingDescr'].' -> '.$entry['jnxOperatingCPU'].' -> '.$entry['jnxOperatingDRAMSize']."\n"); $usage_oid = '.1.3.6.1.4.1.2636.3.1.13.1.8.'.$index; $descr = $entry['jnxOperatingDescr']; @@ -33,9 +29,7 @@ if ($device['os'] == 'junos') { } $srx_processors_array = snmpwalk_cache_multi_oid($device, 'jnxJsSPUMonitoringCPUUsage', $srx_processors_array, 'JUNIPER-SRX5000-SPU-MONITORING-MIB', '+'.$config['install_dir'].'/mibs/junos'); - if ($debug) { - print_r($processors_array); - } + d_echo($processors_array); if (is_array($srx_processors_array)) { foreach ($srx_processors_array as $index => $entry) { diff --git a/includes/discovery/processors/junose.inc.php b/includes/discovery/processors/junose.inc.php index 81fd03247..a0c997607 100644 --- a/includes/discovery/processors/junose.inc.php +++ b/includes/discovery/processors/junose.inc.php @@ -4,9 +4,7 @@ if ($device['os'] == 'junose') { echo 'JUNOSe : '; $processors_array = snmpwalk_cache_double_oid($device, 'juniSystemModule', $processors_array, 'Juniper-System-MIB', $config['install_dir'].'/mibs/junose'); - if ($debug) { - print_r($processors_array); - } + d_echo($processors_array); foreach ($processors_array as $index => $entry) { if ($entry['juniSystemModuleCpuUtilPct'] && $entry['juniSystemModuleCpuUtilPct'] != '-1') { diff --git a/includes/discovery/processors/vrp.inc.php b/includes/discovery/processors/vrp.inc.php index c8a17126b..3cdbcdf2e 100644 --- a/includes/discovery/processors/vrp.inc.php +++ b/includes/discovery/processors/vrp.inc.php @@ -6,16 +6,12 @@ if ($device['os'] == 'vrp') { $processors_array = snmpwalk_cache_multi_oid($device, 'hwEntityCpuUsage', $processors_array, 'HUAWEI-ENTITY-EXTENT-MIB', '+'.$config['install_dir'].'/mibs'); $processors_array = snmpwalk_cache_multi_oid($device, 'hwEntityMemSize', $processors_array, 'HUAWEI-ENTITY-EXTENT-MIB', '+'.$config['install_dir'].'/mibs'); $processors_array = snmpwalk_cache_multi_oid($device, 'hwEntityBomEnDesc', $processors_array, 'HUAWEI-ENTITY-EXTENT-MIB', '+'.$config['install_dir'].'/mibs'); - if ($debug) { - print_r($processors_array); - } + d_echo($processors_array); if (is_array($processors_array)) { foreach ($processors_array as $index => $entry) { if ($entry['hwEntityMemSize'] != 0) { - if ($debug) { - echo $index.' '.$entry['hwEntityBomEnDesc'].' -> '.$entry['hwEntityCpuUsage'].' -> '.$entry['hwEntityMemSize']."\n"; - } + d_echo($index.' '.$entry['hwEntityBomEnDesc'].' -> '.$entry['hwEntityCpuUsage'].' -> '.$entry['hwEntityMemSize']."\n"); $usage_oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.1.1.5.'.$index; $descr = $entry['hwEntityBomEnDesc']; diff --git a/includes/discovery/states.inc.php b/includes/discovery/states.inc.php index 12a07296b..2eb1c740e 100644 --- a/includes/discovery/states.inc.php +++ b/includes/discovery/states.inc.php @@ -17,9 +17,7 @@ echo 'States: '; $include_dir = 'includes/discovery/states'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['states']); -} +d_echo($valid['sensor']['states']); check_valid_sensors($device, 'states', $valid['sensor']); diff --git a/includes/discovery/states/dell.inc.php b/includes/discovery/states/dell.inc.php index c5c070a74..b8dca50df 100644 --- a/includes/discovery/states/dell.inc.php +++ b/includes/discovery/states/dell.inc.php @@ -15,9 +15,7 @@ if ($device['os'] == 'linux') { $oids = snmp_walk($device, 'virtualDiskNumber', '-Oesqn', 'StorageManagement-MIB'); $main_oid = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.'; - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/states/drac.inc.php b/includes/discovery/states/drac.inc.php index 099599108..5e4c5eba8 100644 --- a/includes/discovery/states/drac.inc.php +++ b/includes/discovery/states/drac.inc.php @@ -15,9 +15,7 @@ if ($device['os'] == "drac") { $oids = snmp_walk($device, "virtualDiskNumber", "-Oesqn", "IDRAC-MIB-SMIv2"); $main_oid = ".1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1."; - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { echo "Dell iDRAC"; diff --git a/includes/discovery/states/rfc1628.inc.php b/includes/discovery/states/rfc1628.inc.php index 0a8a482fd..0dd8e6a14 100644 --- a/includes/discovery/states/rfc1628.inc.php +++ b/includes/discovery/states/rfc1628.inc.php @@ -5,9 +5,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul echo 'RFC1628 '; $oids = snmp_walk($device, '1.3.6.1.2.1.33.1.2.2', '-Osqn', 'UPS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { @@ -27,9 +25,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = snmp_walk($device, '1.3.6.1.2.1.33.1.2.3', '-Osqn', 'UPS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { diff --git a/includes/discovery/storage.inc.php b/includes/discovery/storage.inc.php index b8b8fd7e3..d04817c9b 100644 --- a/includes/discovery/storage.inc.php +++ b/includes/discovery/storage.inc.php @@ -9,16 +9,12 @@ require 'includes/include-dir.inc.php'; // Remove storage which weren't redetected here $sql = "SELECT * FROM `storage` WHERE `device_id` = '".$device['device_id']."'"; -if ($debug) { - print_r($valid_storage); -} +d_echo($valid_storage); foreach (dbFetchRows($sql) as $test_storage) { $storage_index = $test_storage['storage_index']; $storage_mib = $test_storage['storage_mib']; - if ($debug) { - echo $storage_index.' -> '.$storage_mib."\n"; - } + d_echo($storage_index.' -> '.$storage_mib."\n"); if (!$valid_storage[$storage_mib][$storage_index]) { echo '-'; diff --git a/includes/discovery/storage/hrstorage.inc.php b/includes/discovery/storage/hrstorage.inc.php index f32a48faa..46907e10a 100644 --- a/includes/discovery/storage/hrstorage.inc.php +++ b/includes/discovery/storage/hrstorage.inc.php @@ -36,49 +36,37 @@ if (is_array($hrstorage_array)) { foreach ($config['ignore_mount'] as $bi) { if ($bi == $descr) { $deny = 1; - if ($debug) { - echo "$bi == $descr \n"; - } + d_echo("$bi == $descr \n"); } } foreach ($config['ignore_mount_string'] as $bi) { if (strpos($descr, $bi) !== false) { $deny = 1; - if ($debug) { - echo "strpos: $descr, $bi \n"; - } + d_echo("strpos: $descr, $bi \n"); } } foreach ($config['ignore_mount_regexp'] as $bi) { if (preg_match($bi, $descr) > '0') { $deny = 1; - if ($debug) { - echo "preg_match $bi, $descr \n"; - } + d_echo("preg_match $bi, $descr \n"); } } if (isset($config['ignore_mount_removable']) && $config['ignore_mount_removable'] && $fstype == 'hrStorageRemovableDisk') { $deny = 1; - if ($debug) { - echo "skip(removable)\n"; - } + d_echo("skip(removable)\n"); } if (isset($config['ignore_mount_network']) && $config['ignore_mount_network'] && $fstype == 'hrStorageNetworkDisk') { $deny = 1; - if ($debug) { - echo "skip(network)\n"; - } + d_echo("skip(network)\n"); } if (isset($config['ignore_mount_optical']) && $config['ignore_mount_optical'] && $fstype == 'hrStorageCompactDisc') { $deny = 1; - if ($debug) { - echo "skip(cd)\n"; - } + d_echo("skip(cd)\n"); } if (!$deny && is_numeric($index)) { diff --git a/includes/discovery/storage/netapp-storage.inc.php b/includes/discovery/storage/netapp-storage.inc.php index 83709c07f..49cd0d803 100644 --- a/includes/discovery/storage/netapp-storage.inc.php +++ b/includes/discovery/storage/netapp-storage.inc.php @@ -20,27 +20,21 @@ if (is_array($netapp_storage)) { foreach ($config['ignore_mount'] as $bi) { if ($bi == $descr) { $deny = 1; - if ($debug) { - echo "$bi == $descr \n"; - } + d_echo("$bi == $descr \n"); } } foreach ($config['ignore_mount_string'] as $bi) { if (strpos($descr, $bi) !== false) { $deny = 1; - if ($debug) { - echo "strpos: $descr, $bi \n"; - } + d_echo("strpos: $descr, $bi \n"); } } foreach ($config['ignore_mount_regexp'] as $bi) { if (preg_match($bi, $descr) > '0') { $deny = 1; - if ($debug) { - echo "preg_match $bi, $descr \n"; - } + d_echo("preg_match $bi, $descr \n"); } } diff --git a/includes/discovery/temperatures.inc.php b/includes/discovery/temperatures.inc.php index 25f385500..60e01b0ba 100644 --- a/includes/discovery/temperatures.inc.php +++ b/includes/discovery/temperatures.inc.php @@ -6,9 +6,7 @@ echo 'Temperatures: '; $include_dir = 'includes/discovery/temperatures'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['temperature']); -} +d_echo($valid['sensor']['temperature']); check_valid_sensors($device, 'temperature', $valid['sensor']); diff --git a/includes/discovery/temperatures/akcp.inc.php b/includes/discovery/temperatures/akcp.inc.php index 76602e418..b60e9ab87 100644 --- a/includes/discovery/temperatures/akcp.inc.php +++ b/includes/discovery/temperatures/akcp.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'akcp' || $device['os'] == 'minkelsrms') { $oids = snmp_walk($device, '.1.3.6.1.4.1.3854.1.2.2.1.16.1.4', '-Osqn', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/temperatures/apc.inc.php b/includes/discovery/temperatures/apc.inc.php index 93aa89dd9..4c7d53cc9 100644 --- a/includes/discovery/temperatures/apc.inc.php +++ b/includes/discovery/temperatures/apc.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'apc') { $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.2.2.2.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo 'APC UPS Internal '; @@ -77,10 +75,8 @@ if ($device['os'] == 'apc') { $set_oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.13.2.2.4.0', '-OsqnU', ''); $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.13.2.2.10.0', '-OsqnU', ''); - if ($debug) { - echo $set_oids."\n"; - echo $oids."\n"; - } + d_echo($oids."\n"); + d_echo($set_oids."\n"); if ($oids !== false) { echo 'APC Portable Supply Temp '; @@ -103,9 +99,7 @@ if ($device['os'] == 'apc') { unset($oids); $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.13.2.2.12.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids !== false) { echo 'APC Portable Return Temp '; @@ -128,10 +122,7 @@ if ($device['os'] == 'apc') { unset($oids); $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.13.2.2.14.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } - + d_echo($oids."\n"); if ($oids !== false) { echo 'APC Portable Remote Temp '; list($oid,$current_raw) = explode(' ', $oids); diff --git a/includes/discovery/temperatures/areca.inc.php b/includes/discovery/temperatures/areca.inc.php index beffb9dd4..a286ad62f 100644 --- a/includes/discovery/temperatures/areca.inc.php +++ b/includes/discovery/temperatures/areca.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'areca') { $oids = snmp_walk($device, '1.3.6.1.4.1.18928.1.1.2.14.1.2', '-Osqn', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { @@ -29,9 +27,7 @@ if ($device['os'] == 'areca') { } $oids = snmp_walk($device, '1.3.6.1.4.1.18928.1.2.2.1.10.1.2', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo 'Areca Controller '; diff --git a/includes/discovery/temperatures/cometsystem-p85xx.inc.php b/includes/discovery/temperatures/cometsystem-p85xx.inc.php index 4049e00fb..28e8f0908 100644 --- a/includes/discovery/temperatures/cometsystem-p85xx.inc.php +++ b/includes/discovery/temperatures/cometsystem-p85xx.inc.php @@ -14,7 +14,6 @@ if ($device['os'] == 'cometsystem-p85xx') { /x'; $oids = snmp_walk($device, '.1.3.6.1.4.1.22626.1.5.2', '-OsqnU', ''); - // if ($debug) { echo($oids."\n"); } if ($oids) { $out = array(); foreach (explode("\n", $oids) as $line) { diff --git a/includes/discovery/temperatures/dell.inc.php b/includes/discovery/temperatures/dell.inc.php index acddb2cbc..dcf6a3b9c 100644 --- a/includes/discovery/temperatures/dell.inc.php +++ b/includes/discovery/temperatures/dell.inc.php @@ -27,9 +27,7 @@ if (strstr($device['hardware'], 'Dell')) { // stuff partially copied from akcp sensor $oids = snmp_walk($device, 'temperatureProbeStatus', '-Osqn', 'MIB-Dell-10892'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { @@ -40,9 +38,7 @@ if (strstr($device['hardware'], 'Dell')) { $data = trim($data); if ($data) { list($oid,$status) = explode(' ', $data, 2); - if ($debug) { - echo 'status : '.$status."\n"; - } + d_echo('status : '.$status."\n"); if ($status == 'ok') { // 2 = normal, 0 = not connected diff --git a/includes/discovery/temperatures/drac.inc.php b/includes/discovery/temperatures/drac.inc.php index 1edc63b53..3687db6c9 100644 --- a/includes/discovery/temperatures/drac.inc.php +++ b/includes/discovery/temperatures/drac.inc.php @@ -13,9 +13,7 @@ if (strstr($device['os'], 'drac')) { $oids = snmp_walk($device, 'temperatureProbeStatus', '-Osqn', 'IDRAC-MIB-SMIv2'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { @@ -26,9 +24,7 @@ if (strstr($device['os'], 'drac')) { $data = trim($data); if ($data) { list($oid,$status) = explode(' ', $data, 2); - if ($debug) { - echo 'status : '.$status."\n"; - } + d_echo('status : '.$status."\n"); if ($status == 'ok') { $split_oid = explode('.', $oid); diff --git a/includes/discovery/temperatures/lm-sensors.inc.php b/includes/discovery/temperatures/lm-sensors.inc.php index 1df73f023..1482b356c 100644 --- a/includes/discovery/temperatures/lm-sensors.inc.php +++ b/includes/discovery/temperatures/lm-sensors.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'linux') { $oids = snmp_walk($device, 'lmTempSensorsDevice', '-Osqn', 'LM-SENSORS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/temperatures/mgeups.inc.php b/includes/discovery/temperatures/mgeups.inc.php index 269664697..4c6e7a478 100644 --- a/includes/discovery/temperatures/mgeups.inc.php +++ b/includes/discovery/temperatures/mgeups.inc.php @@ -1,7 +1,5 @@ $entry) { if ($entry['diskIONRead'] > '0' || $entry['diskIONWritten'] > '0') { - if ($debug) { - echo "$index ".$entry['diskIODevice']."\n"; - } + d_echo("$index ".$entry['diskIODevice']."\n"); if (dbFetchCell('SELECT COUNT(*) FROM `ucd_diskio` WHERE `device_id` = ? AND `diskio_index` = ?', array($device['device_id'], $index)) == '0') { $inserted = dbInsert(array('device_id' => $device['device_id'], 'diskio_index' => $index, 'diskio_descr' => $entry['diskIODevice']), 'ucd_diskio'); echo '+'; - if ($debug) { - echo $sql." - $inserted inserted "; - } + d_echo($sql." - $inserted inserted "); } else { echo '.'; @@ -31,14 +26,10 @@ if (is_array($diskio_array)) { // Remove diskio entries which weren't redetected here $sql = "SELECT * FROM `ucd_diskio` where `device_id` = '".$device['device_id']."'"; -if ($debug) { - print_r($valid_diskio); -} +d_echo($valid_diskio); foreach (dbFetchRows($sql) as $test) { - if ($debug) { - echo $test['diskio_index'].' -> '.$test['diskio_descr']."\n"; - } + d_echo($test['diskio_index'].' -> '.$test['diskio_descr']."\n"); if (!$valid_diskio[$test['diskio_index']]) { echo '-'; diff --git a/includes/discovery/voltages.inc.php b/includes/discovery/voltages.inc.php index d91fe5d4e..5ce7b438d 100644 --- a/includes/discovery/voltages.inc.php +++ b/includes/discovery/voltages.inc.php @@ -6,9 +6,7 @@ echo 'Voltages: '; $include_dir = 'includes/discovery/voltages'; require 'includes/include-dir.inc.php'; -if ($debug) { - print_r($valid['sensor']['voltage']); -} +d_echo($valid['sensor']['voltage']); check_valid_sensors($device, 'voltage', $valid['sensor']); diff --git a/includes/discovery/voltages/apc.inc.php b/includes/discovery/voltages/apc.inc.php index b309d21fb..a45b7027a 100644 --- a/includes/discovery/voltages/apc.inc.php +++ b/includes/discovery/voltages/apc.inc.php @@ -3,9 +3,7 @@ // APC Voltages if ($device['os'] == 'apc') { $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.8.5.3.3.1.3', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo 'APC In '; @@ -27,9 +25,7 @@ if ($device['os'] == 'apc') { } $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.8.5.4.3.1.3', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo ' APC Out '; @@ -54,9 +50,7 @@ if ($device['os'] == 'apc') { } $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.3.2.1.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo ' APC In '; @@ -70,9 +64,7 @@ if ($device['os'] == 'apc') { } $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.4.2.1.0', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo ' APC Out '; @@ -88,9 +80,7 @@ if ($device['os'] == 'apc') { // PDU // $oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.12.1.15.0", "-OsqnU", ""); $oids = snmp_walk($device, 'rPDUIdentDeviceLinetoLineVoltage.0', '-OsqnU', 'PowerNet-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo ' Voltage In '; @@ -104,9 +94,7 @@ if ($device['os'] == 'apc') { } $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.26.6.3.1.6', '-OsqnU', 'PowerNet-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo ' Voltage In '; diff --git a/includes/discovery/voltages/areca.inc.php b/includes/discovery/voltages/areca.inc.php index 258203a80..0958f3b50 100644 --- a/includes/discovery/voltages/areca.inc.php +++ b/includes/discovery/voltages/areca.inc.php @@ -3,9 +3,7 @@ // Areca Voltages if ($device['os'] == 'areca') { $oids = snmp_walk($device, '1.3.6.1.4.1.18928.1.2.2.1.8.1.2', '-OsqnU', ''); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo 'Areca '; diff --git a/includes/discovery/voltages/drac.inc.php b/includes/discovery/voltages/drac.inc.php index e94ce8f02..f009a74cb 100644 --- a/includes/discovery/voltages/drac.inc.php +++ b/includes/discovery/voltages/drac.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == "drac") { $oids = snmp_walk($device, "powerSupplyIndex.1", "-OsqnU", "IDRAC-MIB-SMIv2"); - if ($debug) { - echo($oids."\n"); - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { echo("Dell iDRAC"); diff --git a/includes/discovery/voltages/linux.inc.php b/includes/discovery/voltages/linux.inc.php index f599f02ee..061594ede 100644 --- a/includes/discovery/voltages/linux.inc.php +++ b/includes/discovery/voltages/linux.inc.php @@ -3,9 +3,7 @@ // LMSensors Voltages if ($device['os'] == 'linux') { $oids = snmp_walk($device, 'lmVoltSensorsDevice', '-OsqnU', 'LM-SENSORS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo 'LM-SENSORS '; diff --git a/includes/discovery/voltages/mgeups.inc.php b/includes/discovery/voltages/mgeups.inc.php index 6e715b995..b31cba73c 100644 --- a/includes/discovery/voltages/mgeups.inc.php +++ b/includes/discovery/voltages/mgeups.inc.php @@ -4,9 +4,7 @@ if ($device['os'] == 'mgeups') { echo 'MGE '; $oids = trim(snmp_walk($device, 'mgoutputVoltage', '-OsqnU', 'MG-SNMP-UPS-MIB')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $numPhase = count(explode("\n", $oids)); for ($i = 1; $i <= $numPhase; $i++) { @@ -31,9 +29,7 @@ if ($device['os'] == 'mgeups') { } $oids = trim(snmp_walk($device, 'mgeinputVoltage', '-OsqnU', 'MG-SNMP-UPS-MIB')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $numPhase = count(explode("\n", $oids)); for ($i = 1; $i <= $numPhase; $i++) { diff --git a/includes/discovery/voltages/mikrotik.inc.php b/includes/discovery/voltages/mikrotik.inc.php index 23bff12ad..0127469e0 100644 --- a/includes/discovery/voltages/mikrotik.inc.php +++ b/includes/discovery/voltages/mikrotik.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == "routeros") { $oids = snmp_walk($device, "mtxrHlVoltage", "-OsqnU", "MIKROTIK-MIB"); - if ($debug) { - echo($oids."\n"); - } + d_echo($oids."\n"); if ($oids !== false) echo("MIKROTIK-MIB "); $divisor = 10.0; $type = "mikrotik"; diff --git a/includes/discovery/voltages/rfc1628.inc.php b/includes/discovery/voltages/rfc1628.inc.php index 4c1f654d6..a89efbbd1 100644 --- a/includes/discovery/voltages/rfc1628.inc.php +++ b/includes/discovery/voltages/rfc1628.inc.php @@ -5,9 +5,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul echo 'RFC1628 '; $oids = snmp_walk($device, '1.3.6.1.2.1.33.1.2.5', '-Osqn', 'UPS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { @@ -31,9 +29,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.4.3.0', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { @@ -55,9 +51,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.3.2.0', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { @@ -79,9 +73,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul } $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.5.2.0', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { diff --git a/includes/discovery/voltages/sentry3.inc.php b/includes/discovery/voltages/sentry3.inc.php index e2d704322..7ccebb3e7 100644 --- a/includes/discovery/voltages/sentry3.inc.php +++ b/includes/discovery/voltages/sentry3.inc.php @@ -2,9 +2,7 @@ if ($device['os'] == 'sentry3') { $oids = snmp_walk($device, 'infeedVoltage', '-OsqnU', 'Sentry3-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if ($oids) { echo 'Sentry3-MIB '; diff --git a/includes/discovery/voltages/siklu.inc.php b/includes/discovery/voltages/siklu.inc.php index 867d0bd30..c80b2e75d 100644 --- a/includes/discovery/voltages/siklu.inc.php +++ b/includes/discovery/voltages/siklu.inc.php @@ -3,9 +3,7 @@ if ($device['os'] == 'siklu') { $oid = 'rbSysVoltage.0'; $oids = snmp_walk($device, "$oid", '-OsqnU', 'RADIO-BRIDGE-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); if (!empty($oids)) { echo 'Siklu Voltage '; diff --git a/includes/discovery/voltages/supermicro.inc.php b/includes/discovery/voltages/supermicro.inc.php index 690d34747..21fc75f8a 100644 --- a/includes/discovery/voltages/supermicro.inc.php +++ b/includes/discovery/voltages/supermicro.inc.php @@ -3,9 +3,7 @@ // Supermicro Voltages if ($device['os'] == 'linux') { $oids = snmp_walk($device, '1.3.6.1.4.1.10876.2.1.1.1.1.3', '-OsqnU', 'SUPERMICRO-HEALTH-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); if ($oids) { diff --git a/includes/discovery/voltages/xups.inc.php b/includes/discovery/voltages/xups.inc.php index b01a94341..8b26b3c08 100644 --- a/includes/discovery/voltages/xups.inc.php +++ b/includes/discovery/voltages/xups.inc.php @@ -6,9 +6,7 @@ if ($device['os'] == 'powerware') { // XUPS-MIB::xupsBatVoltage.0 = INTEGER: 51 $oids = snmp_walk($device, 'xupsBatVoltage', '-Osqn', 'XUPS-MIB'); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { @@ -30,9 +28,7 @@ if ($device['os'] == 'powerware') { // XUPS-MIB::xupsInputNumPhases.0 = INTEGER: 1 $oids = trim(snmp_walk($device, 'xupsInputNumPhases', '-OsqnU', 'XUPS-MIB')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { @@ -53,9 +49,7 @@ if ($device['os'] == 'powerware') { // XUPS-MIB::xupsOutputNumPhases.0 = INTEGER: 1 $oids = trim(snmp_walk($device, 'xupsOutputNumPhases', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) { @@ -76,9 +70,7 @@ if ($device['os'] == 'powerware') { // XUPS-MIB::xupsBypassNumPhases.0 = INTEGER: 1 $oids = trim(snmp_walk($device, 'xupsBypassNumPhases', '-OsqnU')); - if ($debug) { - echo $oids."\n"; - } + d_echo($oids."\n"); list($unused,$numPhase) = explode(' ', $oids); for ($i = 1; $i <= $numPhase; $i++) {