Commonly Used Functions
Commonly Used Functions
bundleagentexample
{
classes:
"do_it"and=>{accessedbefore("/tmp/earlier","/tmp/later"),"linux"};
reports:
do_it::
"Thesecretchangeshavebeenaccessedafterthereferencetime";
}
Function changedbefore
Synopsis: changedbefore(arg1,arg2) returns type class
bundleagentexample
{
classes:
"do_it"and=>{changedbefore("/tmp/earlier","/tmp/later"),"linux"};
reports:
do_it::
"Thederivedfileneedsupdating";
}
Function groupexists
Synopsis: groupexists(arg1) returns type class
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
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
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
"free"int=>diskfree("/tmp");
reports:
cfengine_3::
"Freedisk$(free)";
}
Notes:
Values returned in kilobytes