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. Understanding the AgentReadList vs readAgentList

Understanding the AgentReadList vs readAgentList

Scheduled Pinned Locked Moved Support
3 Posts 2 Posters 41.7k 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.
  • B
    B
    Borgso
    wrote on last edited by
    #1

    Have been using AgentReadList in different scenarios to dynamic apply template and dci instances
    Could need some help to get it rewritten for NXLSv3

    What worked in 2.2.x

    Scenario 1:

    DCI on agentless node, using a "source node" and "Instance discovery method: Script", called with

    DW::DiscoverActiveMQ("DLQDetailsQueue")

    DW::DiscoverActiveMQ script is:

    if ($1 == "ActiveMQ") {
      //return AgentReadList($node, "DiscoverActiveMQ(" . $targetObject->ipAddr . ")");
      return $targetObject->readAgentList("DiscoverActiveMQ(" . $targetObject->ipAddr . ")");
    }
    

    ExternalList DiscoverActiveMQ do a do a call from source node to node and get a instance list to create DCI to poll info using a ExternalParameter (script on source node -> node) on each instance.

    Scenario 2:
    AutoApply template if user X is within /etc/passwd.

    Using a script library with following code and "ExternalList = UserList:cut -d: -f1 /etc/passwd"

    sub ServiceCheck(ServiceName) {
      if ($node->isAgent && $node->platformName like "Linux-*") {
        users = AgentReadList($node,"UserList");
        if ( users == null ) return null;
        foreach ( user : users ) {
          if ( user == ServiceName ) return true;
        }
      }
      return false;
    }
    
    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Hi,

      readAgentList is a node object method, so if you were calling

      AgentReadList($node, ...

      (read agent parameter from node pointed by $node variable) you now should use

      $node->readAgentList(...

      to read list from agent on same node.

      Best regards,
      Victor

      1 Reply Last reply
      0
      • B
        B
        Borgso
        wrote on last edited by
        #3

        Hi and thank for reply.

        I tried what you suggest, but it doesnt work as before:

        ServiceName is username within /etc/passwd catched using ExternalList on the node.

        Does not work:

        if ($node->isAgent && $node->platformName like "Linux-*") {
            users = $node->readAgentList("UserList");
            if ( users == null ) return null;
            foreach ( user : users ) {
              if ( user == ServiceName ) return true;
            }
          }
          return false;
        

        Does work, but is not the correct way..

        if ($node->isAgent && $node->platformName like "Linux-*") {
            users = AgentReadList($node,"UserList");
            if ( users == null ) return null;
            foreach ( user : users ) {
              if ( user == ServiceName ) return true;
            }
          }
          return false;
        

        However, if i add node to template first and then do "Configuration Poll" with $node->readAgentList version, it does not remove the node from template even if "Remove this template automatically when node no longer passes through filter"
        It does get removed/unbind if i only put "return false;" in the Automatic Apply Rules.

        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