Understanding Limits on Executed Event Policies and Memory Allocation for Scripts
By default, on a device running Junos OS, the maximum number of event policies that can run concurrently in the system is 15, and the maximum amount of memory allocated for the data segment portion of an executed script is half of the total available memory of the system, up to a maximum value of 128 MB. If a script requires more memory during execution than the set maximum limit, the script exits. If the system is running the maximum number of event policies, the system ignores any triggered event policy until such time that another policy finishes. The system logs the EVENTD_POLICY_LIMIT_EXCEEDED message for any triggered event policies that were not executed.
Starting in Junos OS Release 12.3, you can configure limits on the maximum number of concurrently running event policies and the maximum amount of memory allocated for the data segment for scripts of a given type. Depending on the device and its function in the network, it might be necessary to configure larger or smaller limits on the number of event policies that can execute concurrently and the maximum amount of memory allocated to scripts. You might configure smaller limits on critical devices to ensure that priority processes are not adversely impacted, and that the device can perform all necessary functions in the network.
Additionally, during normal device operation, you might want to allocate disproportionate amounts of memory to different script types. A device might have a particular type of script that plays a vital role in its operation and requires a specific amount of memory to ensure proper execution. For example, when committing a configuration that is inspected by one or more commit scripts, you might need to increase the amount of memory allocated to the commit scripts to accommodate the processing of large configurations.
To set the maximum number of event policies that can run concurrently on a device, configure the max-policies policies statement at the [edit event-options] hierarchy level. You can configure a maximum of 0 through 20 policies.
To set the maximum memory allocated to the data segment for scripts of a given type, configure the max-datasize size statement under the hierarchy appropriate for that script type, where size is the memory in bytes. To specify the memory in kilobytes, megabytes, or gigabytes, append k, m, or g, respectively, to the size. On devices running 32-bit Junos OS, you can configure the memory in the range from 23,068,672 bytes (22 MB) through 1,073,741,824 bytes (1 GB). On devices running 64-bit Junos OS, you can configure the maximum memory in the range from 23,068,672 bytes (22 MB) through 1,073,741,824 bytes (1 GB) for SNMP scripts and from 23,068,672 bytes (22 MB) through 3,221,225,472 (3 GB) for commit, event, op, and translation scripts.
When the max-datasize statement is configured and a script executes, Junos OS sets the maximum memory limit for that script to the configured value irrespective of the total memory available on the system at the time of execution. If the script exceeds the maximum memory limit during execution, it exits gracefully.