diff --git a/includes/polling/applications.inc.php b/includes/polling/applications.inc.php index f0291ac67..4258129a6 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 c12f2d9cb..06eb5f65a 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 d148fa021..27bf8053f 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 3ee6d2a7b..6d7dba82c 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 4e4b6ce7a..99f055c5b 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 1cc757d37..748c226cb 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 f06be53d7..b60ad06da 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 98ed70149..1e3ebd2ef 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 c503cbe11..0688c00aa 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 29a8bd675..6039687ff 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 5f28d30d4..813f05304 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 5345e3a73..5693a0e9a 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 f6a462f21..613d4d058 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 9f2e0c3e0..ef6ebeafd 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 f374f5f62..f98c62d09 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 f15330d30..b57fc526c 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 2f8149a4b..50dade55f 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 1738b1470..dbeffda0e 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 6b653f99e..6ad6526cd 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 d68daa816..3d1754498 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -1,7 +1,5 @@