Index: includes/alerts.inc.php
===================================================================
--- includes/alerts.inc.php	(revision 6212)
+++ includes/alerts.inc.php	(working copy)
@@ -281,8 +281,6 @@
 // TESTME needs unit testing
 function cache_alert_rules($vars = array())
 {
-  global $debug;
-
   $alert_rules = array();
   $rules_count = 0;
   $where = 'WHERE 1';
@@ -298,7 +296,7 @@
     $rules_count++;
   }
 
-  if ($debug) { echo("Cached $rules_count alert rules.\n"); }
+  print_debug("Cached $rules_count alert rules.");
 
   return $alert_rules;
 }
Index: includes/discovery/arp-table.inc.php
===================================================================
--- includes/discovery/arp-table.inc.php	(revision 6212)
+++ includes/discovery/arp-table.inc.php	(working copy)
@@ -41,7 +41,7 @@
 if ($ipNetToPhysicalPhysAddress_oid)
 {
   $oid_data = $ipNetToPhysicalPhysAddress_oid;
-  if ($debug) { echo("Used IP-MIB::ipNetToPhysicalPhysAddress\n"); }
+  print_debug("Used IP-MIB::ipNetToPhysicalPhysAddress");
 } else {
   $oid_data = '';
   if ($device['os_group'] == 'cisco')
@@ -61,7 +61,7 @@
     if ($ipv6NetToMediaPhysAddress_oid)
     {
       $oid_data .= $ipv6NetToMediaPhysAddress_oid;
-      if ($debug) { echo("Used IPV6-MIB::ipv6NetToMediaPhysAddress\n"); }
+      print_debug("Used IPV6-MIB::ipv6NetToMediaPhysAddress");
     }
   }
 }
@@ -73,7 +73,7 @@
   if ($ipNetToMediaPhysAddress_oid)
   {
     $oid_data .= $ipNetToMediaPhysAddress_oid;
-    if ($debug) { echo("Used IP-MIB::ipNetToMediaPhysAddress\n"); }
+    print_debug("Used IP-MIB::ipNetToMediaPhysAddress");
   }
 }
 $oid_data = trim($oid_data);
@@ -140,7 +140,7 @@
 
       if ($clean_mac != $old_mac && $clean_mac != '00:00:00:00:00:00' && $old_mac != '00:00:00:00:00:00')
       {
-        if ($debug) { echo("Changed MAC address for $ip from $old_mac to $clean_mac\n"); }
+        print_debug("Changed MAC address for $ip from $old_mac to $clean_mac");
         log_event("MAC changed: $ip : " . format_mac($old_mac) . " -> " . format_mac($clean_mac), $device, "port", $port_id);
         dbUpdate(array('mac_address' => $clean_mac) , 'ip_mac', 'port_id = ? AND ip_address = ?', array($port_id, $ip));
         echo(".");
@@ -152,7 +152,7 @@
                       'ip_address' => $ip,
                       'ip_version' => $ip_version);
       dbInsert($params, 'ip_mac');
-      if ($debug) { echo("Add MAC $clean_mac\n"); }
+      print_debug("Add MAC $clean_mac");
       //log_event("MAC added: $ip : " . format_mac($clean_mac), $device, "port", $port_id);
       echo("+");
     }
@@ -171,7 +171,7 @@
   if (!isset($mac_table[$entry_if][$entry_version][$entry_ip]))
   {
     dbDelete('ip_mac', 'mac_id = ?', array($entry_mac_id));
-    if ($debug) { echo("Removing MAC address $entry_mac for $entry_ip\n"); }
+    print_debug("Removing MAC address $entry_mac for $entry_ip");
     //log_event("MAC removed: $entry_ip : " . format_mac($entry_mac), $device, "port", $entry['port_id']);
     echo("-");
   }
Index: includes/discovery/bgp-peers.inc.php
===================================================================
--- includes/discovery/bgp-peers.inc.php	(revision 6212)
+++ includes/discovery/bgp-peers.inc.php	(working copy)
@@ -247,7 +247,7 @@
           $afi = $afisafi[$c - 2];
           $safi = $afisafi[$c - 1];
           $peer_ip = hex2ip(str_replace(".$afi.$safi", '', $af));
-          if ($debug) { echo("Peer IP: $peer_ip, AFI: $afi, SAFI: $safi\n"); }
+          print_debug("Peer IP: $peer_ip, AFI: $afi, SAFI: $safi");
           if ($afi && $safi)
           {
             $af_list[$peer_ip][$afi][$safi] = 1;
@@ -334,7 +334,7 @@
 
   unset($p_list, $peerlist);
 
-  echo("\n");
+  echo(PHP_EOL);
 }
 
