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

Reminder

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

upgrade

Configuration Guide - Device Management

S7700 and S9700 V200R013C00

This document describes the configurations of Device Management, including device status query, hardware management, CSS, SVF, PoE, OPS, OIDS, energy-saving management, information center, fault management, NTP, synchronous ethernet, PTP.
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 Detecting Link Protocol Status Changes Through Association Between OIDS and OPS

Example for Detecting Link Protocol Status Changes Through Association Between OIDS and OPS

Networking Requirements

In Figure 7-4, the user remotely manages a switch through a network and wants to detect link protocol status changes through association between OIDS and OPS. When an OIDS filter detects a log indicating link protocol status changes, the switch displays complete log information, indicating that the link protocol status of a certain port changes.

Figure 7-4  Detecting link protocol status changes through association between OIDS and OPS

Configuration Roadmap

  1. Configure an OIDS filter.

  2. Make the Python script log.py to detect link protocol status changes through association between OIDS and OPS.

  3. Log in to the switch remotely, upload the Python script to the switch, and install the script.

  4. Configure a Python script assistant.

Procedure

  1. Configure an OIDS filter.

    # Configure the Log1 Occured event to be triggered based on the log with the module name ifnet and alias name link_state.

    <Switch> system-view
    [Switch] oids filter log 1 module ifnet alias link_state
    [Switch] quit

  2. Make a Python script.

    # Make the Python script log.py and register the Log1 Occured event. When this log is displayed, complete log information is recorded.

    NOTE:

    If you want to view the information displayed by the print statement in an OPS script, log in to the switch through the console port.

  3. Upload and install the Python script.

    # Log in to the switch remotely and upload the Python script to the switch. For details about how to upload the script, see File Management in S7700 and S9700 V200R013C00 Configuration Guide - Basic Configuration.

    # Install the Python script on the switch.

    <Switch> ops install file log.py

  4. Configure a Python script assistant.

    # Configure a Python script assistant and register the CLI event in the script log.py. Wait for the event to be triggered.

    <Switch> system-view
    [Switch] ops
    [Switch-ops] script-assistant python log.py
    [Switch-ops] quit

  5. Verify the configuration.

    # After the preceding configurations are complete, assume that GigabitEthernet 1/0/1 is Up and can be shut down, and check whether complete log information is recorded on the switch.

    [Switch] interface GigabitEthernet 1/0/1
    [Switch-GigabitEthernet1/0/1] shutdown
    [Switch-GigabitEthernet1/0/1] quit
    
    # Run the display oids history-event command in any view to view information about the OIDS events generated within the last 1 hour.
    [Switch] display oids history-event
    ----------------------------------------------------------------------          
    Slot       : 1                                                                  
    ObjectName : LOG_FILTER                                                         
    AttrName   : FILTERED_LOG_INFO                                                  
    Event      : Log1 Occured                                                       
    Time       : 2019-03-02 20:45:45                                                
    State value: 2                                                                  
    ----------------------------------------------------------------------     
    # Run the display oids filter command in any view to check log filter information.
    [Switch] display oids filter
    Type  Module/Alias                                              TriggerTimes    
    --------------------------------------------------------------------------------
    LOG   ifnet/link_state                                             1            
    

Configuration Files and Scripts

  • Configuration file of the switch

    #
    ops
     script-assistant python log.py
    #
    return
  • Example of the script log.py

    # -*- coding: utf-8 -*-
    import ops         # Import the OPS module.
    import sys         # Import the sys module.
    import os          # Import the OS module.
    # Subscription processing function
    def ops_condition (_ops):
    	# Log1 Occured event
    	ret, desp = _ops.oids.subscribe("logFilter", 'LOG', 'Log1 Occured')
    	if ret != 0:
    	    print("\r\nError: subscribe failed(ret={0}, desp={1}".format(ret, desp))
    	return 0
    	# Work processing function
    def ops_execute (_ops):
    	# Display complete log information.
    	logContent, errStr = _ops.environment.get('_oids_log')
    	print("\rlog content({0} bytes): {1}\r".format(len(logContent), logContent))
    	return 0
Translation
Download
Updated: 2019-04-20

Document ID: EDOC1100065738

Views: 45500

Downloads: 39

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