[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Detecting free disk space by percentage?
From: |
Hugo Gayosso |
Subject: |
Re: Detecting free disk space by percentage? |
Date: |
08 Apr 2002 16:36:47 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ok, I think I found it as an undocumented feature.
Looking at the source of the function CheckFreeSpace:
if (kilobytes < 0) /* percentage */
{
free = GetDiskUsage(file,cfpercent);
kilobytes = -1 * kilobytes;
if (free < kilobytes)
{
snprintf(OUTPUT,bufsize*2,"Free disk space is under %d%% for
partition\n",kilobytes);
CfLog(cfinform,OUTPUT,"");
snprintf(OUTPUT,bufsize*2,"containing %s (%d%% free)\n",file,free);
CfLog(cfinform,OUTPUT,"");
return false;
}
}
it seems that if I use a negative number when defining 'freespace',
cfengine will take it as a percentage instead of Kilobytes.
Mark, why were you hiding this gold nugget from us? :-)
I test it:
# Temporary test
disks:
myhost::
/tmp freespace=5000000 define=Fulltmp
/var freespace=-90 define=Fullvar
shellcommands:
myhost.Fulltmp::
"/bin/echo /tmp full !!"
myhost.Fullvar::
"/bin/echo /var full !!"
But when I try to use it, cfengine complains:
disk/required size attribute with silly value (must be > 0)
Which can be found in the function: HandleRequiredSize
if (i < 1)
{
yyerror("disk/required size attribute with silly value (must be > 0)");
}
So, how can use that undocumented feature? (or what are the reasons I
shouldn't be using it?)
Greetings,
- --
Hugo Gayosso
Support the Free Software Movement!
GNU Project <http://www.gnu.org>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE8sf9ex2JZtTN6co8RAuRaAKDTteoDHamvQOELIq74BURAM3JBngCg+M4p
JfI4jMTMP227O1ofVtU/hr4=
=eD1k
-----END PGP SIGNATURE-----
- Detecting free disk space by percentage?, Hugo Gayosso, 2002/04/08
- Re: Detecting free disk space by percentage?,
Hugo Gayosso <=
- Re: Detecting free disk space by percentage?, Bas van der Vlies, 2002/04/09
- Re: Detecting free disk space by percentage?, Hugo Gayosso, 2002/04/09
- Re: Detecting free disk space by percentage?, Hugo Gayosso, 2002/04/09
- Re: Detecting free disk space by percentage?, Bas van der Vlies, 2002/04/09
- Re: Detecting free disk space by percentage?, Hugo Gayosso, 2002/04/11
- Re: Detecting free disk space by percentage?, Bas van der Vlies, 2002/04/12