monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 4.8.2: device/sysdep_LINUX.c


From: Martin Pala
Subject: Re: 4.8.2: device/sysdep_LINUX.c
Date: Fri, 17 Nov 2006 23:27:35 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060809 Debian/1.7.13-0.3

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
address@hidden
http://lists.nongnu.org/mailman/listinfo/monit-dev




reply via email to

[Prev in Thread] Current Thread [Next in Thread]