Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support (Russian)
  3. [nxsnmpset]: Hex-String

[nxsnmpset]: Hex-String

Scheduled Pinned Locked Moved Support (Russian)
7 Posts 3 Posters 13.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    S
    sa_drug
    wrote on last edited by
    #1

    Здравствуйте, подскажите как с помощью nxsnmpset установить значение с типом Hex-String, т.е.:

    snmpset -v3 -a SHA -A password -l authPriv -u writeuser -x DES -X password 10.34.222.74 .1.3.6.1.4.1.171.14.14.1.2.1.6.1 x c0a8055d
    iso.3.6.1.4.1.171.14.14.1.2.1.6.1 = Hex-STRING: C0 A8 05 5D
    

    А вот с помощью nxsnmpset (и соответственно в NXSL) сделать подобное не получается:

    nxsnmpset -v 3 -a SHA1 -A password -u writeuser-e DES -E password 10.34.222.74 .1.3.6.1.4.1.171.14.14.1.2.1.6.1 c0a8055d
    SET operation failed (Wrong value)
    
    nxsnmpset -v 3 -a SHA1 -A password -u writeuser -e DES -E password 10.34.222.74 .1.3.6.1.4.1.171.14.14.1.2.1.6.1@STRING c0a8055d
    SET operation failed (Wrong value)
    
    nxsnmpset -v 3 -a SHA1 -A password -u writeuser -e DES -E password 10.34.222.74 .1.3.6.1.4.1.171.14.14.1.2.1.6.1@IPADDR c0a8055d
    SET operation failed (Wrong type)
    
    nxsnmpset -v 3 -a SHA1 -A password -u writeuser -e DES -E password 10.34.222.74 .1.3.6.1.4.1.171.14.14.1.2.1.6.1@IPADDR 192.168.5.93
    SET operation failed (Wrong type)
    

    .1.3.6.1.4.1.171.14.14.1.2.1.6.1 - это OID коммутаторов Dlink определяющий IP адрес сервера, на который сливается конфиг.

    Используется:

    ii  netxms-agent:amd64                     4.1.377-1                                       amd64        NetXMS agent
    ii  netxms-base:amd64                      4.1.377-1                                       amd64        NetXMS core libraries
    ii  netxms-dbdrv-pgsql:amd64               4.1.377-1                                       amd64        PostgreSQL driver for netxms-server
    ii  netxms-dbdrv-sqlite3:amd64             4.1.377-1                                       amd64        SQLite3 driver for netxms-server
    ii  netxms-release                         1.10                                            all          Package to install apt source and gpg keyring
    ii  netxms-server:amd64                    4.1.377-1                                       amd64        meta package
    
    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Сейчас nxsnmpset не поддерживает задание OCTET STRING в шестнадцатеричном виде. Я добавил feature request: https://track.radensolutions.com/issue/NX-2278.

      В текущей версии это можно делать из NXSL скрипта - при помощи ByteStream собрать нужную последовательность байтов и передать в SNMP SET.

      1 Reply Last reply
      0
      • S
        S
        sa_drug
        wrote on last edited by
        #3

        А не могли бы привести пример, не нахожу в документации ничего про ByteStream.

        1 Reply Last reply
        0
        • V
          V
          Victor Kirhenshtein
          wrote on last edited by
          #4

          Например так:

          bs = new ByteStream();
          bs->writeByte(0xC0);
          bs->writeByte(0xA8);
          bs->writeByte(0x05);
          bs->writeByte(0x5D);
          
          snmp = $node->createSNMPTransport();
          snmp->set(".1.3.6.1.4.1.171.14.14.1.2.1.6.1", bs);
          
          1 Reply Last reply
          0
          • S
            S
            sa_drug
            wrote on last edited by
            #5

            Спасибо огромное за помощь, все получилось!

            Вот скрипт / функция backup-а конфигов по tftp для Dlink Industrial (cisco-like) Switches 1510 Series, но в целом, как шаблон, подойдет для других моделей, меняются только OID-ы.
             

            /* 1. Create snmp transport to current node */
            println ("[INFO]: Node name - " . $node->name);
            
            transport = $node->createSNMPTransport();
            if (transport == null)
            {
            	println ( "[ERROR]: Failed to create SNMP transport" );
            	return -1;
            }
            /* 2. Generate backup name */
            /* 2.1 Path prefix / Node name / Date and time manipulation */
            snmpName = transport->get(".1.3.6.1.2.1.1.5.0")->printableValue;
            pathPrefix = "ma-switches";
            backupName = ( pathPrefix . "/" . snmpName . "/" . "backup_" . strftime("%d-%m-%Y_%H-%M", time()) . ".cfg");
            println ( "[INFO]: " . backupName );
            /* 2.2 Backup */
            /*
            .dlinkIndustrialCommon.dlinkSwSystemFileMIB.dsfMIBObjects.dsfCopyTable.dsfCopyEntry
             - dsfCopyType :: 2 - Upload TFTP / 3 - Upload FTP / 5 - Download TFTP
            .1.3.6.1.4.1.171.14.14.1.2.1.2.1 = INTEGER: 2
             - dsfCopySrcUrl :: 'startup-config','running-config','system-log','attack-log'
            .1.3.6.1.4.1.171.14.14.1.2.1.3.1 = STRING: "running-config"
             - dsfCopyDstUrl :: backupName variable
            .1.3.6.1.4.1.171.14.14.1.2.1.4.1 = STRING: "backup_date_time.cfg"
             - dsfCopyRemoteAddrType :: 0 - unknown / 1 - ipv4 / 2 - ipv6 / 12 - dns
            .1.3.6.1.4.1.171.14.14.1.2.1.5.1 = INTEGER: 1
             - dsfCopyRemoteAddr :: 192.168.5.93
            .1.3.6.1.4.1.171.14.14.1.2.1.6.1 = Hex-STRING: C0 A8 05 5D
             - dsfCopyRowStatus
            .1.3.6.1.4.1.171.14.14.1.2.1.12.1 = INTEGER: 4
            */
            output = transport->set(".1.3.6.1.4.1.171.14.14.1.2.1.2.1", 2, "INTEGER");
            if (!output) { println ("[ERROR]: Can't set backup method TFTP (" . $node->name . ")"); return -2 ; };
            
            output = transport->set(".1.3.6.1.4.1.171.14.14.1.2.1.3.1", "running-config", "STRING");
            if (!output) { println ("[ERROR]: Can't set backup remote source (" . $node->name . ")"); return -3 ; };
            
            output = transport->set(".1.3.6.1.4.1.171.14.14.1.2.1.4.1", backupName, "STRING");
            if (!output) { println ("[ERROR]: Can't set backup local filename (" . $node->name . ")"); return -4 ; };
            
            output = transport->set(".1.3.6.1.4.1.171.14.14.1.2.1.5.1", 1, "INTEGER");
            if (!output) { println ("[ERROR]: Can't set dest address-type to IPv4 (" . $node->name . ")"); return -5 ; };
            
            /* https://www.netxms.org/forum/oe-oo/nxsnmpset-hex-string/ */
            bs = new ByteStream();
            bs->writeByte(0xC0);
            bs->writeByte(0xA8);
            bs->writeByte(0x05);
            bs->writeByte(0x5D);
            
            output = transport->set(".1.3.6.1.4.1.171.14.14.1.2.1.6.1", bs);
            if (!output) { println ("[ERROR]: Can't set destanation IP address (" . $node->name . ")"); return -6 ; };
            /* 3. Run backup */
            output = transport->set(".1.3.6.1.4.1.171.14.14.1.2.1.12.1", 4, "INTEGER");
            if (!output) { println ("[ERROR]: Runnig backup process failed (" . $node->name . ")"); return -12 ; };
            /* 4. End */
            return 0;
            
            1 Reply Last reply
            0
            • D
              D
              Dawid Kellerman
              wrote on last edited by
              #6

              Thank you for your example
              Script / function to backup configs via tftp for Dlink Industrial (cisco-like) Switches 1510 Series

              Gotta Love Google Translate

              1 Reply Last reply
              0
              • V
                V
                Victor Kirhenshtein
                wrote on last edited by
                #7

                Обновил nxsnmpset, теперь у него появился ключ -H для указания hex строки. Будет в следующем патч релизе 4.2.

                1 Reply Last reply
                0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                Powered by NodeBB Contributors
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups