Dampening Script Execution
The Junos OS software automation feature enables you to create commit, op, event, and SNMP scripts to automate devices running Junos OS. These scripts can be CPU-intensive, potentially impacting other critical software processes such as the routing protocol process (rpd). Starting in Junos OS Release 14.1, you can configure Junos OS to dampen or slow down the execution of SLAX and XSLT commit, op, and event scripts. Although the scripts are processed more slowly, enabling script dampening helps to ensure that the other critical software processes can function normally.
Script dampening is only supported for SLAX and XSLT scripts. Junos OS does not support script dampening for Python automation scripts.
The script dampening feature does not work for certain CPU-intensive remote procedure calls (RPCs), including the following:
Executing the following RPC might cause the software process to consume numerous CPU cycles. This cannot be avoided as it is outside the control of the cscript process and up to the software process to optimize.var $cmd = <command> "show snmp mib walk .1";var $out = jcs:invoke($cmd);
The cscript process might consume numerous CPU cycles for this particular RPC, as this involves parsing of the XML configuration returned by the management process (mgd). This cannot be avoided since a single line in the script triggers the processing.var $config = jcs:invoke("get-configuration");
To enable script dampening:
Include the dampen statement.
The dampen statement and the script dampening options configured under the dampen-options statement can be configured at various hierarchy levels, depending on the type of scripts you want to dampen and whether or not you want to apply dampening to specific scripts or all scripts.
You can dampen all event scripts by configuring the dampen statement at the [edit event-options event-script] hierarchy level or dampen a specific event script by configuring the dampen statement at the [edit event-options event-script file filename] hierarchy level.
You can dampen all op scripts by configuring the dampen statement at the [edit system scripts op] hierarchy level or dampen a specific op script by configuring the dampen statement at the [edit system scripts op file filename] hierarchy level.
Script dampening is only enforced for op scripts that are local to the device. If you execute an op script from a remote location using the op url command, Junos OS does not dampen the script.
You can dampen all commit scripts by configuring the dampen statement at the [edit system scripts commit] hierarchy level. You cannot dampen a specific commit script. This is a limitation of the cscript process which runs a single commit script at a time.
(Optional) Modify the behavior of the script dampening feature by configuring the following dampening options:
cpu-factor—Script dampening is initiated when CPU use exceeds the value specified using this statement.
line-interval—Specifies the number of lines of script Junos OS executes before pausing.
time-interval—Specifies the time that script execution is paused.
To configure the script dampening options, configure the following statements. If you configure the dampen statement and do not configure values for these statements, the defaults are used. You can configure the dampen-options statements at all of the hierarchy levels at which you can configure the dampen statement.
If you configure the dampen-options statements at both a global hierarchy level (for example, at the [edit event-options event-script] hierarchy level) or for a specific script (for example, at the [edit event-options event-script file filename] hierarchy level), the file hierarchy level configuration takes precedence.
Configure the traceoptions statement to help debug issues related to the script dampening feature.
For commit scripts, include the events flag in the traceoptions statement configuration.[edit system scripts commit traceoptions]flag events;
For event scripts, include the events flag in the traceoptions statement configuration.[edit event-options event-script traceoptions]flag events;
For op scripts, include the events flag in the traceoptions statement configuration.[edit system scripts op traceoptions]flag events;
Dec 11 21:40:40 cscript: paused for 100 microseconds