From 55a2e0423d5e5d3eee2fca0a6e00270eb80c1f4f Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Thu, 20 Aug 2015 15:02:40 +0200 Subject: [PATCH 1/7] Remove all unneeded if($debug)-statements and replace them with d_echo --- includes/polling/applications.inc.php | 4 +-- includes/polling/bgp-peers.inc.php | 27 +++++-------------- includes/polling/cisco-cef.inc.php | 4 +-- includes/polling/cisco-mac-accounting.inc.php | 8 ++---- includes/polling/entity-physical.inc.php | 4 +-- includes/polling/functions.inc.php | 8 ++---- includes/polling/junose-atm-vp.inc.php | 8 ++---- includes/polling/mempools.inc.php | 4 +-- includes/polling/mempools/cemp.inc.php | 4 +-- includes/polling/mempools/cmp.inc.php | 4 +-- includes/polling/mempools/hpGlobal.inc.php | 8 ++---- includes/polling/mempools/hpLocal.inc.php | 8 ++---- includes/polling/mempools/hrstorage.inc.php | 8 ++---- includes/polling/mempools/junos.inc.php | 12 +++------ includes/polling/mempools/vrp.inc.php | 12 +++------ includes/polling/netscaler-vsvr.inc.php | 8 ++---- includes/polling/ospf.inc.php | 4 +-- includes/polling/ports.inc.php | 24 +++++------------ includes/polling/storage.inc.php | 4 +-- includes/polling/storage/hrstorage.inc.php | 4 +-- .../polling/storage/netapp-storage.inc.php | 4 +-- includes/polling/ucd-diskio.inc.php | 8 ++---- includes/polling/unix-agent.inc.php | 2 -- .../polling/unix-agent/munin-plugins.inc.php | 8 ++---- 24 files changed, 47 insertions(+), 142 deletions(-) diff --git a/includes/polling/applications.inc.php b/includes/polling/applications.inc.php index f0291ac674..4258129a65 100644 --- a/includes/polling/applications.inc.php +++ b/includes/polling/applications.inc.php @@ -1,9 +1,7 @@ $b_in:$b_out:$p_in:$p_out "; - } + d_echo("\n".$acc['hostname'].' '.$acc['ifDescr']." $mac -> $b_in:$b_out:$p_in:$p_out "); $rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'); diff --git a/includes/polling/entity-physical.inc.php b/includes/polling/entity-physical.inc.php index c12f2d9cb2..06eb5f65a1 100644 --- a/includes/polling/entity-physical.inc.php +++ b/includes/polling/entity-physical.inc.php @@ -32,9 +32,7 @@ if ($device['os'] == 'ios') { $rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('c6kxbar-'.$index.'-'.$subindex.'.rrd'); - if ($debug) { - echo "$rrd "; - } + d_echo("$rrd "); if (!is_file($rrd)) { rrdtool_create( diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index d148fa0213..27bf8053fc 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -23,9 +23,7 @@ function poll_sensor($device, $class, $unit) { else { // Try 5 times to get a valid temp reading for ($i = 0; $i < 5; $i++) { - if ($debug) { - echo "Attempt $i "; - } + d_echo("Attempt $i "); $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib"))); preg_match('/[\d\.]+/', $sensor_value, $temp_response); @@ -280,9 +278,7 @@ function poll_device($device, $options) { // echo("$device_end - $device_start; $device_time $device_run"); echo "Polled in $device_time seconds\n"; - if ($debug) { - echo 'Updating '.$device['hostname'].' - '.print_r($update_array)." \n"; - } + d_echo('Updating '.$device['hostname'].' - '.print_r($update_array)." \n"); $updated = dbUpdate($update_array, 'devices', '`device_id` = ?', array($device['device_id'])); if ($updated) { diff --git a/includes/polling/junose-atm-vp.inc.php b/includes/polling/junose-atm-vp.inc.php index 3ee6d2a7bc..6d7dba82ca 100644 --- a/includes/polling/junose-atm-vp.inc.php +++ b/includes/polling/junose-atm-vp.inc.php @@ -20,9 +20,7 @@ if (count($vp_rows)) { $oid = $vp['ifIndex'].'.'.$vp['vp_id']; - if ($debug) { - echo "$oid "; - } + d_echo("$oid "); $t_vp = $vp_cache[$oid]; @@ -33,9 +31,7 @@ if (count($vp_rows)) { $rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('vp-'.$vp['ifIndex'].'-'.$vp['vp_id'].'.rrd'); - if ($debug) { - echo "$rrd "; - } + d_echo("$rrd "); if (!is_file($rrd)) { rrdtool_create( diff --git a/includes/polling/mempools.inc.php b/includes/polling/mempools.inc.php index 4e4b6ce7a3..99f055c5bc 100644 --- a/includes/polling/mempools.inc.php +++ b/includes/polling/mempools.inc.php @@ -44,9 +44,7 @@ foreach (dbFetchRows('SELECT * FROM mempools WHERE device_id = ?', array($device } if ($config['memcached']['enable'] === true) { - if ($debug) { - print_r($mempool['state']); - } + d_echo($mempool['state']); $memcache->set('mempool-'.$mempool['mempool_id'].'-value', $mempool['state']); } diff --git a/includes/polling/mempools/cemp.inc.php b/includes/polling/mempools/cemp.inc.php index 1cc757d373..748c226cb6 100644 --- a/includes/polling/mempools/cemp.inc.php +++ b/includes/polling/mempools/cemp.inc.php @@ -7,9 +7,7 @@ $pool_cmd = $config['snmpget'].' -M '.$config['mibdir'].' -m CISCO-ENHANCED-MEM $pool_cmd .= " cempMemPoolUsed.$oid cempMemPoolFree.$oid cempMemPoolLargestFree.$oid"; $pool_cmd .= " | cut -f 1 -d ' '"; -if ($debug) { - echo "SNMP [ $pool_cmd ]\n"; -} +d_echo("SNMP [ $pool_cmd ]\n"); $pool = shell_exec($pool_cmd); diff --git a/includes/polling/mempools/cmp.inc.php b/includes/polling/mempools/cmp.inc.php index f06be53d7f..b60ad06dae 100644 --- a/includes/polling/mempools/cmp.inc.php +++ b/includes/polling/mempools/cmp.inc.php @@ -7,9 +7,7 @@ $pool_cmd = $config['snmpget'].' -M '.$config['mibdir'].' -m CISCO-MEMORY-POOL- $pool_cmd .= " ciscoMemoryPoolUsed.$oid ciscoMemoryPoolFree.$oid ciscoMemoryPoolLargestFree.$oid"; $pool_cmd .= " | cut -f 1 -d ' '"; -if ($debug) { - echo "$pool_cmd"; -} +d_echo("$pool_cmd"); $pool = shell_exec($pool_cmd); diff --git a/includes/polling/mempools/hpGlobal.inc.php b/includes/polling/mempools/hpGlobal.inc.php index 98ed701497..1e3ebd2ef8 100644 --- a/includes/polling/mempools/hpGlobal.inc.php +++ b/includes/polling/mempools/hpGlobal.inc.php @@ -9,14 +9,10 @@ // NETSWITCH-MIB::hpGlobalMemAllocBytes.1 = INTEGER: 1668728 if (!is_array($mempool_cache['hpGlobal'])) { $mempool_cache['hpGlobal'] = snmpwalk_cache_oid($device, 'hpGlobal', null, 'NETSWITCH-MIB', $config['mibdir'].':'.$config['mibdir'].'/hp'); - if ($debug) { - print_r($mempool_cache); - } + d_echo($mempool_cache); } else { - if ($debug) { - echo 'Cached!'; - } + d_echo('Cached!'); } $entry = $mempool_cache['hpGlobal'][$mempool[mempool_index]]; diff --git a/includes/polling/mempools/hpLocal.inc.php b/includes/polling/mempools/hpLocal.inc.php index c503cbe11e..0688c00aa6 100644 --- a/includes/polling/mempools/hpLocal.inc.php +++ b/includes/polling/mempools/hpLocal.inc.php @@ -9,14 +9,10 @@ // NETSWITCH-MIB::hpLocalMemAllocBytes.1 = INTEGER: 1668728 if (!is_array($mempool_cache['hpLocal'])) { $mempool_cache['hpLocal'] = snmpwalk_cache_oid($device, 'hpLocal', null, 'NETSWITCH-MIB', $config['mibdir'].':'.$config['mibdir'].'/hp'); - if ($debug) { - print_r($mempool_cache); - } + d_echo($mempool_cache); } else { - if ($debug) { - echo 'Cached!'; - } + d_echo('Cached!'); } $entry = $mempool_cache['hpLocal'][$mempool[mempool_index]]; diff --git a/includes/polling/mempools/hrstorage.inc.php b/includes/polling/mempools/hrstorage.inc.php index 29a8bd675b..6039687ff2 100644 --- a/includes/polling/mempools/hrstorage.inc.php +++ b/includes/polling/mempools/hrstorage.inc.php @@ -3,14 +3,10 @@ // HOST-RESOURCES-MIB - Memory Objects if (!is_array($storage_cache['hrstorage'])) { $storage_cache['hrstorage'] = snmpwalk_cache_oid($device, 'hrStorageEntry', null, 'HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES'); - if ($debug) { - print_r($storage_cache); - } + d_echo($storage_cache); } else { - if ($debug) { - echo 'Cached!'; - } + d_echo('Cached!'); } $entry = $storage_cache['hrstorage'][$mempool[mempool_index]]; diff --git a/includes/polling/mempools/junos.inc.php b/includes/polling/mempools/junos.inc.php index 5f28d30d4c..813f053043 100644 --- a/includes/polling/mempools/junos.inc.php +++ b/includes/polling/mempools/junos.inc.php @@ -2,22 +2,16 @@ $oid = $mempool['mempool_index']; -if ($debug) { - echo 'JunOS Mempool'; -} +d_echo('JunOS Mempool'); if (!is_array($mempool_cache['junos'])) { - if ($debug) { - echo 'caching'; - } + d_echo('caching'); $mempool_cache['junos'] = array(); $mempool_cache['junos'] = snmpwalk_cache_multi_oid($device, 'jnxOperatingBuffer', $mempool_cache['junos'], 'JUNIPER-MIB', $config['install_dir'].'/mibs/junos'); $mempool_cache['junos'] = snmpwalk_cache_multi_oid($device, 'jnxOperatingDRAMSize', $mempool_cache['junos'], 'JUNIPER-MIB', $config['install_dir'].'/mibs/junos'); $mempool_cache['junos'] = snmpwalk_cache_multi_oid($device, 'jnxOperatingMemory', $mempool_cache['junos'], 'JUNIPER-MIB', $config['install_dir'].'/mibs/junos'); - if ($debug) { - print_r($mempool_cache); - } + d_echo($mempool_cache); } $entry = $mempool_cache['junos'][$mempool[mempool_index]]; diff --git a/includes/polling/mempools/vrp.inc.php b/includes/polling/mempools/vrp.inc.php index 5345e3a73c..5693a0e9a3 100644 --- a/includes/polling/mempools/vrp.inc.php +++ b/includes/polling/mempools/vrp.inc.php @@ -2,21 +2,15 @@ $oid = $mempool['mempool_index']; -if ($debug) { - echo 'Huawei VRP Mempool'; -} +d_echo('Huawei VRP Mempool'); if (!is_array($mempool_cache['vrp'])) { - if ($debug) { - echo 'caching'; - } + d_echo('caching'); $mempool_cache['vrp'] = array(); $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, 'hwEntityMemSize', $mempool_cache['vrp'], 'HUAWEI-ENTITY-EXTENT-MIB', $config['install_dir'].'/mibs'); $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, 'hwEntityMemUsage', $mempool_cache['vrp'], 'HUAWEI-ENTITY-EXTENT-MIB', $config['install_dir'].'/mibs'); - if ($debug) { - print_r($mempool_cache); - } + d_echo($mempool_cache); } $entry = $mempool_cache['vrp'][$mempool[mempool_index]]; diff --git a/includes/polling/netscaler-vsvr.inc.php b/includes/polling/netscaler-vsvr.inc.php index f6a462f215..613d4d0588 100644 --- a/includes/polling/netscaler-vsvr.inc.php +++ b/includes/polling/netscaler-vsvr.inc.php @@ -77,9 +77,7 @@ if ($device['os'] == 'netscaler') { print_r($vsvr); } - if ($debug) { - print_r($vsvrs); - } + d_echo($vsvrs); foreach ($vsvr_array as $index => $vsvr) { if (isset($vsvr['vsvrName'])) { @@ -129,9 +127,7 @@ if ($device['os'] == 'netscaler') { }//end if }//end foreach - if ($debug) { - print_r($vsvr_exist); - } + d_echo($vsvr_exist); foreach ($vsvrs as $db_name => $db_id) { if (!$vsvr_exist[$db_name]) { diff --git a/includes/polling/ospf.inc.php b/includes/polling/ospf.inc.php index 9f2e0c3e0a..ef6ebeafd8 100644 --- a/includes/polling/ospf.inc.php +++ b/includes/polling/ospf.inc.php @@ -327,9 +327,7 @@ if (is_array($ospf_nbrs_db)) { foreach ($ospf_nbr_oids as $oid) { // Loop the OIDs - if ($debug) { - echo $ospf_nbr_db[$oid].'|'.$ospf_nbr_poll[$oid]."\n"; - } + d_echo($ospf_nbr_db[$oid].'|'.$ospf_nbr_poll[$oid]."\n"); if ($ospf_nbr_db[$oid] != $ospf_nbr_poll[$oid]) { // If data has changed, build a query diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index f374f5f62a..f98c62d09a 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -192,9 +192,7 @@ else { $polled = time(); // 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. :> @@ -243,9 +241,7 @@ foreach ($ports as $port) { if ($config['memcached']['enable'] === true) { $state = $memcache->get('port-'.$port['port_id'].'-state'); - if ($debug) { - print_r($state); - } + d_echo($state); if (is_array($state)) { $port = array_merge($port, $state); @@ -336,7 +332,7 @@ foreach ($ports as $port) { $port['update'][$oid] = array('NULL'); log_event($oid.': '.$port[$oid].' -> NULL', $device, 'interface', $port['port_id']); if ($debug) { - echo $oid.': '.$port[$oid].' -> NULL '; + d_echo($oid.': '.$port[$oid].' -> NULL '); } else { echo $oid.' '; @@ -346,7 +342,7 @@ foreach ($ports as $port) { $port['update'][$oid] = $this_port[$oid]; log_event($oid.': '.$port[$oid].' -> '.$this_port[$oid], $device, 'interface', $port['port_id']); if ($debug) { - echo $oid.': '.$port[$oid].' -> '.$this_port[$oid].' '; + d_echo($oid.': '.$port[$oid].' -> '.$this_port[$oid].' '); } else { echo $oid.' '; @@ -423,9 +419,7 @@ foreach ($ports as $port) { $port['state'][$oid.'_delta'] = $oid_diff; } - if ($debug) { - echo "\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"; - } + d_echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); }//end if }//end foreach @@ -547,9 +541,7 @@ foreach ($ports as $port) { // Update Memcached if ($config['memcached']['enable'] === true) { - if ($debug) { - print_r($port['state']); - } + d_echo($port['state']); $memcache->set('port-'.$port['port_id'].'-state', $port['state']); } @@ -563,9 +555,7 @@ foreach ($ports as $port) { // Update Database if (count($port['update'])) { $updated = dbUpdate($port['update'], 'ports', '`port_id` = ?', array($port['port_id'])); - if ($debug) { - echo "$updated updated"; - } + d_echo("$updated updated"); } // End Update Database diff --git a/includes/polling/storage.inc.php b/includes/polling/storage.inc.php index f15330d301..b57fc526c3 100644 --- a/includes/polling/storage.inc.php +++ b/includes/polling/storage.inc.php @@ -19,9 +19,7 @@ foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', array($device[ // FIXME Generic poller goes here if we ever have a discovery module which uses it. } - if ($debug) { - print_r($storage); - } + d_echo($storage); if ($storage['size']) { $percent = round(($storage['used'] / $storage['size'] * 100)); diff --git a/includes/polling/storage/hrstorage.inc.php b/includes/polling/storage/hrstorage.inc.php index 2f8149a4b5..50dade55f8 100644 --- a/includes/polling/storage/hrstorage.inc.php +++ b/includes/polling/storage/hrstorage.inc.php @@ -3,9 +3,7 @@ // HOST-RESOURCES-MIB - Storage Objects if (!is_array($storage_cache['hrstorage'])) { $storage_cache['hrstorage'] = snmpwalk_cache_oid($device, 'hrStorageEntry', null, 'HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES'); - if ($debug) { - print_r($storage_cache); - } + d_echo($storage_cache); } $entry = $storage_cache['hrstorage'][$storage[storage_index]]; diff --git a/includes/polling/storage/netapp-storage.inc.php b/includes/polling/storage/netapp-storage.inc.php index 1738b14709..dbeffda0ee 100644 --- a/includes/polling/storage/netapp-storage.inc.php +++ b/includes/polling/storage/netapp-storage.inc.php @@ -2,9 +2,7 @@ if (!is_array($storage_cache['netapp-storage'])) { $storage_cache['netapp-storage'] = snmpwalk_cache_oid($device, 'dfEntry', null, 'NETAPP-MIB'); - if ($debug) { - print_r($storage_cache); - } + d_echo($storage_cache); } $entry = $storage_cache['netapp-storage'][$storage[storage_index]]; diff --git a/includes/polling/ucd-diskio.inc.php b/includes/polling/ucd-diskio.inc.php index 6b653f99e3..6ad6526cd6 100644 --- a/includes/polling/ucd-diskio.inc.php +++ b/includes/polling/ucd-diskio.inc.php @@ -15,15 +15,11 @@ if (count($diskio_data)) { echo $diskio['diskio_descr'].' '; - if ($debug) { - print_r($entry); - } + d_echo($entry); $rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('ucd_diskio-'.$diskio['diskio_descr'].'.rrd'); - if ($debug) { - echo "$rrd "; - } + d_echo("$rrd "); if (!is_file($rrd)) { rrdtool_create( diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index d68daa816d..3d1754498c 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -1,7 +1,5 @@ Date: Thu, 20 Aug 2015 15:07:28 +0200 Subject: [PATCH 2/7] Remove all unneeded if($debug)-statements and replace them with d_echo . html dir.. --- html/graph.php | 7 ++----- html/includes/graphs/graph.inc.php | 8 ++------ html/includes/graphs/macaccounting/auth.inc.php | 8 ++------ html/pages/device/health/mempool.inc.php | 4 +--- html/pages/device/overview/mempools.inc.php | 4 +--- html/pages/device/port.inc.php | 4 +--- html/pages/device/ports.inc.php | 4 +--- html/pages/health/sensors.inc.php | 4 +--- 8 files changed, 11 insertions(+), 32 deletions(-) diff --git a/html/graph.php b/html/graph.php index f3cf51fd98..537c5e999a 100644 --- a/html/graph.php +++ b/html/graph.php @@ -58,8 +58,5 @@ $end = utime(); $run = ($end - $start); -if ($debug) { - echo '
Runtime '.$run.' secs'; - - echo ('
MySQL: Cell '.($db_stats['fetchcell'] + 0).'/'.round(($db_stats['fetchcell_sec'] + 0), 3).'s'.' Row '.($db_stats['fetchrow'] + 0).'/'.round(($db_stats['fetchrow_sec'] + 0), 3).'s'.' Rows '.($db_stats['fetchrows'] + 0).'/'.round(($db_stats['fetchrows_sec'] + 0), 3).'s'.' Column '.($db_stats['fetchcol'] + 0).'/'.round(($db_stats['fetchcol_sec'] + 0), 3).'s'); -} +d_echo('
Runtime '.$run.' secs'); +d_echo('
MySQL: Cell '.($db_stats['fetchcell'] + 0).'/'.round(($db_stats['fetchcell_sec'] + 0), 3).'s'.' Row '.($db_stats['fetchrow'] + 0).'/'.round(($db_stats['fetchrow_sec'] + 0), 3).'s'.' Rows '.($db_stats['fetchrows'] + 0).'/'.round(($db_stats['fetchrows_sec'] + 0), 3).'s'.' Column '.($db_stats['fetchcol'] + 0).'/'.round(($db_stats['fetchcol_sec'] + 0), 3).'s'); diff --git a/html/includes/graphs/graph.inc.php b/html/includes/graphs/graph.inc.php index 19e99c9b69..d7ed4cbc89 100644 --- a/html/includes/graphs/graph.inc.php +++ b/html/includes/graphs/graph.inc.php @@ -69,9 +69,7 @@ function graph_error($string) { if ($height > '99') { shell_exec($rrd_cmd); - if ($debug) { - echo '
'.$rrd_cmd.'
'; - } + d_echo('
'.$rrd_cmd.'
'); if (is_file($graphfile) && !$debug) { header('Content-type: image/png'); @@ -135,9 +133,7 @@ else { else { if ($rrd_options) { rrdtool_graph($graphfile, $rrd_options); - if ($debug) { - echo $rrd_cmd; - } + d_echo($rrd_cmd); if (is_file($graphfile)) { if (!$debug) { diff --git a/html/includes/graphs/macaccounting/auth.inc.php b/html/includes/graphs/macaccounting/auth.inc.php index 9718741166..d6a2ccb5fd 100644 --- a/html/includes/graphs/macaccounting/auth.inc.php +++ b/html/includes/graphs/macaccounting/auth.inc.php @@ -11,14 +11,10 @@ if (is_numeric($vars['id'])) { if (is_array($acc)) { if ($auth || port_permitted($acc['port_id'])) { - if ($debug) { - echo $config['rrd_dir'].'/'.$acc['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'); - } + d_echo($config['rrd_dir'].'/'.$acc['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd')); if (is_file($config['rrd_dir'].'/'.$acc['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'))) { - if ($debug) { - echo 'exists'; - } + d_echo('exists'); $rrd_filename = $config['rrd_dir'].'/'.$acc['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'); $port = get_port_by_id($acc['port_id']); diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index 613aa1250b..e2a6eaa515 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -18,9 +18,7 @@ foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($devi if ($config['memcached']['enable'] === true) { $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if ($debug) { - print_r($state); - } + d_echo($state); if (is_array($state)) { $mempool = array_merge($mempool, $state); diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 49884331d7..01895ee7d6 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -21,9 +21,7 @@ if (count($mempools)) { foreach ($mempools as $mempool) { if ($config['memcached']['enable'] === true) { $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if ($debug) { - print_r($state); - } + d_echo($state); if (is_array($state)) { $mempool = array_merge($mempool, $state); diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index 80bdbff911..bd9c38acd6 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -8,9 +8,7 @@ $port = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ?', array($vars['por if ($config['memcached']['enable'] === true) { $state = $memcache->get('port-'.$port['port_id'].'-state'); - if ($debug) { - print_r($state); - } + d_echo($state); if (is_array($state)) { $port = array_merge($port, $state); diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index dc941e246f..11a5978ff8 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -138,9 +138,7 @@ else { foreach ($ports as $port) { if ($config['memcached']['enable'] === true) { $state = $memcache->get('port-'.$port['port_id'].'-state'); - if ($debug) { - print_r($state); - } + d_echo($state); if (is_array($state)) { $port = array_merge($port, $state); diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index a51ba6e71b..7ed65f926a 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -24,9 +24,7 @@ echo ' foreach (dbFetchRows($sql, $param) as $sensor) { if ($config['memcached']['enable'] === true) { $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - if ($debug) { - echo 'Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']'; - } + d_echo('Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']'); } if (empty($sensor['sensor_current'])) { From 677a4f3f5f89f0b72b5b13c41c8b854c4d7a6282 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Thu, 20 Aug 2015 15:59:43 +0200 Subject: [PATCH 3/7] Remove all unneeded if($debug)-statements and replace them with d_echo . discovery dir.. --- includes/discovery/arp-table.inc.php | 8 +- includes/discovery/bgp-peers.inc.php | 32 ++---- includes/discovery/charge.inc.php | 4 +- includes/discovery/charge/apc.inc.php | 8 +- includes/discovery/charge/rfc1628.inc.php | 4 +- includes/discovery/cisco-cef.inc.php | 4 +- .../discovery/cisco-entity-sensor.inc.php | 4 +- includes/discovery/cisco-vrf.inc.php | 6 +- includes/discovery/current.inc.php | 4 +- includes/discovery/current/apc.inc.php | 20 +--- includes/discovery/current/mgeups.inc.php | 8 +- includes/discovery/current/rfc1628.inc.php | 16 +-- includes/discovery/current/sentry3.inc.php | 4 +- includes/discovery/current/xups.inc.php | 12 +- .../discovery/discovery-protocols.inc.php | 12 +- includes/discovery/fanspeeds.inc.php | 4 +- includes/discovery/fanspeeds/areca.inc.php | 4 +- includes/discovery/fanspeeds/dell.inc.php | 4 +- includes/discovery/fanspeeds/drac.inc.php | 4 +- .../discovery/fanspeeds/lmsensors.inc.php | 4 +- includes/discovery/fanspeeds/mikrotik.inc.php | 4 +- .../discovery/fanspeeds/supermicro.inc.php | 4 +- includes/discovery/frequencies.inc.php | 4 +- includes/discovery/frequencies/apc.inc.php | 16 +-- includes/discovery/frequencies/mgeups.inc.php | 8 +- .../discovery/frequencies/rfc1628.inc.php | 4 +- includes/discovery/functions.inc.php | 104 +++++------------- includes/discovery/hr-device.inc.php | 18 +-- includes/discovery/humidity.inc.php | 4 +- includes/discovery/humidity/akcp.inc.php | 4 +- includes/discovery/humidity/mgeups.inc.php | 6 +- includes/discovery/humidity/netbotz.inc.php | 4 +- includes/discovery/humidity/sentry3.inc.php | 4 +- includes/discovery/junose-atm-vp.inc.php | 12 +- includes/discovery/libvirt-vminfo.inc.php | 4 +- includes/discovery/load.inc.php | 4 +- includes/discovery/load/apc.inc.php | 4 +- includes/discovery/load/rfc1628.inc.php | 4 +- includes/discovery/mempools.inc.php | 8 +- includes/discovery/mempools/junos.inc.php | 8 +- includes/discovery/mempools/vrp.inc.php | 8 +- includes/discovery/ports.inc.php | 4 +- includes/discovery/power.inc.php | 4 +- includes/discovery/power/rfc1628.inc.php | 12 +- includes/discovery/processors.inc.php | 8 +- .../discovery/processors/hrdevice.inc.php | 4 +- includes/discovery/processors/ios.inc.php | 8 +- .../discovery/processors/ironware.inc.php | 4 +- includes/discovery/processors/junos.inc.php | 12 +- includes/discovery/processors/junose.inc.php | 4 +- includes/discovery/processors/vrp.inc.php | 8 +- includes/discovery/states.inc.php | 4 +- includes/discovery/states/dell.inc.php | 4 +- includes/discovery/states/drac.inc.php | 4 +- includes/discovery/states/rfc1628.inc.php | 8 +- includes/discovery/storage.inc.php | 8 +- includes/discovery/storage/hrstorage.inc.php | 24 +--- .../discovery/storage/netapp-storage.inc.php | 12 +- includes/discovery/temperatures.inc.php | 4 +- includes/discovery/temperatures/akcp.inc.php | 4 +- includes/discovery/temperatures/apc.inc.php | 19 +--- includes/discovery/temperatures/areca.inc.php | 8 +- .../temperatures/cometsystem-p85xx.inc.php | 1 - includes/discovery/temperatures/dell.inc.php | 8 +- includes/discovery/temperatures/drac.inc.php | 8 +- .../discovery/temperatures/lm-sensors.inc.php | 4 +- .../discovery/temperatures/mgeups.inc.php | 6 +- .../discovery/temperatures/mikrotik.inc.php | 4 +- .../discovery/temperatures/netapp.inc.php | 4 +- .../discovery/temperatures/netbotz.inc.php | 4 +- .../temperatures/observernms-custom.inc.php | 4 +- .../discovery/temperatures/rfc1628.inc.php | 4 +- .../discovery/temperatures/sentry3.inc.php | 4 +- includes/discovery/temperatures/siklu.inc.php | 4 +- includes/discovery/temperatures/xups.inc.php | 4 +- includes/discovery/toner.inc.php | 12 +- includes/discovery/ucd-diskio.inc.php | 17 +-- includes/discovery/voltages.inc.php | 4 +- includes/discovery/voltages/apc.inc.php | 24 +--- includes/discovery/voltages/areca.inc.php | 4 +- includes/discovery/voltages/drac.inc.php | 4 +- includes/discovery/voltages/linux.inc.php | 4 +- includes/discovery/voltages/mgeups.inc.php | 8 +- includes/discovery/voltages/mikrotik.inc.php | 4 +- includes/discovery/voltages/rfc1628.inc.php | 16 +-- includes/discovery/voltages/sentry3.inc.php | 4 +- includes/discovery/voltages/siklu.inc.php | 4 +- .../discovery/voltages/supermicro.inc.php | 4 +- includes/discovery/voltages/xups.inc.php | 16 +-- 89 files changed, 192 insertions(+), 561 deletions(-) diff --git a/includes/discovery/arp-table.inc.php b/includes/discovery/arp-table.inc.php index a292bf25b5..69b0d9b750 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 304bbc6b10..b9f3c16a03 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 c82863d0f7..eeea0961f2 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 b9858b958d..ce98b4b9d2 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 c7d5742c7a..02b85e03f2 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 7b8ef3a806..5f9ef1ca65 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 e7053a20d0..66340dedb0 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 39928b734e..aceef192f6 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 c28644184f..143d6068c3 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 e57f266404..8e35df8821 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 c2a7b77a7d..bc80a0b162 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 d86b708088..73811ae101 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 6946d37702..45bcc6d9f9 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 328ed98013..d6dff4d3f6 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 0e5d540f15..0afe433117 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 6ad6295492..536232149d 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 831cd78a52..cdb0fb7919 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 f1ee40d942..d1522a6569 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 38b80c340d..3d9e0bf414 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 a4aa7c6ca2..8e288e73de 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 9908fdbf03..789769f7d1 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 be56aec020..c16eb1b09a 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 23b30b0926..93fa171176 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 cfb4d08efc..794fe5fc54 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 67a31218cf..1815a30c6a 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 aeadbf3e6b..7073181549 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 512f39cff4..dbe5d08dd0 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 aa168da8ce..a00ddc887c 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 69b3d9d975..d32be07e45 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 07dc0864ca..d32406ba28 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 3d524d2596..0f15b3c246 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 e4dd44dabf..e3f686fd94 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 c3e4ff4406..e1417993c9 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 53916e8dc0..f65320fcc7 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 38777b9025..8825bf7b46 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 aa28fe866a..f09ae86e39 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 39927b59f3..1d0c7ce5ec 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 c11522f45a..01f0067822 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 9435b0207b..b865b9f434 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 f3a30c139a..2a9ed6bd20 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 180514368a..ca06a851e8 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 3a8a2eb607..32067fa054 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 2161e5ec24..d204c4b5cb 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 8816ff9b4c..adaa5c918d 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 3d0eb0cb4d..c095015980 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 2f6c152b7c..97d021745d 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 36a18493f0..4bcaa0ffa7 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 b3f995c870..7acb763d75 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 d15c898f62..c66785ddc2 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 81fd032479..a0c9976070 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 c8a17126bd..3cdbcdf2ed 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 12a07296bb..2eb1c740e2 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 c5c070a741..b8dca50df3 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 0995991081..5e4c5eba8b 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 0a8a482fd4..0dd8e6a142 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 b8b8fd7e33..d04817c9be 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 f32a48faa9..46907e10aa 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 83709c07fe..49cd0d8035 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 25f385500c..60e01b0ba2 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 76602e418f..b60e9ab878 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 93aa89dd9d..4c7d53cc91 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 beffb9dd4f..a286ad62fb 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 4049e00fb8..28e8f09085 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 acddb2cbcc..dcf6a3b9cb 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 1edc63b535..3687db6c9d 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 1df73f023e..1482b356c5 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 2696646977..4c6e7a478e 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 d91fe5d4ef..5ce7b438da 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 b309d21fbc..a45b7027a9 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 258203a805..0958f3b50f 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 e94ce8f027..f009a74cb8 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 f599f02eeb..061594ede2 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 6e715b9955..b31cba73ce 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 23bff12ad5..0127469e05 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 4c1f654d6c..a89efbbd18 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 e2d7043224..7ccebb3e75 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 867d0bd309..c80b2e75dd 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 690d347477..21fc75f8a6 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 b01a94341f..8b26b3c08f 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++) { From 4792879ce5d93f5b0b6faf324bb8af91cc1a2a82 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Thu, 20 Aug 2015 16:06:44 +0200 Subject: [PATCH 4/7] Remove all unneeded if($debug)-statements and replace them with d_echo in the rest of the directories... --- discovery.php | 4 +--- includes/alerts.inc.php | 1 - includes/common.php | 10 ++-------- includes/definitions.inc.php | 4 +--- includes/functions.php | 30 +++++++++--------------------- includes/include-dir.inc.php | 4 +--- includes/port-descr-parser.inc.php | 4 +--- includes/rrdtool.inc.php | 16 +++++----------- includes/sql-schema/update.php | 4 +--- poller.php | 4 +--- 10 files changed, 22 insertions(+), 59 deletions(-) diff --git a/discovery.php b/discovery.php index 336f91ad08..c708780544 100755 --- a/discovery.php +++ b/discovery.php @@ -118,9 +118,7 @@ if ($discovered_devices) { } $string = $argv[0]." $doing ".date($config['dateformat']['compact'])." - $discovered_devices devices discovered in $proctime secs"; -if ($debug) { - echo "$string\n"; -} +d_echo("$string\n"); if ($options['h'] != 'new' && $config['version_check']) { include 'includes/versioncheck.inc.php'; diff --git a/includes/alerts.inc.php b/includes/alerts.inc.php index 1d5c5c91ce..f57c102b36 100644 --- a/includes/alerts.inc.php +++ b/includes/alerts.inc.php @@ -220,7 +220,6 @@ function IsMaintenance( $device ) { * @return void */ function RunRules($device) { - global $debug; if( IsMaintenance($device) > 0 ) { echo "Under Maintenance, Skipping alerts.\r\n"; return false; diff --git a/includes/common.php b/includes/common.php index 03b239e85c..32e6e65af1 100644 --- a/includes/common.php +++ b/includes/common.php @@ -33,15 +33,9 @@ function format_number_short($number, $sf) { } function external_exec($command) { - global $debug; - - if ($debug) { - echo($command."\n"); - } + d_echo($command."\n"); $output = shell_exec($command); - if ($debug) { - echo($output."\n"); - } + d_echo($output."\n"); return $output; } diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 0fc20c740d..11151148c2 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1664,9 +1664,7 @@ if ($config['memcached']['enable'] === true) { if (class_exists('Memcached')) { $memcache = new Memcached(); $memcache->addServer($config['memcached']['host'], $config['memcached']['port']); - if ($debug) { - print_r($memcache->getStats()); - } + d_echo($memcache->getStats()); } else { echo "WARNING: You have enabled memcached but have not installed the PHP bindings. Disabling memcached support.\n"; diff --git a/includes/functions.php b/includes/functions.php index 10499c0864..0027748eec 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -95,14 +95,12 @@ function logfile($string) { } function getHostOS($device){ - global $config, $debug; + global $config; $sysDescr = snmp_get ($device, "SNMPv2-MIB::sysDescr.0", "-Ovq"); $sysObjectId = snmp_get ($device, "SNMPv2-MIB::sysObjectID.0", "-Ovqn"); - if ($debug) { - echo("| $sysDescr | $sysObjectId | "); - } + d_echo("| $sysDescr | $sysObjectId | "); $path = $config['install_dir'] . "/includes/discovery/os"; $dir_handle = @opendir($path) or die("Unable to open $path"); @@ -698,8 +696,6 @@ function get_astext($asn) { # Use this function to write to the eventlog table function log_event($text, $device = NULL, $type = NULL, $reference = NULL) { - global $debug; - if (!is_array($device)) { $device = device_by_id_cache($device); } @@ -830,7 +826,7 @@ function isHexString($str) { # Include all .inc.php files in $dir function include_dir($dir, $regex = "") { - global $device, $config, $debug, $valid; + global $device, $config, $valid; if ($regex == "") { $regex = "/\.inc\.php$/"; @@ -839,9 +835,7 @@ function include_dir($dir, $regex = "") { if ($handle = opendir($config['install_dir'] . '/' . $dir)) { while (false !== ($file = readdir($handle))) { if (filetype($config['install_dir'] . '/' . $dir . '/' . $file) == 'file' && preg_match($regex, $file)) { - if ($debug) { - echo("Including: " . $config['install_dir'] . '/' . $dir . '/' . $file . "\n"); - } + d_echo("Including: " . $config['install_dir'] . '/' . $dir . '/' . $file . "\n"); include($config['install_dir'] . '/' . $dir . '/' . $file); } @@ -853,7 +847,7 @@ function include_dir($dir, $regex = "") { function is_port_valid($port, $device) { - global $config, $debug; + global $config; if (strstr($port['ifDescr'], "irtual")) { $valid = 0; @@ -868,9 +862,7 @@ function is_port_valid($port, $device) { foreach ($fringe as $bi) { if (strstr($if, $bi)) { $valid = 0; - if ($debug) { - echo("ignored : $bi : $if"); - } + d_echo("ignored : $bi : $if"); } } if (is_array($config['bad_if_regexp'])) { @@ -881,9 +873,7 @@ function is_port_valid($port, $device) { foreach ($fringe as $bi) { if (preg_match($bi ."i", $if)) { $valid = 0; - if ($debug) { - echo("ignored : $bi : ".$if); - } + d_echo("ignored : $bi : ".$if); } } } @@ -895,9 +885,7 @@ function is_port_valid($port, $device) { foreach ($fringe as $bi) { if (strstr($port['ifType'], $bi)) { $valid = 0; - if ($debug) { - echo("ignored ifType : ".$port['ifType']." (matched: ".$bi." )"); - } + d_echo("ignored ifType : ".$port['ifType']." (matched: ".$bi." )"); } } } @@ -917,7 +905,7 @@ function is_port_valid($port, $device) { function scan_new_plugins() { - global $config, $debug; + global $config; $installed = 0; // Track how many plugins we install. diff --git a/includes/include-dir.inc.php b/includes/include-dir.inc.php index d5c0a7eabf..2d6c1456d3 100644 --- a/includes/include-dir.inc.php +++ b/includes/include-dir.inc.php @@ -8,9 +8,7 @@ if ($include_dir_regexp == '' || !isset($include_dir_regexp)) { if ($handle = opendir($config['install_dir'].'/'.$include_dir)) { while (false !== ($file = readdir($handle))) { if (filetype($config['install_dir'].'/'.$include_dir.'/'.$file) == 'file' && preg_match($include_dir_regexp, $file)) { - if ($debug) { - echo 'Including: '.$config['install_dir'].'/'.$include_dir.'/'.$file."\n"; - } + d_echo('Including: '.$config['install_dir'].'/'.$include_dir.'/'.$file."\n"); include $config['install_dir'].'/'.$include_dir.'/'.$file; } diff --git a/includes/port-descr-parser.inc.php b/includes/port-descr-parser.inc.php index 2b0f475aaa..144790c124 100644 --- a/includes/port-descr-parser.inc.php +++ b/includes/port-descr-parser.inc.php @@ -20,9 +20,7 @@ if ($type && $descr) { $port_ifAlias['speed'] = $speed; $port_ifAlias['notes'] = $notes; - if ($debug) { - print_r($port_ifAlias); - } + d_echo($port_ifAlias); } unset($port_type, $port_descr, $port_circuit, $port_notes, $port_speed); diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index afbd2f7ad4..a8a7e99369 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -23,7 +23,7 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) { - global $config, $debug; + global $config; $command = $config['rrdtool'].' -'; @@ -74,12 +74,8 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) { function rrdtool_pipe_close($rrd_process, &$rrd_pipes) { - global $debug; - - if ($debug) { - echo stream_get_contents($rrd_pipes[1]); - echo stream_get_contents($rrd_pipes[2]); - } + d_echo(stream_get_contents($rrd_pipes[1])); + d_echo(stream_get_contents($rrd_pipes[2])); fclose($rrd_pipes[0]); fclose($rrd_pipes[1]); @@ -210,7 +206,7 @@ function rrdtool($command, $filename, $options) { function rrdtool_create($filename, $options) { - global $config, $debug, $console_color; + global $config, $console_color; if ($config['norrd']) { print $console_color->convert('[%gRRD Disabled%n] ', false); @@ -219,9 +215,7 @@ function rrdtool_create($filename, $options) { $command = $config['rrdtool']." create $filename $options"; } - if ($debug) { - print $console_color->convert('RRD[%g'.$command.'%n] '); - } + d_echo($console_color->convert('RRD[%g'.$command.'%n] ')); return shell_exec($command); diff --git a/includes/sql-schema/update.php b/includes/sql-schema/update.php index 6497d1ca55..4bb7df7211 100644 --- a/includes/sql-schema/update.php +++ b/includes/sql-schema/update.php @@ -103,9 +103,7 @@ foreach ($filelist as $file) { foreach (explode("\n", $data) as $line) { if (trim($line)) { - if ($debug) { - echo "$line \n"; - } + d_echo("$line \n"); if ($line[0] != '#') { if ($config['db']['extension'] == 'mysqli') { diff --git a/poller.php b/poller.php index 623c000440..62bb94cd74 100755 --- a/poller.php +++ b/poller.php @@ -124,9 +124,7 @@ if ($polled_devices) { } $string = $argv[0]." $doing ".date($config['dateformat']['compact'])." - $polled_devices devices polled in $poller_time secs"; -if ($debug) { - echo "$string\n"; -} +d_echo("$string\n"); echo ("\n".'MySQL: Cell['.($db_stats['fetchcell'] + 0).'/'.round(($db_stats['fetchcell_sec'] + 0), 2).'s]'.' Row['.($db_stats['fetchrow'] + 0).'/'.round(($db_stats['fetchrow_sec'] + 0), 2).'s]'.' Rows['.($db_stats['fetchrows'] + 0).'/'.round(($db_stats['fetchrows_sec'] + 0), 2).'s]'.' Column['.($db_stats['fetchcol'] + 0).'/'.round(($db_stats['fetchcol_sec'] + 0), 2).'s]'.' Update['.($db_stats['update'] + 0).'/'.round(($db_stats['update_sec'] + 0), 2).'s]'.' Insert['.($db_stats['insert'] + 0).'/'.round(($db_stats['insert_sec'] + 0), 2).'s]'.' Delete['.($db_stats['delete'] + 0).'/'.round(($db_stats['delete_sec'] + 0), 2).'s]'); From 4260c6697cd7c2e1088bdf6a232f274a5d29a409 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Fri, 21 Aug 2015 16:13:54 +0200 Subject: [PATCH 5/7] Sign AUTHORS.md --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 2421c7ce3b..ad5e416297 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -48,6 +48,7 @@ Contributors to LibreNMS: - Michael Newton (miken32) - Tom Ferguson (Tawmu) - Jimmy Cleuren (jimmycleuren) +- Mark Schouten (tuxis-ie) [1]: http://observium.org/ "Observium web site" From bfe47128d39cb20c7b7f98ba02441fe70498a4db Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Fri, 21 Aug 2015 16:47:29 +0200 Subject: [PATCH 6/7] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index ad5e416297..823ffedeca 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -48,7 +48,7 @@ Contributors to LibreNMS: - Michael Newton (miken32) - Tom Ferguson (Tawmu) - Jimmy Cleuren (jimmycleuren) -- Mark Schouten (tuxis-ie) +- Mark Schouten (tuxis-ie) [1]: http://observium.org/ "Observium web site" From dadbcb454a8214716aab01e7fec91c5826ed1471 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Fri, 21 Aug 2015 23:42:18 +0200 Subject: [PATCH 7/7] Fix two typos --- includes/discovery/bgp-peers.inc.php | 2 +- includes/discovery/temperatures/mgeups.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index b9f3c16a03..1b87eaecf5 100644 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -113,7 +113,7 @@ if ($config['enable_bgp']) { $af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']); } - d_echo('afi data :: '; + d_echo('afi data :: '); d_echo($af_data); foreach ($af_data as $k => $v) { diff --git a/includes/discovery/temperatures/mgeups.inc.php b/includes/discovery/temperatures/mgeups.inc.php index 4c6e7a478e..f60170a5a3 100644 --- a/includes/discovery/temperatures/mgeups.inc.php +++ b/includes/discovery/temperatures/mgeups.inc.php @@ -50,7 +50,7 @@ if ($device['os'] == 'mgeups') { $low_warn_limit = ($low_limit + $hysteresis); $high_warn_limit = ($high_limit - $hysteresis); - d_echo("low_limit : $low_limit\nlow_warn_limit : $low_warn_limit\nhigh_warn_limit : $high_warn_limit\nhigh_limit : $high_limit\n"): + d_echo("low_limit : $low_limit\nlow_warn_limit : $low_warn_limit\nhigh_warn_limit : $high_warn_limit\nhigh_limit : $high_limit\n"); discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, '10', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, ($current / 10)); }