Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Configure Script Start Options

SUMMARY Configure the device to perform specific system resource checks before executing a script.

You can configure start options for certain types of scripts on supported platforms. When you configure start options, the device performs specific system resource checks before executing a script. The checks determine whether the system should start or prevent script execution based on the configured values. By configuring script start options you can ensure that a device executes only essential scripts when system resources are limited, thereby enabling the device to continue performing all critical network functions.

You can configure start options to prevent script execution based on the system's memory usage, as described in Configure the System Memory Usage Threshold for Scripts.

You configure script start options to prevent a script from executing under certain conditions. To instead enable the device to start a script but slow the script's execution or halt the script if it exceeds certain limits as it runs, see the following documentation:

Configure the System Memory Usage Threshold for Scripts

You can configure a device to prevent a script from executing if the system's memory usage is above a configured threshold. For example, you might want to prevent the execution of a particularly resource intensive script or type of script if the system memory usage is above 75 percent. Alternatively, if a particular script plays a vital role in the device's operation, you might configure a higher system memory usage threshold or no threshold for that specific script to ensure that the device still executes the script even if the system has more limited resources at that time.

You configure the start start-options mem-factor statement to define the system memory usage threshold above which a script does not execute. You can define a threshold for op, event, SNMP, and Juniper Extension Toolkit (JET) scripts. You can apply the statement to an individual script or to all scripts of a given type. When you configure the statement for a type of script, for example, op scripts, the statement applies to all Python, SLAX, and XSLT scripts of that type. If you define different thresholds for the script type and an individual script of the same type, the configuration for the individual script takes precedence.

Note:

Junos devices do not enforce script start options for remote op scripts, which are executed using the op url command. Script start options are enforced only for local op scripts.

Note:

For JET applications, the daemonize and mem-factor statements are mutually exclusive. If a JET application includes the daemonize statement in its configuration, you cannot configure the mem-factor statement either for that individual script or globally for all JET scripts. If you configure both statements and commit the configuration, the device issues a commit error.

When you execute a script that has the mem-factor statement configured for that script or that type of script, the device compares the current system memory usage to the configured mem-factor value. If the system memory usage is lower than the configured threshold, then the script executes normally. If the system memory usage exceeds the configured threshold, the device does not execute the script and generates a system log message to that effect. If you do not configure the mem-factor statement for either the individual script or script type, then the system does not perform any system memory usage checks and executes the script normally.

Junos devices calculate the system memory usage differently depending on the operating system. Junos OS uses the following calculation to determine the system memory usage:

For example, consider the following show system memory command output on a device running Junos OS:

In this case, the current system memory usage is approximately twenty-seven percent. If you a invoke a script, the device does not execute the script if this usage exceeds the configured mem-factor value for that script. The device compares the usage against the mem-factor value for the script type only if you do not configure the mem-factor statement for the individual script.

Junos OS Evolved includes the system memory usage directly in the show system memory command's XML output.

When you invoke a script that has the mem-factor statement configured, the device logs the CSCRIPT_START_OPTIONS_MEM_FACTOR system log message with severity level INFO.

If a device prevents the execution of a script because the current system memory usage exceeds the configured threshold, the cscript process records system log messages in the log file. The CLI does not issue any warning or error that the script was halted. The device logs the CSCRIPT_START_OPTIONS_SYSTEM_MEM and CSCRIPT_START_OPTIONS_WARNING system log messages with severity level WARNING for this event.

Note:

The CLI does not indicate if the device halts a script's execution. For example, op scripts do not emit any output in this case, SNMP scripts return a No such instance error, and JET scripts still emit a message that the extension service application was started. You must always refer to the system log messages to confirm that the device prevented a script from running.

Configure Start Options for Individual Scripts

To configure script start options for individual scripts:

  1. Configure the threshold for system memory usage above which the device does not execute the specified script. Configure the threshold percentage (1 through 100) at the file filename hierarchy level for the specific script.
  2. Commit the configuration.

Configure Start Option for All Scripts of a Given Type

To configure script start options for all scripts of a given type:

  1. Configure the threshold for system memory usage above which the device does not execute any script of the specified type. Configure the threshold percentage (1 through 100) at the configuration hierarchy level for that script type.
  2. Commit the configuration.