MIB Explorer can execute scripts based on VTL, the Velocity Template Language from Apache. Also VTL, in the first place, is designed for generating text or HTML output with dynamic content, its clear differentiation between model, view, and controller (MVC) makes it also a first choice for scripting.
The control structures provided by VTL are limited, but they also make it easy for users with little or no programming experience to write scripts based on VTL. Supported control statements are #if..#else..#end to conditionally execute statements and #foreach..#end to execute statements for each element of a given list. With the #macro statement parts of script that are frequently used can be combined into a function that can called in the script with #<macro_name>. Please refer to the VTL user guide for a complete description of the VTL language.
A MIB Explorer script differs from any other Velocity Macro (VM) only by the model MIB Explorer provides for the script. The model is accessed from a VM through contexts. To access the methods (services) provided by a context, a VTL reference with the context's name is used, for example
$utils.sleep(1000)
will cause the script to cease execution for one second by calling the sleep method of context utils. The contexts supported by MIB Explorer are shown in the table below. The Scope column indicates in which type of scripts the corresponding context can be used. The methods implemented by the contexts are documented in the JavaDoc HTML documentation also available in the api subdirectory of the doc directory in the MIB Explorer installation folder:
|
Context |
Scope |
Description |
|---|---|---|
|
snmp |
any |
The snmp context provides services to create SNMP request, load PDUs, modify their variable bindings, send SNMP requests and notifications synchronously and inspect SNMP responses. The context has several internal members which can be accessed through this interface:
|
|
smi mib |
any |
The mib context provides services to
|
|
utils |
any |
The utils context provides utility services to
|
|
parameters |
monitor-script-servlet |
The parameters context is a Map that associates (HTTP request) parameter names with a String array of associated values. Each parameter may thus have zero or more values. Note: This context is only available for scripts executed on behalf of the HTTP server script servlet. |
|
gui |
script-tool |
The gui context provides means to get input from the user when the script is executed. The user can be prompted for a string value, or for a variable binding. Note: This context is only available for scripts executed on behalf of the script tool pane of the MIB Explorer GUI. |
|
alarm |
monitor-alarm-script |
The alarm context provides information about the alarm event that triggered the script's execution. Note: This context is exclusively available for scripts executed on behalf of a monitor's alarm configuration. |
|
monitorname |
monitor-data-servlet |
The monitorname context contains the name of the monitor for which data is requested through a HTTP request to the monitor data servlet. Note: This context is exclusively available for scripts executed on behalf of monitor data servlet.
|
|
monitordata |
monitor-data-servlet |
The monitordata of the monitor for which data is requested through a HTTP request to the monitor data servlet. The monitordata object is an array of MonitorData instances. The first instance contains the primary data table or the requested consolidation table. If there are additional instances then these are all the consolidation data tables and the first one is the primary data table. The column labels can be accessed by calling the getColumnLabels() method. It returns the lables as a List. The cells of of a MonitorData object can be retrieved through getCells() which returns a List of row objects. Each row object is a List of columns containing Double or String objects. Note: This context is exclusively available for scripts executed on behalf of monitor data servlet. |
|
consolidationname |
monitor-data-servlet |
The consolidationname context contains the name of the consolidation table for which data is requested through a HTTP request to the monitor data servlet. This context is only available (not null) if a consolidation table has been requested explicitly. Note: This context is exclusively available for scripts executed on behalf of monitor data servlet. |
The script editor is divided into three areas: the Toolbar area, the Script area, and the Output area. The Script tab is used to edit the script whereas the Output tab shows the script's output from its last run.
|
Run
Executes the script once. The Output tab is selected and the script's output is shown as it is generated.
Stop/Abort
Stop the execution of the script.
Redo
Redo last change made to the script.
Undo
Undo last change made to the script.
Detach
Detach this script panel from the main window and show it in its own window.
Attach
Attach a previously detached window to the main window again.
|
Run Interval
Specifies the run interval in seconds. You can either use the predefined values or enter your own value. By pressing <Enter>, periodically script execution starts with the given interval. 0 deactivates periodical refresh.
During periodically script execution, the script is scheduled for repeated fixed-delay execution. Subsequent executions take place at approximately regular intervals, separated by the specified period.
In fixed-delay execution, each execution is scheduled relative to the actual execution time of the previous execution. If an execution is delayed for any reason (such as garbage collection or other background activity), subsequent executions will be delayed as well. In the long run, the frequency of execution will generally be slightly lower than the reciprocal of the specified period.
Start
Start periodically script execution, if the interval value is not zero (not "disabled").
Stop
Stop the periodical script execution.
Progress Bar
Shows the percentage of the execution pause period left until the next scheduled execution.
Export Output
By pressing the toggle button, a text file can be specified to store the script's output. While the export toggle button is selected the script's output is saved to the specified file whenever it is updated.