Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Fri Jul 28, 2017 12:11 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Suggestion for Discovery Export
PostPosted: Tue Jul 03, 2012 4:11 am 
Offline

Joined: Thu Jul 07, 2005 5:14 pm
Posts: 16
Location: Melb, Australia
Just tried the export function and noticed it doesn't enclose the fields it exports in quotes, which creates an issue when opening in Excel as fields get shifted if they contain a comma.

Have just changed my discover.php as per the below patch to enclose the fields in quotes which Excel recognises.
Would be handy if this was included in the mainline code either as an option or by default.

Code:
--- /discover.php   Thu Dec 22 08:27:32 2011
+++ /discover (2).php   Tue Jul 03 18:58:07 2012
@@ -156,17 +156,17 @@
      foreach($host as $h=>$r) {
         $host['$h'] = str_replace(',','',$r);
      }
-      print $host['hostname'] . ",";
-      print $host['ip'] . ",";
-      print $host['community'] . ",";
-      print $host['sysName'] . ",";
-      print $host['sysLocation'] . ",";
-      print $host['sysContact'] . ",";
-      print $host['sysDescr'] . ",";
-      print $host['os'] . ",";
-      print $uptime . ",";
-      print $host['snmp'] . ",";
-      print $host['up'] . "\n";
+      print "\"" . $host['hostname'] . "\"" . ",";
+      print "\"" . $host['ip'] . "\"" . ",";
+      print "\"" . $host['community'] . "\"" . ",";
+      print "\"" . $host['sysName'] . "\"" . ",";
+      print "\"" . $host['sysLocation'] . "\"" . ",";
+      print "\"" . $host['sysContact'] . "\"" . ",";
+      print "\"" . $host['sysDescr'] . "\"" . ",";
+      print "\"" . $host['os'] . "\"" . ",";
+      print "\"" . $uptime . "\"" . ",";
+      print "\"" . $host['snmp'] . "\"" . ",";
+      print "\"" . $host['up'] . "\"" . "\n";
   }
   exit;
}


Cheers,
Karl


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group