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. Unknown Object Attribute and Method

Unknown Object Attribute and Method

Scheduled Pinned Locked Moved Support
4 Posts 3 Posters 27.6k 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.
  • J
    J
    jpaquin1106
    wrote on last edited by
    #1

    I'm currently learning NXSL to write scripts for executing ssh commands to nodes but have immediatelly run into issues that i'm unable to pinpoint the issue based on their documentation here:https://www.netxms.org/documentation/nxsl-latest/#_introduction

    1 sub main() {
    2 	node = Objects.FindNodeByIPAddress($1, null);
    3
    4	if (node == NULL) {
    5		println("Error: node not found.");
    6    }
    7
    8	//println(node->name);
    9   println(node->executeSSHCommand("ip address print"));
    10}
    

    When I try to execute the code above, it says "Error 30 in line 9: Unknown object's method" claiming the executeSSHCommand method doesn't exist, yet based on Node documentation is does. 

    When commenting that line out and uncommenting line 8, it says the attribute doesn't exist. 
    However, in documentation, it does. 

    I'm unsure at this point if I'm missing something obvious syntactically or what.

    Any help would be appreciated.

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

      Hey jp,

      I was thinking that maybe node was null, but then I think that would give a different error.

      What comes back if you print classof(node)?  I'm expecting it to be Node, but maybe its actually coming back as something else and not returning a node like the docs say.

      What server version are you running?

      1 Reply Last reply
      0
      • J
        J
        jpaquin1106
        wrote on last edited by
        #3

        @johnnyva said in Unknown Object Attribute and Method:

        Hey jp,

        I was thinking that maybe node was null, but then I think that would give a different error.

        What comes back if you print classof(node)?  I'm expecting it to be Node, but maybe its actually coming back as something else and not returning a node like the docs say.

        What server version are you running?

        Okay so after doing a classof(node) call its coming back with "Error 14 in line 8: Function or operation argument is not an object".
        With this now known, I've run typeof(node) and its saying its a String.
        Printing this string actually prints "Node@0x7f92ac7b6170".

        Based on the documentation here: https://www.netxms.org/documentation/nxsl-latest/#_objects it states

        FindNodeByIPAddress(ipaddress, currentNode) => Node
        
        Return
        Instance of Node object or null if not found or not accessible
        

        So it seems its trying to return a node object but is instead doing an internal call to a toString() method before returning it.
        I'm just going based on my knowledge of Java since that "Node@0x7f92ac7b6170" matches what I'm assuming exactly.

        Edit:

        I'm running the follow:

        Server version: 4.3.2 (build 4.3-374-g4f45f9ba5c)
        Java version: 11.0.10
        JVM: OpenJDK 64-Bit Server VM 11.0.10+9

        I've seen rare issues occur when running later versions of OpenJDK but documentation says the latest minimal version is 11 so I should be alright.

        edit 2:

        I've tested each of the find functions and they are all returning the same string representation.
        To clarify, trusted node checks are disabled (by default) so the 2nd parameter is optional based on documentation.

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

          FindNodeByIPAddress is a function, so you should not add "Objects." in front of it. Dot is string concatenation operation in NXSL (we plan to change that in 5.0, but that's another story) - so Objects . FindNodeByIPAddress concatenates null value converted to empty string from non-existent variable "Objects" with object returned by FindNodeByIPAddress converted to string - so result is a string.
          Correct script will be something like this:

          node = FindNodeByIPAddress($1, null);
          if (node == NULL) {
             println("Error: node not found.");
             return;
          }
          
          println(node->name);
          println(node->executeSSHCommand("ip address print"));
          

          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