Prototype: getgid(groupname)

Return type: int

Description: Return the integer group id of the group groupname on this host.

If the named group does not exist, the function will fail and the variable will not be defined.

Arguments:

  • groupname: string - Group name in text - in the range: .*

Example:

code
body common control
{
      bundlesequence => { "example" };
}

bundle agent example
{
  vars:
    linux|solaris|hpux::
      "gid" int => getgid("root");
    freebsd|darwin|openbsd::
      "gid" int => getgid("wheel");
    aix::
      "gid" int => getgid("system");

  reports:
      "root's gid is $(gid)";
}

Output:

code
R: root's gid is 0

Notes: On Windows, which does not support group ids, the variable will not be defined.