# define DF_HAVE_READ 0
#endif
-#if HAVE_STATFS
-#define STATANYFS statfs
-#define BLOCKSIZE(s) (s).f_bsize
-
-#elif HAVE_STATVFS
-#define STATANYFS statvfs
-#define BLOCKSIZE(s) ((s).f_frsize ? (s).f_frsize : (s).f_bsize)
+#if HAVE_STATVFS
+# if HAVE_SYS_STATVFS_H
+# include <sys/statvfs.h>
+# endif
+# define STATANYFS statvfs
+# define BLOCKSIZE(s) ((s).f_frsize ? (s).f_frsize : (s).f_bsize)
+#elif HAVE_STATFS
+# if HAVE_SYS_STATFS_H
+# include <sys/statfs.h>
+# endif
+# define STATANYFS statfs
+# define BLOCKSIZE(s) (s).f_bsize
#endif
static char *filename_template = "df-%s.rrd";
-/* 104857600 == 100 MB */
static char *ds_def[] =
{
- "DS:used:GAUGE:25:0:U",
- "DS:free:GAUGE:25:0:U",
+ "DS:used:GAUGE:"COLLECTD_HEARTBEAT":0:U",
+ "DS:free:GAUGE:"COLLECTD_HEARTBEAT":0:U",
NULL
};
static int ds_num = 2;
static void df_read (void)
{
- struct STATANYFS statbuf;
+#if HAVE_STATVFS
+ struct statvfs statbuf;
+#elif HAVE_STATFS
+ struct statfs statbuf;
+#endif
+ /* struct STATANYFS statbuf; */
cu_mount_t *mnt_list;
cu_mount_t *mnt_ptr;
unsigned long long blocksize;
unsigned long long df_free;
unsigned long long df_used;
+ char mnt_name[BUFSIZE];
mnt_list = NULL;
if (cu_mount_getlist (&mnt_list) == NULL)
- {
- syslog (LOG_WARNING, "cu_mount_getlist returned `NULL'");
return;
- }
for (mnt_ptr = mnt_list; mnt_ptr != NULL; mnt_ptr = mnt_ptr->next)
{
-
if (STATANYFS (mnt_ptr->dir, &statbuf) < 0)
{
syslog (LOG_ERR, "statv?fs failed: %s", strerror (errno));
df_free = statbuf.f_bfree * blocksize;
df_used = (statbuf.f_blocks - statbuf.f_bfree) * blocksize;
- syslog (LOG_INFO, "blocksize = %llu, free = %llu, used = %llu, dir = %s", blocksize, df_free, df_used, mnt_ptr->dir);
- df_submit ("blahfoo", df_used, df_free);
+ if (strcmp (mnt_ptr->dir, "/") == 0)
+ {
+ strncpy (mnt_name, "root", BUFSIZE);
+ }
+ else
+ {
+ int i, len;
+
+ strncpy (mnt_name, mnt_ptr->dir + 1, BUFSIZE);
+ len = strlen (mnt_name);
+
+ for (i = 0; i < len; i++)
+ if (mnt_name[i] == '/')
+ mnt_name[i] = '-';
+ }
+
+ df_submit (mnt_name, df_used, df_free);
}
cu_mount_freelist (mnt_list);