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. scripting management functions [SOLVED]

scripting management functions [SOLVED]

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

    Hello,

      I have been creating filtering and even some scripts that imitate snmpwalk or trying to polish tool to mass-create DCI (based on my snmpwalk) but some problems with management functions arised.
    (I am looking into python for nxshell functionality now, but I believe commands from Function Reference should be working without nxshell.)

    Some functions work, but some do not and I don't know why..

    For example - GetNodeParents, GetNodeInterfaces, GetObjectParents, GetObjectChildren

    The first line where I use these functions makes the script broken, even test scripts like this are not working...

    interfaces = GetNodeInterfaces($1);
    foreach(i : interfaces)
    {
        println "Interface: name='" . i->name . "' id=" . i->id;
    }
    

    All I get is: ERROR: Script finished with error: Error 14 in line 1: Function or operation argument is not an object

    Can someone enlighten me what I do wrong please?

    With regards

    Milan Sperl

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

      Hi!

      You pass $1 to GetNodeInterfaces. It's a first argument of the script. It depends on context, but it's unlikely that it will be node object. If you want to work with "current" node (i.e. owner node of DCI in transformation script), you can use built-in variable $node. In other cases, you can use FindNodeObject function to obtain reference to node object you are interested in.

      Best regards,
      Victor

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

        Sorry for not explaining - I am using $1 because I am running the script from Server Console and provide node name as first parameter of course. That is why I am "printing" the results.
        I even tried to set node name (or ID) instead of $1 to remove the possibility this parameter is at fault.
        If I set node name (e.g. Core1-SW) the error changes to:
        _Error 5: Invalid operation with NULL value_

        Thanks for the reply

        Milan Sperl

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

          Node name is a string, not an object reference. If you want to find node object by name, you could use FindObject or FindNodeObject function, like this:

          node = FindNodeObject(null, $1);
          println "Node ID: " node->id;
          

          Also check this script example: http://wiki.netxms.org/wiki/Script_Example:_Read_SNMP_Value_From_Node

          Best regards,
          Victor

          1 Reply Last reply
          0
          • S
            S
            sperlm
            wrote on last edited by
            #5

            Thanks for pointing the problem for me.
            I should have used the findObject function and I have to use ID of the tested node only. Cannot use Object Name, which is OK for testing purposes, in called scripts I can use $node again.
            The "null" parameter in findObjectNode was not clear to me (but it works with it too).

            Thanks once more.

            Milan Sperl

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

              @sperlm said in scripting management functions [SOLVED]:

              The "null" parameter in findObjectNode was not clear to me (but it works with it too).

              It's a reference to already known object. Here is the explanation: http://wiki.netxms.org/wiki/SG:Security_Issues.

              Best regards,
              Victor

              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