[nxsnmpset]: Hex-String
-
Здравствуйте, подскажите как с помощью 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 -
Сейчас nxsnmpset не поддерживает задание OCTET STRING в шестнадцатеричном виде. Я добавил feature request: https://track.radensolutions.com/issue/NX-2278.
В текущей версии это можно делать из NXSL скрипта - при помощи ByteStream собрать нужную последовательность байтов и передать в SNMP SET.
-
-
Например так:
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); -
Спасибо огромное за помощь, все получилось!
Вот скрипт / функция 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; -
Thank you for your example
Script / function to backup configs via tftp for Dlink Industrial (cisco-like) Switches 1510 SeriesGotta Love Google Translate
-
Обновил nxsnmpset, теперь у него появился ключ -H для указания hex строки. Будет в следующем патч релизе 4.2.
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