Cli-defined policy configuration example, Network requirements, Configuration procedure – H3C Technologies H3C MSR 5600 User Manual
Page 239: Verifying the configuration
226
In response to this CLI event, EAA executes the policy. You can see the message "rtm_tcl_test is running"
and the policy successfully executed message on the terminal screen.
CLI-defined policy configuration example
Network requirements
Configure a policy from the CLI to monitor the event that occurs when a question mark (?) is entered at
the command line that contains letters and digits.
When the event occurs, the system executes the command and sends the log message "hello world" to
the information center.
Configuration procedure
# Enter system view.
# Create the CLI-defined policy test and enter its view.
[Sysname] rtm cli-policy test
# Add a CLI event that occurs when a question mark (?) is entered at any command line that contains
letters and digits.
[Sysname-rtm-test] event cli async mode help pattern [a-zA-Z0-9]
# Add an action that sends the message "hello world" with priority 4 from device local3 when the event
occurs.
[Sysname-rtm-test] action 0 syslog priority 4 facility local3 msg “hello world”
# Add an action that enters system view when the event occurs.
[Sysname-rtm-test] action 2 cli sy
# Add an action that creates VLAN 2 when the event occurs.
[Sysname-rtm-test] action 3 cli vlan 2
# Set the maximum runtime of the policy to 2000 seconds. The system stops executing the policy and
displays an execution failure message if it fails to complete policy execution within 2000 seconds.
[Sysname-rtm-test] running-time 2000
# Specify the network-admin user role for executing the policy.
[Sysname-rtm-test] user-role network-admin
# Enable the policy.
[Sysname-rtm-test] commit
Verifying the configuration
# Display information about the policy.
Total number: 1
PolicyName Type Event TimeRegistered User-role
test CLI CLI Apr 21 16:35:00 2012 network-admin
# Enter a question mark (?) at a command line that contains both letters and digits. You can see the
message "hello world" and a policy successfully executed message on the terminal screen. (Details not
shown.)