help-cfengine
[Top][All Lists]
Advanced

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

Re: Detecting free disk space by percentage?


From: Bas van der Vlies
Subject: Re: Detecting free disk space by percentage?
Date: Tue, 09 Apr 2002 08:18:01 +0100 (MET DST)

You must use the % sign (Inside the function it is a negative number to
distinquish between kb and %)

 /home freespace=10% 


On 08-Apr-2002 Hugo Gayosso wrote:
> -----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-----
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine

--
********************************************************************
*                                                                  *
*  Bas van der Vlies                     e-mail: basv@sara.nl      *
*  SARA - Academic Computing Services    phone:  +31 20 592 8012   *
*  Kruislaan 415                         fax:    +31 20 6683167    *
*  1098 SJ Amsterdam                     WWW:    www.sara.nl       *
*                                                                  *
********************************************************************



reply via email to

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