APPENDIX D: Scripts and Events – Best Practices
There are three primary mechanisms for executing a script: Against a single device, Events and en mass via Bulk Operations. All of the following best practices apply regardless of the script delivery method used.
Scripts
When designing a script, keep it lean with only essential functions. Audit scripts regularly to ensure the tasks they perform are still relevant and necessary. Also audit for redundant calls within the same script. Remove all non-essential functions to ensure the session time required when the script runs is minimal. Five seconds of session time to execute a script against a device might not seem like much. Multiply that by hundreds of thousands or perhaps millions of devices in your subscriber population and the necessity for minimalism becomes more clear.
Exercise judicious use of scripting calls that initiate device communications.
- tr069.sync.syncApps()
- tr069.get()
- tr069.set()
- tr069.setMany()
- tr069.setNotify()
- tr069.has()
- tr069.create()
- tr069.destroy()
- tr069.useDownloadCredentials()
- tr069.downloadFirmware()
- tr069.downloadConfigFile()
- tr069.reboot()
- tr069.rebootNow()
The above are prime example operations which are costly in terms of server resources. When executed via an Event experienced by your entire subscriber population or triggered under Bulk Operations (multiplied over potentially thousands or millions of devices) this can serve to degrade system performance and may slow processing time. Apply vigilant, lean thinking at all times.
To illustrate this, operations like tr069.reboot() of many CPE devices in short succession should be used with care. The mass numbers of devices attempting to inform to your instance of Device Manager immediately following the reboot can potentially slow system operation. Consider running scripts of this nature in small, manageable batches. Some experimentation of small groups of devices then slowly, incrementally larger batches of devices will be required to fully understand the impact on the unique properties of your Device Manager Instance.
Contact your Adtran Sales Engineer or the Customer Service team for the relevant specs of your particular Device Manager instance and for any other questions you may have related to your scripting or bulk operations needs.
Events
The process of script design and planning inevitably leads to the question of — under what circumstance should this script be executed? This brings us to the topic of Events in Device Manager and some dos and don'ts as they relate to scripting.
You can read more about events here but in short, Device Manager defines the following types:
- Initial Contact
- Subscriber Associated
- Reboot
- Service Enable
- Service Disable
- Firmware Upgraded
- Inform
Give careful consideration to which event you’ll attach your script to with an eye for minimal impact on system resources. For example, running a script every time the device informs may not be truly necessary. In a typical environment, subscriber devices inform once a day (configurable). In all likelihood, your subscriber devices don’t truly benefit from daily re-exposure to the functions of most scripts. Instead, select a less frequent event that is more appropriate and complimentary to the intended benefit your script will render.
Triggering your scripts via the Initial Contact event should also be used sparingly.
Bulk Operations
Similar cautionary practices also apply to Bulk Operations in general but great care and planning should be exercised especially for Bulk Operations that trigger scripts. See Bulk Operations - Best Practices for more on this topic.