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: Aaron Scamehorn
Subject: RE: 4.8.2: device/sysdep_LINUX.c
Date: Wed, 6 Dec 2006 08:29:27 -0600

Awesome!

Thanks,
Aaron
 

-----Original Message-----
From: address@hidden
[mailto:address@hidden On
Behalf Of Martin Pala
Sent: Wednesday, December 06, 2006 6:33 AM
To: The monit developer list
Subject: Re: 4.8.2: device/sysdep_LINUX.c

Hi, sorry for the delay.

I have looked on it, you are right. Although the linux documentation of 
statvfs f_blocks says, that it is in f_frsize units, it seems that in 
fact the f_bsize is used.

I have tested it with different blocks sizes and filesystems (ext3, 
vfat, ntfs, udf) ... in all these cases the f_frsize was equal to 
f_bsize and monit provided correct result.

The NFS is different as you described - it reports 512B f_frsize and 
32KB f_bsize ... the f_blocks here is obviously in f_bsize. The monit 
result based on the f_frsize to f_bsize conversion was invalid.

The device/sysdep_LINUX.c was fixed, thanks for the patch and help :)

Martin


Aaron Scamehorn wrote:
> Hi Martin,
> 
> I don't think your assumption about f_bsize == f_frsize is valid.  And
> if it is, what is the point of multiplying by (usage.f_frsize /
> usage.f_bsize), which is always 1?
> 
> I don't see anything in the POSIX docs for statvfs stating that this
> math is necessary, nor that f_bsize == f_frsize is a rule.
> 
> I didn't see anything in the GNU coreutils package (df, du, stat, etc)
> doing this math either.
> 
> One place that this assumption breaks is for an nfs mounted partition;
> The default blocksize is 8K, usually larger (32K).
> 
> Please look at the attached test program, and it's associated output.
> 
> I think you'll see that statvfs is ultimately making the same system
> call that statfs does (as evidenced by the strace output), which gives
> you the proper f_blocks without any additional math necessary.
> 
> Thanks,
> Aaron
> 
> 
> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden On
> Behalf Of Martin Pala
> Sent: Friday, November 17, 2006 4:28 PM
> To: The monit developer list
> Subject: Re: 4.8.2: device/sysdep_LINUX.c
> 
> 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
> 
> 
> _______________________________________________
> monit-dev mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/monit-dev
> 
> 
>
------------------------------------------------------------------------
> 
> Script started on Mon 20 Nov 2006 11:39:20 AM CST
> address@hidden ~]$ a.out /cogcap
> -------------Incorrect f_blocks----------
> f_blocks=15073280
> Blocks free for non superuser 1540419 [48138.1 MB] [10.2%]
> Blocks free total 1636317 [51134.9 MB] [10.9%]
> --------------Correct f_blocks-----------
> f_blocks=1887811
> Blocks free for non superuser 1540419 [48138.1 MB] [81.6%]
> Blocks free total 1636317 [51134.9 MB] [86.7%]
> address@hidden ~]$ 
> address@hidden ~]$ 
> address@hidden ~]$ stat -f /cogcap
>   File: "/cogcap"
>     ID: 0        Namelen: 255     Type: nfs
> Blocks: Total: 1887811    Free: 1636308    Available: 1540411    Size:
32768
> Inodes: Total: 7684096    Free: 7460383   
> address@hidden ~]$ 
> address@hidden ~]$ 
> address@hidden ~]$ df -B 1024K /cogcap
> Filesystem           1M-blocks      Used Available Use% Mounted on
> nfs.cogcap.com:/export/cogcap
>                          58995      7860     48139  15% /cogcap
> address@hidden ~]$ 
> address@hidden ~]$ 
> address@hidden ~]$ strace -e trace=statfs,statfs64 a.out /cogcap >
/dev/null
> statfs("/cogcap", {f_type="NFS_SUPER_MAGIC", f_bsize=32768,
f_blocks=1887811, f_bfree=1636316, f_bavail=1540419, f_files=7684096,
f_ffree=7460383, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
> statfs("/cogcap", {f_type="NFS_SUPER_MAGIC", f_bsize=32768,
f_blocks=1887811, f_bfree=1636316, f_bavail=1540419, f_files=7684096,
f_ffree=7460383, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
> address@hidden ~]$ exit
> 
> Script done on Mon 20 Nov 2006 11:42:12 AM CST
> 
> 
>
------------------------------------------------------------------------
> 
> _______________________________________________
> monit-dev mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/monit-dev


_______________________________________________
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]