UNC free space calculation

Remote Monitoring Agent for Linux, FreeBSD, and other UNIX-like platforms.
Post Reply
evilmonkey
Posts: 6
Joined: Tue Jul 03, 2007 8:08 pm

UNC free space calculation

Post by evilmonkey »

Can you publish what formula you use to calculate percentage free for UNC?


Using linux RMA we get a discrepency on Debian based system. e.g.:

OS says:
9.1G 7.2G 1.5G 84% /var

Where 84% is amount used

HM says:
Reply: 21%

Where alert is set to alert on percent < 20%

I've also seen different behaviour than the above from RedHat where the mount didn't work (e.g. /var) but adding the dev device did.

I don't think this is a problem with RMA seems more like someone is using the HD idea of disk and the other the OS idea of disk.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Actually, RMA uses standard function statfs() to retrieve free space information. What exact free space parameter do you check: free space for current user or the total free space?

Regards,
Max
Last edited by KS-Soft Europe on Mon Nov 26, 2007 7:54 am, edited 1 time in total.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Code is pretty simple

Code: Select all

  struct statfs statbuf;
  if (statfs(path, &statbuf)==0)
  {
     total = (int64)(statbuf.f_blocks) * statbuf.f_bsize;
     free  = (int64)(statbuf.f_bfree)  * statbuf.f_bsize;
     freeforuser = (int64)(statbuf.f_bavail) * statbuf.f_bsize;
     return True;
  }
  else return False;
Regards
Alex
Post Reply