191
Verifying the configuration
# Display information about the policy.
[Sysname-rtm-test] display rtm policy registered
Total number: 1
Type Event TimeRegistered PolicyName
CLI CLI Aug 29 14:56:50 2013 test
# Enable the information center to output log messages to the current monitoring terminal.
[Sysname-rtm-test] return
<Sysname> terminal monitor
# Enter a question mark (?) at a command line that contains a letter
d
. Verify that the system displays the
"hello world" message and a policy successfully executed message on the terminal screen.
<Sysname> d?
debugging
delete
diagnostic-logfile
dir
display
<Sysname>d%May 7 02:10:03:218 2013 Sysname RTM/4/RTM_ACTION: "hello world"
%May 7 02:10:04:176 2013 Sysname RTM/6/RTM_POLICY: CLI policy test is running
successfully.
CLI-defined policy with EAA environment variables
configuration example
Network requirements
Define an environment variable to match the IP address 1.1.1.1.
Configure a policy from the CLI to monitor the event that occurs when a command line that contains
loopback0
is executed. In the policy, use the environment variable for IP address assignment.
When the event occurs, the system performs the following tasks:
•
Creates the Loopback 0 interface.
•
Assigns 1.1.1.1/24 to the interface.
•
Sends the matching command line to the information center.
Configuration procedure
# Configure an EAA environment variable for IP address assignment. The variable name is
loopback0IP
,
and the variable value is
1.1.1.1
.
<Sysname> system-view
[Sysname] rtm environment loopback0IP 1.1.1.1
# Create the CLI-defined policy
test
and enter its view.
<Sysname> system-view
[Sysname] rtm cli-policy test
# Add a CLI event that occurs when a command line that contains
loopback0
is executed.
[Sysname-rtm-test] event cli async mode execute pattern loopback0