HowTo Use SNMP SET on Mellanox Switches

Version 19

    This post shows how to use SNNP SET command on Mellanox switches (MLNX-OS) via Linux SNMP based tools.

     

    References

    • MLNX-OS User Manual
    • MLNX-OS MIBs (located on the Mellanox support site)

     

    Setup

     

    A Mellanox SwitchX based system connected to an SNMP client via the mgmt network.

     

    Configuration

    1. set an read-write community string on the switch in order to be able to use SNMP set command

    switch  (config) # snmp-server community private_community rw

     

    2. use the "show snmp" command to verify the configuration

    switch (config) # show snmp

    SNMP enabled:         yes

    SNMP port:            161

    System contact:

    System location:

    Read-only communities:

       public

    Read-write communities:

      private_community

     

    Interface listen enabled: yes

    No Listen Interfaces.

               

     

     

    Supported Set Commands

     

    1. Hostname change (via Linux environment):

    # snmpset -v 2c -c private 10.7.54.243 SNMPv2-MIB::sysName.0  SX1036 SNMPv2-MIB::sysName.0 = STRING: SX1036     

    2. Verify the Host-name has been changed:

    # snmpget -v 2c -c private_community 10.7.54.243

    SNMPv2-MIB::sysName.0 SNMPv2-MIB::sysName.0 = STRING: SX1036

               

     

    3. Sending a test trap to a configured SNMP server

     

    #snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-EFM-MIB:sendTestTrapSet.0 u 0

    MELLANOX-EFM-MIB::sendTestTrapSet.0 = Gauge32: 0

             


    4. Power Cycle

     

         Available command options and their mappings:

     

      1 - mellanoxPowerCycleCmdExecuteReload

      2 - mellanoxPowerCycleCmdExecuteReloadDiscard

      3 - mellanoxPowerCycleCmdExecuteReloadForce

      4 - mellanoxPowerCycleCmdExecuteReloadSlave

     

    4.1 Reload - save any unsaved configuration and reloads the switch

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-POWER-CYCLE-MIB:mellanoxPowerCycleCmdExecute.0 i 1

    MELLANOX-POWER-CYCLE-MIB::mellanoxPowerCycleCmdExecute.0 = INTEGER: mellanoxPowerCycleCmdExecuteReload(1)

             

     

    4.2 Reload discard - reboots the system and discards any unsaved configuration

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-POWER-CYCLE-MIB:mellanoxPowerCycleCmdExecute.0 i 2

    MELLANOX-POWER-CYCLE-MIB::mellanoxPowerCycleCmdExecute.0 = INTEGER: mellanoxPowerCycleCmdExecuteReloadDiscard(2)

             


    4.3 Reload force - forces an expedited reload on the system even if it's busy without saving unsaved configuration (like the CLI command "reload force")

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-POWER-CYCLE-MIB:mellanoxPowerCycleCmdExecute.0 i 3

    MELLANOX-POWER-CYCLE-MIB::mellanoxPowerCycleCmdExecute.0 = INTEGER: mellanoxPowerCycleCmdExecuteReloadForce(3)

             


    4.4 Reload slave - reloads the slave management module on dual management systems (Director switches), requires using the Master management IP address or BIP (BOX-IP)

    # snmpset -v 2c -c private_community 10.7.54.240 MELLANOX-POWER-CYCLE-MIB:mellanoxPowerCycleCmdExecute.0 i 4

    MELLANOX-POWER-CYCLE-MIB::mellanoxPowerCycleCmdExecute.0 = INTEGER: mellanoxPowerCycleCmdExecuteReloadSlave(4)

             

     

    5. Configuration file manipulation

     

    Available Commands:

    • BinarySwitchTo - replaces the configuration file with a new binary configuration file.
      This option fetches the configuration file from the URI provided in the mellanoxConfigDBCmdUri and switches to that configuration file. This command should be preceded by a reload command in order for the new configuration to apply
    • TextApply - fetches a configuration file in human-readable format and applies its configuration upon the current configuration. if a command fails, the rest of the commands are not applied
    • TextApplyFailContinue - fetches a configuration file in human-readable format and applies its configuration upon the current configuration. if a command failes, continue applying the rest of the commands
    • BinaryUpload - uploads a binary format configuration file of the current running configuration or an existing configuration file on the switch to the URI in the mellanoxConfigDBCmdUri command. The mellanoxConfigDBCmdFilename parameter indicates which configuration file on the switch to upload.
    • TextUpload - uploads a human-readable configuration file of the current running configuration or an existing configuration file on the switch to the URI in the mellanoxConfigDBCmdUri command. The filename parameter indicates what configuration file on the switch to upload.
    • BinaryDelete - deletes a binary format configuration file. The mellanoxConfigDBCmdFilename parameter indicates which Binary configuration file on the switch to delete.
    • TextDelete - deletes a binary format configuration file. The mellanoxConfigDBCmdFilename parameter indicates which textual configuration file on the switch to delete.
    • ConfigWrite -  saves active configuration to a filename on the switch as given in the filename parameter. In case filename is “active”, active configuration is saved to thecurrent saved configuration (same as the CLI command "configuration write" or "write memory")

     

    Binary Upload Example:

    ### set the file name to upload from the switch to the remote server

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdFilename.0 s "initial"

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdFilename.0 = STRING: "initial"

     

    ### set the URI - to where to upload the file

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdUri.0 s "scp://root:password@10.1.1.1:/tmp/SX1036_binary_conf"

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdUri.0 = STRING: "scp://root:password@10.1.1.1:/tmp/SX1036_binary_conf"

     

    ### execute the BinaryUpload Command

    # snmpset -t 10  -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdExecute.0 i mellanoxConfigDBCmdExecuteBinaryUpload

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdExecute.0 = INTEGER: mellanoxConfigDBCmdExecuteBinaryUpload(4)

          

     

     

    • TextUpload - uploads a human-readable configuration file of the current running configuration or an existing configuration file on the switch to the URI in the mellanoxConfigDBCmdUri parameter. The mellanoxConfigDBCmdFilename parameter indicates what configuration file on the switch to upload.

     

    ### set the file name to upload from the switch to the remote server

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdFilename.0 s "initial"

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdFilename.0 = STRING: "initial"

     

    ### set the URI - to where to upload the file

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdUri.0 s "scp://root:password@10.1.1.1:/tmp/SX1036_text_conf.txt"

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdUri.0 = STRING: "scp://root:password@10.1.1.1:/tmp/SX1036_text_conf.txt"

     

    ### execute the TextUpload command

    # snmpset -t 10  -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdExecute.0 i mellanoxConfigDBCmdExecuteTextUpload MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdExecute.0 = INTEGER: mellanoxConfigDBCmdExecuteTextUpload(5)

          

     

    • ConfigWrite - saves active configuration to a file name on the switch as given in the mellanoxConfigDBCmdFilename parameter. In case mellanoxConfigDBCmdFilename is “active”, active configuration is saved to the current saved configuration (same as the CLI command "configuration write").

     

    ### Set the file name to save to

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdFilename.0 s "active" MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdFilename.0 = STRING: "active"

     

    ### run the command ConfigWrite

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdExecute.0 i mellanoxConfigDBCmdExecuteConfigWrite MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdExecute.0 = INTEGER: mellanoxConfigDBCmdExecuteConfigWrite(6)

          
    • BinaryDelete - deletes a saved binary configuration file according to a given file name

    ### Set the binary file name to delete

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdFilename.0 s "eddie_test"

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdFilename.0 = STRING: "eddie_test"

     

    ### run the command BinaryDelete

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdExecute.0 i mellanoxConfigDBCmdExecuteBinaryDelete

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdExecute.0 = INTEGER: mellanoxConfigDBCmdExecuteBinaryDelete(7)

     

     

    • TextDelete - deletes a saved textual configuration file according to a given file name

    ### Set the text file name to delete

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdFilename.0 s "SX1036.txt"

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdFilename.0 = STRING: "SX1036.txt"

     

    ### run the command TextDelete

     

    # snmpset -v 2c -c private_community 10.7.54.243 MELLANOX-CONFIG-DB-MIB:mellanoxConfigDBCmdExecute.0 i mellanoxConfigDBCmdExecuteTextDelete

    MELLANOX-CONFIG-DB-MIB::mellanoxConfigDBCmdExecute.0 = INTEGER: mellanoxConfigDBCmdExecuteTextDelete(8)

     

     

    6. Software Update

     

        Available command options and their mappings:

     

     

    • Update - fetches the image from a specified URI (equivalent to the command “image
      fetch” followed by “image install”)

      This option fetches the configuration file from the URI provided in the mellanoxConfigDBCmdUri and switches to that configuration file. This command should be preceded by a reload command in order for the new configuration to apply
    • Set-Next changes the image for the next boot, equivalent to the CLI command “image
      boot”

     

    Software update via SNMP example:

    ### Set the image path to upgrade to

     

    # snmpset -c private_community -v 2c 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdUri.0 s 'scp://root:password@10.7.54.107/image-X86_64-3.4.1120.img'

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdUri.0 = STRING: "scp://root:password@10.7.54.107/image-X86_64-3.4.1120.img"

     

    ###  Start the fetch and install process

    # snmpset -c private_community -v 2c 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdExecute.0 i mellanoxSWUpdateCmdExecuteUpdate

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdExecute.0 = INTEGER: mellanoxSWUpdateCmdExecuteUpdate(1)

     

    ### View the status

     

    # snmpwalk -c private_community -v 2c 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdStatus

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdStatus.0 = INTEGER: 60

     

    #

    # 0 – no operation
    #  1-100 – progress%
    #  101 – success
    #  200 – failure

    #

     

    ### Automatically the next boot partition is changed to the partition on which the new image was installed on.

    ###  this can be checked with

     

    # snmptable -v 2c -c private_community 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWTable

    SNMP table: MELLANOX-SW-UPDATE-MIB::mellanoxSWTable

     

     

    mellanoxSWPartitionIndex                      mellanoxSWPartitionName mellanoxSWPartitionActive mellanoxSWPartitionBootNext

                            1 "X86_64 3.4.1100 2015-02-10 20:18:57 x86_64"                         1                           0

                            2 "X86_64 3.4.1120 2015-03-19 21:11:43 x86_64"                         0                           1

     

    ### And changed with

     

    ### partition no. 1

     

    # snmpset -v 2c -c private_community 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdSetNext.0 i 1

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdSetNext.0 = INTEGER: 1

    # snmpwalk -c private_community -v 2c 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdExecute.0 i mellanoxSWUpdateCmdExecuteSetNext

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdExecute.0 = INTEGER: mellanoxSWUpdateCmdExecuteSetNext(2)

     

    ### partition no. 2

    snmpset -v 2c -c private_community 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdSetNext.0 i 2

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdSetNext.0 = INTEGER: 2

    # snmpwalk -c private_community -v 2c 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdExecute.0 i mellanoxSWUpdateCmdExecuteSetNext

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdExecute.0 = INTEGER: mellanoxSWUpdateCmdExecuteSetNext(2)

     

    ### Next partition

    snmpset -v 2c -c private_community 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdSetNext.0 i 3

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdSetNext.0 = INTEGER: 3

    # snmpwalk -c private_community -v 2c 10.7.54.38 MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdExecute.0 i mellanoxSWUpdateCmdExecuteSetNext

    MELLANOX-SW-UPDATE-MIB::mellanoxSWUpdateCmdExecute.0 = INTEGER: mellanoxSWUpdateCmdExecuteSetNext(2)

     

     

     

    And Finally we can of course reload the switch to  load the new image with the below snmp set:

     

    # snmpset -v 2c -c private_community 10.7.54.38 MELLANOX-POWER-CYCLE-MIB:mellanoxPowerCycleCmdExecute.0 i mellanoxPowerCycleCmdExecuteReload