No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search


To have a better experience, please upgrade your IE browser.


NE20E-S2 V800R010C10SPC500 Configuration Guide - System Management 01

This is NE20E-S2 V800R010C10SPC500 Configuration Guide - System Management
Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Example for Configuring an Assistant for Automatic Health Check (Using a Python Script)

Example for Configuring an Assistant for Automatic Health Check (Using a Python Script)

This section provides an example for configuring an assistant for automatic health check using a Python script.

Networking Requirements

As shown in Figure 6-2, the remote server is a TFTP server. DeviceA and the TFTP server have reachable routes to each other. To reduce maintenance workload, configure DeviceA to automatically collect health information and send it to the TFTP server for analysis.

Figure 6-2 Automatic health check using a Python script

Configuration Roadmap

The configuration roadmap is as follows:
  1. Compile a Python script, upload, and install it on DeviceA.

  2. Create a script assistant.


  1. Compile a Python script.

    # Compile a Python script named

    In the Python script, set the trigger condition as the timer and the task as executing commands to collect device information, including hardware status, route status, and interface link status, and to send the information to the TFTP server. The Python script is as follows:
    # Define the function of the trigger condition.
    def ops_condition(_ops):
    	_ops.timer.cron("con1","0 1 * * * *")      # Set the timer event.
    # Define the functions of tasks.
    def ops_execute(_ops):
    	handle, err_desp  =      # Open the CLI channel.
    	_ops.cli.execute(handle,"display device > health.txt")      # Execute CLIs.
    	_ops.cli.execute(handle,"display health >> health.txt")
    	_ops.cli.execute(handle,"display ip routing-table >> health.txt")
    	_ops.cli.execute(handle,"display lldp neighbor brief >> health.txt")
    	_ops.cli.execute(handle,"tftp put health.txt")
    	ret = _ops.cli.close(handle)      # Close the CLI channel.
    	return 0

  2. Upload and install the Python script.

    # Configure DeviceA functioning as a TFTP client to download the Python script file from the TFTP server. The Python script is stored on the TFTP server.

    <HUAWEI> system-view
    [~HUAWEI] sysname DeviceA
    [*HUAWEI] commit
    [~DeviceA] quit
    <DeviceA> tftp get
    Info: Transfer file in binary mode.
    Please wait for a while...
    /    635 bytes transferred
    Info: Downloaded the file successfully.

    # Install the Python script on DeviceA.

    <DeviceA> ops install file

  3. Configure a script assistant.

    <DeviceA> system-view
    [~DeviceA] ops
    [~DeviceA-ops] script-assistant python
    [*DeviceA-ops] commit
    [~DeviceA-ops] return

  4. Verify the configuration.

    # Check the configuration of the assistant.

    <DeviceA> display ops assistant verbose name
    Assistant information
      Name                 :
      State                : ready
      Type                 : script
      Default assistant    : no
     Running statistics
      Running times        : 0
      Queue size/(free)    : 10/(10)
      Skip for queue full  : 0
      Skip for delay       : 0
      Skip for suppression : 0
      Skip for error       : 0
     Execute information
      Task abstract        : : ops_execute()
     Trigger control
      Occurs threshold     : 1
      Period (s)           : 0
      Delay (s)            : 0
      Suppress max         : 0
      Hits in period       : 0
     Condition information
      Correlate expression : con1
      Condition tag        : con1
        Condition type     : timer
        Subscribe result   : success
        Occurs threshold   : 0
        Period (s)         : 0
        Hits in period     : 0

Configuration Files

  • DeviceA configuration file

    sysname DeviceA
     script-assistant python
Updated: 2019-01-02

Document ID: EDOC1100055400

Views: 20414

Downloads: 30

Average rating:
This Document Applies to these Products
Related Documents
Related Version
Previous Next