Fixing compile-errors/-warnings when building without librrd.
[collectd.git] / src / disk.c
index 4e53df0..ded2080 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/disk.c
- * Copyright (C) 2005  Florian octo Forster
+ * Copyright (C) 2005,2006  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -38,24 +38,24 @@ static char *part_filename_template = "partition-%s.rrd";
 /* 104857600 == 100 MB */
 static char *disk_ds_def[] =
 {
-       "DS:rcount:COUNTER:25:0:U",
-       "DS:rmerged:COUNTER:25:0:U",
-       "DS:rbytes:COUNTER:25:0:104857600",
-       "DS:rtime:COUNTER:25:0:U",
-       "DS:wcount:COUNTER:25:0:U",
-       "DS:wmerged:COUNTER:25:0:U",
-       "DS:wbytes:COUNTER:25:0:104857600",
-       "DS:wtime:COUNTER:25:0:U",
+       "DS:rcount:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rmerged:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rbytes:COUNTER:"COLLECTD_HEARTBEAT":0:104857600",
+       "DS:rtime:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wcount:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wmerged:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wbytes:COUNTER:"COLLECTD_HEARTBEAT":0:104857600",
+       "DS:wtime:COUNTER:"COLLECTD_HEARTBEAT":0:U",
        NULL
 };
 static int disk_ds_num = 8;
 
 static char *part_ds_def[] =
 {
-       "DS:rcount:COUNTER:25:0:U",
-       "DS:rbytes:COUNTER:25:0:104857600",
-       "DS:wcount:COUNTER:25:0:U",
-       "DS:wbytes:COUNTER:25:0:104857600",
+       "DS:rcount:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:rbytes:COUNTER:"COLLECTD_HEARTBEAT":0:104857600",
+       "DS:wcount:COUNTER:"COLLECTD_HEARTBEAT":0:U",
+       "DS:wbytes:COUNTER:"COLLECTD_HEARTBEAT":0:104857600",
        NULL
 };
 static int part_ds_num = 4;
@@ -65,6 +65,9 @@ typedef struct diskstats
 {
        char *name;
 
+       /* This overflows in roughly 1361 year */
+       unsigned int poll_count;
+
        unsigned int read_sectors;
        unsigned int write_sectors;
 
@@ -300,6 +303,10 @@ static void disk_read (void)
                read_bytes  = ds->read_bytes;
                write_bytes = ds->write_bytes;
 
+               /* Don't write to the RRDs if we've just started.. */
+               ds->poll_count++;
+               if (ds->poll_count <= 6)
+                       continue;
 
                if ((read_count == 0) && (write_count == 0))
                        continue;