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
  3. Auto-bind script for new node

Auto-bind script for new node

Scheduled Pinned Locked Moved Support
3 Posts 2 Posters 13.9k 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
    sNsReal
    wrote on last edited by
    #1

    Hi again and sory for my following question, im new to NetXMS and i am having some headaches trying to do simple tasks.
    Here it goes

    I need to make an auto-bind script template to bind new nodes to a specific container

    Something like this:

    return $node->isNew bind to container "container";

    How can i achieve this simple script? i cant find the correct syntax to make it work

    Thanks!

    1 Reply Last reply
    0
    • J
      J
      johnnyva
      wrote on last edited by
      #2

      Hey sNsReal,

      You could probably use the newly available creationTime attribute on the NetObj class (added sometime in v3) which is epoch of when the object was created.

      So on the container that you want nodes to autobind to, you could enable "Automatically bind nodes selected by filter to this container", and disable the unbind option.
      And your filtering script would be something like this:

      HOURS_IN_SECONDS = 3600;
      if($node->creationTime != 0 && (time() - $node->creationTime) < HOURS_IN_SECONDS) return true;
      

      This will bind nodes that have been created within the last hour.  So long as the node performs a config poll within that time, then it should bind.
      If it does not return true, then it will implicitly return null, and null means that it won't bind or unbind the node being processed.
      If the object was created prior to the CreationTime being added to NetXMS, then CreationTime will be 0.

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

        Thanks!!!!

        It works very well!

        But the problem that i need to solve is that i need to bind the nodes matched by the template to "infrastructure Services\new nodes" container so i can then organize them in infrastructure.

        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