[collectd] [PATCH 2/3] Entry in manpage for config option

Paul Sadauskas psadauskas at gmail.com
Wed Jul 29 05:41:27 CEST 2009


Signed-off-by: Paul Sadauskas <psadauskas at gmail.com>
---
 src/collectd.conf.pod |    6 ++++++
 src/df.c              |    9 +++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 8a5f6fd..6483755 100644
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -870,6 +870,12 @@ match any one of the criteria are collected. By default only selected
 partitions are collected if a selection is made. If no selection is configured
 at all, B<all> partitions are selected.
 
+=item B<ReportByDevice> I<true>|I<false>
+
+Report using the device name rather than the mountpoint. i.e. with this I<false>,
+(the default), it will report a disk as "root", but with it I<true>, it will be
+"sda1" (or whichever).
+
 =back
 
 =head2 Plugin C<disk>
diff --git a/src/df.c b/src/df.c
index 6319b18..8e64a32 100644
--- a/src/df.c
+++ b/src/df.c
@@ -117,7 +117,7 @@ static int df_config (const char *key, const char *value)
 				|| (strcasecmp (value, "Yes") == 0)
 				|| (strcasecmp (value, "On") == 0))
 		{
-                        by_device = false;
+                        by_device = true;
 		}
 		return (0);
 	}
@@ -187,7 +187,12 @@ static int df_read (void)
                 if (by_device) 
                 {
                         // eg, /dev/hda1  -- strip off the "/dev/"
-                        strncpy (disk_name, mnt_ptr->device + 5, sizeof (disk_name));
+                        strncpy (disk_name, mnt_ptr->spec_device + 5, sizeof (disk_name));
+                        if (strlen(disk_name) < 1) 
+                        {
+                              DEBUG("df: no device name name for mountpoint %s, skipping", mnt_ptr->dir);
+                              continue;
+                        }
                 } 
                 else 
                 {
-- 
1.6.3.3




More information about the collectd mailing list