-// end includes/discovery/bgp-peers.inc.php
+// EOF
Index: includes/discovery/ucd-diskio.inc.php
===================================================================
--- includes/discovery/ucd-diskio.inc.php	(revision 6212)
+++ includes/discovery/ucd-diskio.inc.php	(working copy)
@@ -27,7 +27,7 @@
   {
     if ($entry['diskIONRead'] > "0" || $entry['diskIONWritten'] > "0")
     {
-      if ($debug) { echo("$index ".$entry['diskIODevice']."\n"); }
+      print_debug("$index ".$entry['diskIODevice']);
       if (isset($entries_db[$index]) && $entries_db[$index]['diskio_descr'] == $entry['diskIODevice'] )
       {
         // Entries match. Nothing to do here!
@@ -56,8 +56,6 @@
   dbDelete('ucd_diskio', '`diskio_id` = ?', array($entry['diskio_id']));
 }
 
-/// FIXME - migrate this to dbFacile
+echo(PHP_EOL);
 
-echo("\n");
-
-?>
+// EOF
Index: includes/include-dir-mib.inc.php
===================================================================
--- includes/include-dir-mib.inc.php	(revision 6212)
+++ includes/include-dir-mib.inc.php	(working copy)
@@ -12,8 +12,6 @@
  *
  */
 
-global $debug;
-
 /* not finished yet --mike
 if (isset($config['os'][$device['os']]['detect']) && $config['os'][$device['os']]['detect'])
 {
@@ -41,12 +39,12 @@
   {
     if (is_file($inc_file))
     {
-      if ($debug) { echo("[[$mib]]"); }
+      print_debug("[[$mib]]");
       include($inc_file);
     }
     else if (is_dir($inc_dir))
     {
-      if ($debug) { echo("[[$mib]]"); }
+      print_debug("[[$mib]]");
       foreach (glob($inc_dir.'/*.inc.php') as $dir_file)
       {
         if (is_file($dir_file))
Index: includes/include-dir.inc.php
===================================================================
--- includes/include-dir.inc.php	(revision 6212)
+++ includes/include-dir.inc.php	(working copy)
@@ -11,8 +11,6 @@
  *
  */
 
-global $debug;
-
 // This is an include so that we don't lose variable scope.
 
 if ($include_dir_regexp == "" || !isset($include_dir_regexp))
@@ -26,7 +24,7 @@
   {
     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"); }
+      print_debug('Including: ' . $config['install_dir'] . '/' . $include_dir . '/' . $file);
 
       include($config['install_dir'] . '/' . $include_dir . '/' . $file);
     }
Index: includes/polling/bgp-peers.inc.php
===================================================================
--- includes/polling/bgp-peers.inc.php	(revision 6212)
+++ includes/polling/bgp-peers.inc.php	(working copy)
@@ -271,7 +271,7 @@
     $polled = time();
     $polled_period = $polled - $peer['bgpPeer_polled'];
 
-    if ($debug) { echo("[ polled $polled -> period $polled_period ]"); }
+    print_debug("[ polled $polled -> period $polled_period ]");
 
     $peer_rrd = 'bgp-' . $peer_ip . '.rrd';
 
@@ -336,7 +336,7 @@
       {
         $afi = $peer_afi['afi'];
         $safi = $peer_afi['safi'];
-        if ($debug) { echo("$afi $safi\n"); }
+        print_debug("$afi $safi");
 
         if ($device['os_group'] == "cisco")
         {
Index: includes/polling/ospf.inc.php
===================================================================
--- includes/polling/ospf.inc.php	(revision 6212)
+++ includes/polling/ospf.inc.php	(working copy)
@@ -303,7 +303,7 @@
 
       foreach ($ospf_nbr_oids as $oid)
       { // Loop the OIDs
-        if ($debug) { echo($ospf_nbr_db[$oid]."|".$ospf_nbr_poll[$oid]."\n"); }
+        print_debug($ospf_nbr_db[$oid]."|".$ospf_nbr_poll[$oid]);
         if ($ospf_nbr_db[$oid] != $ospf_nbr_poll[$oid])
         { // If data has changed, build a query
           $ospf_nbr_update[$oid] = $ospf_nbr_poll[$oid];
@@ -347,6 +347,6 @@
 unset($ospf_ports_db);
 unset($ospf_ports_poll);
 
-echo("\n");
+echo(PHP_EOL);
 
 // EOF