Vous êtes sur la page 1sur 6

Function accessedbefore

Synopsis: accessedbefore(arg1,arg2) returns type class


arg1 : Newer filename, in the range "?(/.*)
arg2 : Older filename, in the range "?(/.*)
True if arg1 was accessed before arg2 (atime)
Example:
bodycommoncontrol
{
bundlesequence=>{"example"};
}
###########################################################

bundleagentexample
{
classes:
"do_it"and=>{accessedbefore("/tmp/earlier","/tmp/later"),"linux"};
reports:
do_it::
"Thesecretchangeshavebeenaccessedafterthereferencetime";
}

Function changedbefore
Synopsis: changedbefore(arg1,arg2) returns type class

arg1 : Newer filename, in the range "?(/.*)


arg2 : Older filename, in the range "?(/.*)

True if arg1 was changed before arg2 (ctime)


Example:
bodycommoncontrol
{
bundlesequence=>{"example"};
}
###########################################################

bundleagentexample
{
classes:
"do_it"and=>{changedbefore("/tmp/earlier","/tmp/later"),"linux"};
reports:
do_it::
"Thederivedfileneedsupdating";
}

Function groupexists
Synopsis: groupexists(arg1) returns type class

arg1 : Group name or identifier, in the range .*


True if group or numerical id exists on this host
Example:

bodycommoncontrol
{
bundlesequence=>{"example"};
}
###########################################################

bundleagentexample
{
classes:
"gname"expression=>groupexists("users");
"gid"expression=>groupexists("100");
reports:
gname::
"Groupexistsbyname";
gid::
"Groupexistsbyid";
}

Function getusers
Synopsis: getusers(arg1,arg2) returns type slist

arg1 : Comma separated list of User names, in the range .*


arg2 : Comma separated list of UserID numbers, in the range .*
Get a list of all system users defined, minus those names defined in arg1 and uids in arg2
Example:

vars:
"allusers"slist=>getusers("zenoss,mysql,at","12,0");
reports:
linux::
"Founduser$(allusers)";

Notes:
History: Was introduced in version 3.1.0b1,Nova 2.0.0b1 (2010) This function is only available on
Unix-like systems in the present version.
The function has two arguments, both are comma separated lists. The first argument is a list of user
names that should be excluded from the output. The second is a list of integrer UIDs that should be
excluded

Function translatepath
Synopsis: translatepath(arg1) returns type string

arg1 : Unix style path, in the range "?(/.*)


Translate path separators from Unix style to the host's native
Example:
bodycommoncontrol
{
bundlesequence=>{"test"};
}
##############################

bundleagenttest

{
vars:
"inputs_dir"string=>translatepath("$(sys.workdir)/inputs");
reports:
windows::
"Thepathhasbackslashes:$(inputs_dir)";
!windows::
"Thepathhasslashes:$(inputs_dir)";
}

Notes:
Takes a string argument with slashes as path separators and translate these to the native format for
path separators on the host. For example translatepath("a/b/c") would yield "a/b/c" on Unix
platforms, but "a\b\c" on Windows.
Be careful when using this function in combination with regular expressions, since backslash is also
used as escape character in regex's. For example, in the regex dir/.abc, the dot represents the
regular expression "any character", while in the regex dir\.abc, the backslash-dot represents a
literal dot character

Function diskfree
Synopsis: diskfree(arg1) returns type int

arg1 : File system directory, in the range "?(/.*)


Return the free space (in KB) available on the directory's current partition (0 if not found)
Example:
bundleagentexample
{
vars:

"free"int=>diskfree("/tmp");
reports:
cfengine_3::
"Freedisk$(free)";
}

Notes:
Values returned in kilobytes

Vous aimerez peut-être aussi