Hi,

the blocks size is computed according to statvfs structure description (see 'man statvfs'):

--8<--
         struct statvfs {
           unsigned long  f_bsize;    /* file system block size */
           unsigned long  f_frsize;   /* fragment size */
           fsblkcnt_t     f_blocks;   /* size of fs in f_frsize units */
           fsblkcnt_t     f_bfree;    /* # free blocks */
           fsblkcnt_t     f_bavail;   /* # free blocks for non-root */
           fsfilcnt_t     f_files;    /* # inodes */
           fsfilcnt_t     f_ffree;    /* # free inodes */
           fsfilcnt_t     f_favail;   /* # free inodes for non-root */
           unsigned long  f_fsid;     /* file system ID */
           unsigned long  f_flag;     /* mount flags */
           unsigned long  f_namemax;  /* maximum filename length */
         };
--8<--

f_blocks has to be recomputed this way since it describes the number of fragments, not blocks (the f_bsize and f_frsize match on all linuxes which i ever saw even with different block sizes).

Martin


Aaron Scamehorn wrote:
Hello,

In device_usage_sysdep:

I'm not quite sure what the following is supposed to be calculating:

inf->f_blocks=          usage.f_blocks * usage.f_frsize / usage.f_bsize;


I think you're incorrectly mixing block size & fragment sizes.  I don't
think they have anything to do with each other.

You're probably just getting lucky, because your f_frsize & f_bsize both
= 4K.

However, on large filesystems, where f_bsize might be 32K, you'll get
crazy usage numbers.

I think you just want:

inf->f_blocks=          usage.f_blocks ;


Thanks,
Aaron

25        if(statvfs( dir, &usage) != 0) {
(gdb) n
(gdb) print usage
$1 = {f_bsize = 32768, f_frsize = 4096, f_blocks = 8811322, f_bfree =
8053030, f_bavail = 7605440,
  f_files = 35815424, f_ffree = 35800806, f_favail = 35800806, f_fsid =
0, __f_unused = 0, f_flag = 0,
    f_namemax = 255, __f_spare = {0, 0, 0, 0, 0, 0}}


_______________________________________________
monit-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monit-dev


_______________________________________________
monit-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monit-dev

Reply via email to