9 Replies Latest reply on Oct 13, 2015 7:18 AM by orrence

    Can't get device details to be polled immediately after adding node

    orrence

      Hello there!

       

      This is my very first post in this community, so please be patient with me.

       

      We have the NPM up and running and try to add nodes using the SDK. With curl in a shell script adding the node and interfaces just works fine.

       

      What I can't get to work is the node details to be polled. I add the node with an empty caption and either it stays empty or sometimes the IP gets filled in as the displayed name.

       

      I add a couple of pollers (not quite sure which ones I need for Cisco routers, an 1812 for example) and send a PollNow to the newly created node using this code:

       

      #

      # Add Pollers for the newly added device.

      #

      CREATE_POLLER_URL="https://$ORION_SERVER:$PORT/SolarWinds/InformationService/v3/Json/Create/Orion.Pollers"

      for POLLER in "N.Uptime.SNMP.Generic" "N.Details.SNMP.Generic" "N.Topology.Snmp.Layer3" "N.Status.ICMP.Native" "N.ResponseTime.ICMP.Native"

      do

       

              JSON_STRING="{\"NetObject\":\"N:$NODE_ID\", \"NetObjectType\":\"N\", \"NetObjectID\":\"$NODE_ID\", \"PollerType\":\"$POLLER\"}"

              CMD="curl -s -S -k -X POST -H 'Content-Type: application/json' $CREDENTIALS -d '$JSON_STRING' $CREATE_POLLER_URL"

              POLLER_RESULT=`eval $CMD`

              echo "Registered Poller $POLLER (Result: $POLLER_RESULT) for Node \"$NODE_ID\""

      done

       

      # Send PollNow to newly created node.

      POLLNOW_URL="https://$ORION_SERVER:$PORT/SolarWinds/InformationService/v3/Json/Invoke/Orion.Nodes/PollNow"

      CMD="curl -s -S -k -X POST -H 'Content-Type: application/json' -d '[\"N:$NODE_ID\"]' $CREDENTIALS $POLLNOW_URL"

      OUTPUT=`eval $CMD`

       

      The response I get from the PollNow invoke above is "null". Am I doing it wrong somehow? Can somebody give any hints why the PollNow does not work?

       

      Thanks for any help!

      Daniel.

        • Re: Can't get device details to be polled immediately after adding node
          tdanner

          Your code for adding pollers looks ok. Can you post your code for adding the node?

           

          "null" is the expected response from PollNow. It returns immediately - it doesn't wait for the polling to complete.

            • Re: Can't get device details to be polled immediately after adding node
              orrence

              Thanks for your fast reply, @tdanner!

               

              Here is the code I use to add the node and interfaces that is immediately followed by the PollNow code posted above ($JQ is the path to the JSON-parsing-tool "jq", see jq):

               

              #

              # Add device

              #

              JSON_STRING="{

              \"EntityType\" :\"Orion.Nodes\", \

              \"IPAddress\" :\"$DEVICE_IP\", \

              \"IPAddressGUID\" :\"\", \

              \"DynamicIP\" :\"false\", \

              \"Caption\" :\"\", \

              \"EngineID\" :\"1\", \

              \"Status\" :\"1\", \

              \"UnManaged\" :\"false\", \

              \"Allow64BitCounters\" :\"true\", \

              \"SysObjectID\" :\"\", \

              \"MachineType\" :\"Unknown\", \

              \"External\" :\"false\", \

              \"SysName\" :\"\", \

              \"NodeDescription\" :\"\", \

              \"Location\" :\"\", \

              \"Contact\" :\"\", \

              \"IOSImage\" :\"\", \

              \"IOSVersion\" :\"\", \

              \"Vendor\" :\"Unknown\", \

              \"VendorIcon\" :\"Unknown.gif\", \

              \"PercentMemoryUsed\"   :\"-2\", \

              \"ObjectSubType\" :\"SNMP\", \

              \"Community\" :\"\", \

              \"SNMPVersion\" :\"$SNMPVERSION\", \

              \"SNMPV3Username\" :\"$SNMPV3USER\", \

              \"SNMPV3PrivMethod\" :\"$SNMPV3PRIVMETHOD\", \

              \"SNMPV3PrivKey\" :\"$SNMPV3PRIVPASS\",   \

              \"SNMPV3AuthMethod\"    :\"$SNMPV3AUTHMETHOD\", \

              \"SNMPV3AuthKey\" :\"$SNMPV3AUTHPASS\",   \

              \"BufferNoMemThisHour\" :\"-2\", \

              \"BufferNoMemToday\" :\"-2\", \

              \"BufferSmMissThisHour\":\"-2\", \

              \"BufferSmMissToday\" :\"-2\", \

              \"BufferMdMissThisHour\":\"-2\", \

              \"BufferMdMissToday\" :\"-2\", \

              \"BufferBgMissThisHour\":\"-2\", \

              \"BufferBgMissToday\" :\"-2\", \

              \"BufferLgMissThisHour\":\"-2\", \

              \"BufferLgMissToday\" :\"-2\", \

              \"BufferHgMissThisHour\":\"-2\", \

              \"BufferHgMissToday\" :\"-2\", \

              \"RediscoveryInterval\" :\"30\", \

              \"PollInterval\" :\"120\", \

              \"StatCollection\" :\"10\" \

              }"

              CREATE_NODE_URL="https://$ORION_SERVER:$PORT/SolarWinds/InformationService/v3/Json/Create/Orion.Nodes"

              CMD="curl -s -S -k -X POST -H 'Content-Type: application/json' $CREDENTIALS -d '$JSON_STRING' $CREATE_NODE_URL"

               

              RESULT=`eval $CMD`

              NODE_ID=`echo $RESULT | sed -e 's/.*=\([0-9]\+\)"/\1/'`

              echo "Added device \"$DEVICE\" as Node \"$NODE_ID\" to Orion:"

              echo $RESULT

               

               

              #

              # Add Interfaces for the newly added device.

              #

              #

               

              # Disvover Interfaces

              CMD="curl -s -S -k -X POST -H 'Content-Type: application/json' -d '[\"$NODE_ID\"]' $CREDENTIALS https://$ORION_SERVER:$PORT/SolarWinds/InformationService/v3/Json/Invoke/Orion.NPM.Interfaces/DiscoverInterfacesOnNode"

              OUTPUT=`eval $CMD`

              INTERFACES=`echo $OUTPUT | $JQ .DiscoveredInterfaces`

              RESULT=`echo $OUTPUT | $JQ .Result`

              if [ "$RESULT" -gt 0 ]

              then

              echo "Unable to discover Interfaces for $DEVICE:"

              echo $OUTPUT

              else

              #echo "Discovered Interfaces for $DEVICE:"

              #echo $INTERFACES | $JQ '.[]'

              #echo

              echo "Adding these Interfaces:"

              echo "------------------------"

              echo $INTERFACES | $JQ '.[] | select(.ifType==6)'  | grep Caption | sed -e 's/^.*"Caption": "\(.*\)"/\1/'

              IFS2ADD=`echo $INTERFACES | $JQ '[ .[] | select(.ifType==6) ]'`

              echo

               

              # Add found interfaces

              CMD="curl -s -S -k -X POST -H 'Content-Type: application/json' -d '[$NODE_ID, $IFS2ADD, \"AddDefaultPollers\" ]' $CREDENTIALS https://$ORION_SERVER:$PORT/SolarWinds/InformationService/v3/Json/Invoke/Orion.NPM.Interfaces/AddInterfacesOnNode"

              OUTPUT=`eval $CMD`

              fi

               

               

              Thanks,

              Daniel.

                • Re: Can't get device details to be polled immediately after adding node
                  tdanner

                  What version of NPM are you using?

                   

                  And are all your devices using SNMPv3?

                    • Re: Can't get device details to be polled immediately after adding node
                      orrence

                      We are using NPM 11.5.2. No Service Pack.

                       

                      Almost all our devices use SNMPv3, I would say about 99%. Those I tried to add with my script are definitely v3. And the node and interfaces get added just fine, as I already said. If I leave the device in for a while, when the next scheduled polling occurs, the device details are filled with sensible data. So, in principle, polling works even for the nodes added by script. I just can't get immediate polling to work, which is what we want and need.

                       

                      Does that help find a clue as to why the immediate polling does not work (yet)?

                       

                      Thanks,

                      Daniel.

                        • Re: Can't get device details to be polled immediately after adding node
                          tdanner

                          For 11.5 and later, you can omit most of the properties when you create the node. All you really need are:

                           

                          • IPAddress
                          • EngineID
                          • ObjectSubType ("SNMP")
                          • SNMPVersion
                          • and either:
                            • Community or
                            • the SNMPV3* credential properties

                           

                          The system will fill in your configured default values for all of the others.

                           

                          But that doesn't explain why it is not polling immediately. I'll see what I can find out.

                            • Re: Can't get device details to be polled immediately after adding node
                              tdanner

                              I got an explanation for why PollNow seems to have no effect immediately after adding a new node. Basically, the component that handles the PollNow keeps a cache of data about the monitored nodes. If it gets a PollNow call for a node it doesn't know about, it ignores it. The cache is not updated immediately after a new node is added through the API - there may be a 30 second delay here.

                                • Re: Can't get device details to be polled immediately after adding node
                                  orrence

                                  Thanks for getting back to me again on this one, @tdanner.

                                   

                                  I am not quite sure I understand what this means, exactly, though.

                                  1.) Do I send the PollNow event and then have to wait for 30s for the polling to occur?

                                  2.) Or do I have to wait for 30s after adding the node and then send the PollNow, so that the node is known by "the cache"? Does the polling then occur immediately if I send a "PollNow", like the name of the event suggests?

                                   

                                  I tried 1.) above, but unfortunately that does not work. Even after waiting at least three minutes and then looking at the node again gave an empty caption and no node details.

                                   

                                  Is 2.) the way to go? That would be quite annoying, because then the script for adding nodes would take a very long time to finish. But at least I would have something to rely on.

                                   

                                  While you (hopefully) give this some more thought, I will try option nr. 2.) and get back to you with the results ...

                                   

                                  Thanks,

                                  Daniel.

                                    • Re: Can't get device details to be polled immediately after adding node
                                      tdanner

                                      I'm afraid it is #2. If you send the PollNow immediately after adding the node, it will just be lost and ignored. If you wait the 30 seconds and then send the PollNow, it should poll the node relatively promptly, but the PollNow call will still return right away - it doesn't block until the poll completes.

                                       

                                      If you have a bunch of nodes to add, you could add them all, then wait 30 seconds, then PollNow them all. This might make your script more complex, but it will finish faster than if you wait 30 seconds between each node.

                                        • Re: Can't get device details to be polled immediately after adding node
                                          orrence

                                          I am sorry that I have to say this, but unfortunately I cannot confirm that #2 works, at least not for me. I don't know if I am doing it wrong somehow, but waiting for 40s (10 extra seconds to be sure) and then doing the PollNow on the new Node doesn't change a thing here. It is as if I haven't sent a PollNow at all. Looking at the Node after several minutes did not show any details. I tried it several times already, unfortunately to no avail.

                                           

                                          I am out of ideas here and would be more than happy if you have something else for me to try ..... otherwise we just have to wait until regular scheduled poll events occur and the node details get filled with data. Would be unhappy about that but what else can I do?

                                           

                                          Thanks for your support so far!

                                           

                                          Any ideas left?

                                           

                                          Daniel.