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

by Juniper Employee on ‎02-18-2016 01:23 PM - edited on ‎08-23-2017 12:39 PM by Administrator Administrator (1,778 Views)


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.