Persistent variables
Persistent variables are a method of setting variables that persist for a specified time and are synchronized across all of the policy servers in the enterprise. Procedures are provided to list, get, set and delete persistent variables.
delpersistentvar
Description
The delpersistentvar() procedure deletes a persistent variable from the local database. This deletion is synchronized to the other specified policy servers.
Syntax
boolean delpersistentvar(wildcard)
Arguments
name | Required. A glob(3) wildcard limiting the deleted variables to those matched. |
Return values
A boolean indicating success or failure of the procedure.
Example
delpersistentvar("flag\*")
getpersistentvarint
Description
The getpersistentvarint() procedure retrieves a persistent variable from the local database. If the variable does not exist, or has expired, it returns the default 0.
Syntax
int getpersistentvarint(name)
Arguments
name | Required. The name of the variable to be retrieved. This can be any text string. |
Return values
An integer containing the variable contents, or zero if the variable does not exist or has expired.
Example
myflag = getpersistentvarint("flag\_" + submituser)
getpersistentvarlist
Description
The getpersistentvarlist() procedure retrieves a persistent variable from the local database. If the variable does not exist, or has expired, it returns the default empty list {}.
Syntax
list getpersistentvarlist(name)sna
Arguments
name | Required. The name of the variable to be retrieved. This can be any text string. |
Return values
A list containing the variable contents, or an empty list if the variable does not exist or has expired.
Example
mylist = getpersistentvarlist("hosts\_" + submituser)
getpersistentvarstring
Description
The getpersistentvarstring() procedure retrieves a persistent variable from the local database. If the variable does not exist, or has expired, it returns the default empty string "".
Syntax
string getpersistentvarstring(name)
Arguments
name | Required. The name of the variable to be retrieved. This can be any text string. |
Return values
A string containing the variable contents, or an empty string ("") if the variable does not exist or has expired.
Example
mystr = getpersistentvarstring("msg\_" + submituser)
listpersistentvars
Description
The listpersistentvars() procedure returns a list of currently active persistent variables. Variables that expire are not retrieved.
Syntax
Var = listpersistentvars(wildcard)
Arguments
wildcard | Optional. A glob(3) wildcard limiting the returned values to those matched. |
Return values
A list that contains the current active persistent variables.
Example
vars = listpersistentvars("a\*");
setpersistentvar
Description
The setpersistentvar() procedure sets a persistent variable in the local database, and synchronizes the value to other specified policy servers.
- If Registry Name Service is enabled, it synchronizes to all of the other policy servers in the Service Group.
- If Registry Name Service is not enabled, it synchronizes to all of the other policy servers specified by the submitmasters setting on the current policy server.
Syntax
boolean setpersistentvar(name,value,[expiry])
Arguments
name | Required. The name of the variable to be set. This can be any text string. |
Value | Required. The value of the variable. This can be an integer, string, or list values. |
Expiry | Optional. This is the UNIX epoch (in seconds) of the expiry date of the variable. Suitable values can be calculated using unixtimestamp with additional seconds calculated using Date/Time functions. |
Return values
A boolean indicating success or failure of the procedure.
Example
setpersistentvar("flag\_" + submituser,true,unixtimestamp+300)
Updated 5 days ago