Configuring a Command Assistant Based on Batch Files

Context

If you want a device to automatically run a few commands in a specific condition to implement a function, write the commands one by one to a batch file with the file name extension *.bat. Then, load the batch file and bind it to a command assistant. When the device runs the command assistant, it executes the commands in the batch file in sequence.

  • A command assistant can be configured with only one batch file.

  • Ensure that the specified batch file is correct and complete. The system does not check the correctness of content in the batch file.

  • Assistants are executed on the background. Therefore, it is not recommended to bind interactive commands or jump commands, such as telnet and stelnet, to an assistant.

  • The system switches to the user view by default to run commands in the batch file. If a command needs to be executed in the system view, run the system-view command to enter the system view. Otherwise, the command will be executed in the user view, and the command configuration does not take effect.

  • If a command needs to be committed and the two-phase validation mode is used in the system, run the commit command after specifying this command. Otherwise, the configuration does not take effect.

Procedure

  1. Upload a batch file to the device. For details on how to upload a file to the device, see File System Configuration in NetEngine 8000 F Configuration Guide - Basic Configuration.
  2. In the user view, run ops install file file [ destination directory ]

    The batch file is installed.

    If you do not specify destination directory in the command, the batch file is loaded to the default path cfcard:/$_user/. If this parameter is specified, the batch file is loaded to the path cfcard:/$_user/directory/.

    If the specified directory does not exist, the system automatically creates the directory. A maximum of seven levels of subdirectories can be created under cfcard:/$_user/.

  3. Run system-view

    The system view is displayed.

  4. Run ops

    The OPS view is displayed.

  5. Run enable

    OPS is enabled.

  6. Run assistant assistant-name

    An assistant is created.

  7. Configure a trigger condition for the assistant.

    • To set the severity of an alarm that triggers the assistant execution, run the condition alarm level { eq | ge | gt | le | lt | ne } { critical | major | minor | warning } command.

    • To set the name of an alarm or event that triggers the assistant execution, run the condition { alarm alarm-type | event } feature feature-name name event-name [ para-name para-optype para-value ] & <1-4> [ occurs occur-number [ period period-value ] ] command.

    • To set the OID of an SNMP trap that triggers the assistant execution, run the condition snmp-notification oid oid-string [ optype oid-value ] command.
    • To set a log that triggers the assistant execution, run the condition syslog pattern reg-express [ occurs occur-number [ period period-value ] ] command.
    • To set the time when an assistant is executed, run the condition timer cron minutes hours daysOfMonth months daysOfWeek [ years ] command.

    Each assistant can have only one trigger condition.

  8. Run the execute priority batch-file file-name command to configure a batch file to be executed by the assistant.

    Only one batch file can be configured for a command assistant. The batch file is a .bat file that contains commands to be processed in batches. The following is an example:

    system-view
    arp static 1.1.1.1 1-1-1
    commit
    
    snmp-agent
    snmp-agent sys-info version all
    commit

  9. Run commit

    The configuration is committed.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >