getindices

Table of Contents

Prototype: getindices(varref)

Return type: slist

Description: Returns the list of keys in varref which can be the name of an array or container.

Make sure you specify the correct scope when supplying the name of the variable.

Note the list which getindices returns is not guaranteed to be in any specific order.

In the case of a doubly-indexed array (such as parsestringarrayidx and friends produce), the primary keys are returned; i.e. if varref[i][j] exist for various i, j and you ask for the keys of varref, you get the i values. For each such i you can then ask for getindices("varref[i]") to get a list of the j values (and so on, for higher levels of indexing).

Arguments:

  • varref: string, in the range: [a-zA-Z0-9_$(){}\[\].:]+

Example:

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

bundle agent example
{
  vars:

      "ps[relayhost]"                  string => "[mymailrelay]:587";
      "ps[mydomain]"                   string => "iu.hio.no";
      "ps[smtp_sasl_auth_enable]"      string => "yes";
      "ps[smtp_sasl_password_maps]"    string => "hash:/etc/postfix/sasl-passwd";
      "ps[smtp_sasl_security_options]" string => "";
      "ps[smtp_use_tls]"               string => "yes";
      "ps[default_privs]"              string => "mailman";
      "ps[inet_protocols]"             string => "all";
      "ps[inet_interfaces]"            string => "127.0.0.1";

      "parameter_name" slist => getindices("ps");

  reports:

      "Found key $(parameter_name)";
}

Output:

R: Found key inet_protocols
R: Found key mydomain
R: Found key smtp_use_tls
R: Found key smtp_sasl_password_maps
R: Found key smtp_sasl_security_options
R: Found key relayhost
R: Found key default_privs
R: Found key inet_interfaces
R: Found key smtp_sasl_auth_enable