Scripting How-To: Use system variables in a command in an event-options policy definition

By Elevate posted 02-18-2016 13:23



If the command to automate an operation requires the hostname of a system and the IP address of a DHCP-based interface, is it possible to use these dynamic values in a command in an event-options policy definition?



No. However, there are some variables that are available from within an event script. So if you define the event-option policy to execute an event script, the event script would then have access internally to a variable, such as $HOSTNAME, which would contain the hostname of the local Routing Engine that the script is running on, or the script could make a remote procedure call (RPC) to obtain the configured hostname of the device, and so on.

In a scenario where you want some other variable out of the system to be processed such as in the example of the DHCP-based IP address, then the script can make an RPC to obtain that information and then parse the response to trigger the necessary actions.