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. instance discovery -> script

instance discovery -> script

Scheduled Pinned Locked Moved Support (Russian)
5 Posts 2 Posters 37.5k 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.
  • W
    W
    wonderboy
    wrote on last edited by
    #1

    Можно ли сразу из скрипта (который используется в instance discovery) возвращать массив instance'ов вместе с именами, по аналогии как в instance discovery filter строка: return %(true, $1, i->name); ? Есть желание все сделать в основном скрипте, а фильтр не использовать, так как получается дублирование кода.

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

      Можно как метод instance discovery выбрать скрипт, а он уже вернет массив instance'ов.

      1 Reply Last reply
      0
      • W
        W
        wonderboy
        wrote on last edited by
        #3

        Видимо криво объяснил. У меня итак сейчас в instance discovery стоит script, который возвращает массив ifIndex'ов, а дальше приходится использовать instance discovery filter чисто для того, чтобы достать еще и список наименований для этих индексов, чтобы dci красиво проименовать используя instance-name. Я подумал, а почему бы в основном скрипте сразу с массивом ifIndex'ов не возвращать и наименования, чтобы не делать двойную работу. Но как из основного скрипта вернуть массив индексов и массив имен я так и не нашел. return %(ifIndexes, ifNames) не работает 🙂

        ps Благодарю за все ответы 🙂

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

          Сейчас так сделать нельзя, но идея хорошая, поэтому добавил 🙂 В аттаче патч на 2.0.6 - если собираете из исходников, то можно пересобрать. Ну и изменение войдет в 2.1-М1 и 2.0.7 (если будем делать 2.0.7).
          После этого изменения instance discovery script может вернуть hash map вместо массива - в таком случае ключи будут instance, а значения - instance name. Например:

          instances = %{};  // создаем пустой hash map
          instances[1] = "eth1";
          instances[2] = "eth2";
          instances[3] = "eth3";
          return instances;
          

          Если все ключи известны заранее, то можно даже так:

          return %{ 1:"eth1", 2:"eth2", 3:"eth3" };
          

          Ключ - это строка, не обязательно число. Так тоже правильно:

          instances = %{};  // создаем пустой hash map
          instances["eth1"] = "Ethernet 1";
          instances["eth2"] = "Ethernet 2";
          instances["eth3"] = "Ethernet 3";
          return instances;
          

          instance_map.patch

          1 Reply Last reply
          0
          • W
            W
            wonderboy
            wrote on last edited by
            #5

            Виктор, прекрасно! 🙂

            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