getindices
Prototype: getindices(varref)
Return type: slist
Description: Returns the list of keys in varref
which can be
the name of an array or container.
This function can accept many types of data parameters.
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:.*
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");
"parameter_name_sorted" slist => sort(parameter_name, lex);
reports:
"Found key $(parameter_name_sorted)";
}
Output:
R: Found key default_privs
R: Found key inet_interfaces
R: Found key inet_protocols
R: Found key mydomain
R: Found key relayhost
R: Found key smtp_sasl_auth_enable
R: Found key smtp_sasl_password_maps
R: Found key smtp_sasl_security_options
R: Found key smtp_use_tls
History: The collecting function behavior was added in 3.9.
See also: getvalues()
, about collecting functions, and data
documentation.