9 Replies Latest reply on Feb 16, 2015 3:44 PM by tdanner

    Problems with creating nodes with interfaces when using SDK (Perl)

    bart_vh

      Hi, I'm having serious problems getting nodes added properly with selected interfaces monitored.

       

      When I add the node, it does not re-discover by itself, I need to edit the node in the GUI and just submit before it will be picked up for rediscovery.

      When adding interfaces, the status icon is blank, basically there are a number of NULL fields in the database.

       

      Trying to set a value to and empty string does not work with the Perl libraries, these values will end up NULL in the database, and that in turn will screw up the views.

       

      Trying to populate variables with international characters doesn't work either, the string ends up being scrambled. (I have doublechecked that the variables are proper UTF-8 with the flag set, so that's not the problem)

      ( e.g. Säffle, Göteborg, etc... )

       

      Anyone having any tips on how I can get all this to work?

       

      Many thanks,

      Bart

        • Re: Problems with creating nodes with interfaces when using SDK (Perl)
          juniordev

          Hi @bart_vh ,

          I am not sure but maybe it is related to pollers. When I will add a node via SDK, also I add "N.Details.SNMP.Generic", "N.Uptime.SNMP.Generic" pollers. Can you try add pollers after add node?

            • Re: Problems with creating nodes with interfaces when using SDK (Perl)
              bart_vh

              Hi Juniordev,

               

              I don't think it is, here's what I do for a node and its interfaces:

               

              node 'x.y.z' with IP 1.2.3.4 created: nodeID=9418
                      poller 'N.Details.SNMP.Generic' added (PollerID=97752)
                      poller 'N.Uptime.SNMP.Generic' added (PollerID=97753)
                      poller 'N.Cpu.SNMP.CiscoGen3' added (PollerID=97754)
                      poller 'N.Memory.SNMP.CiscoGen3' added (PollerID=97755)

              Adding interface 'Gi1/0/3' ('GigabitEthernet1/0/3',10103) to node 9418
                      Interface 'Gi1/0/3' added with ID 22103
                      poller 'I.StatisticsTraffic.SNMP.Universal' added (PollerID=97756)
                      poller 'I.StatisticsErrors32.SNMP.IfTable' added (PollerID=97757)
                      poller 'I.Rediscovery.SNMP.IfTable' added (PollerID=97758)

               

              But there's something else wrong...

                • Re: Problems with creating nodes with interfaces when using SDK (Perl)
                  Jan Pelousek

                  Hello,

                   

                  it's hard to guess without the Code snippet, but I suspect you're just missing the polling settings in the property bag (like PollInterval, RediscoveryInterval or so...) for propper polling scheduling. Is there possible to share the piece of code (at least the PropertyBag definition), where creating the Node, Interface and their pollers? If you believe it's everything correct, there would be great to share also SNMP walk of the device.

                   

                  Regards,

                  H.

                    • Re: Problems with creating nodes with interfaces when using SDK (Perl)
                      bart_vh

                      Sure, no problem, there are also some custom attributes that I populate:

                       

                      sub addNode($$$;$$$$$$$$$$){
                              my $ip=shift;
                              my $name=shift;
                              my $community=shift;

                              my $BA_BU = shift;
                              my $City = shift;
                              my $Country = shift;
                              my $CustomerName = shift;
                              my $Device_Type = shift;
                              my $GMT_Offset = shift;
                              my $Local_Company = shift;
                              my $Provider = shift;
                              my $Region = shift;
                              my $Layer = shift;

                              $GMT_Offset=~s/\,/\./g if defined($GMT_Offset);

                              print "Adding node '$name' with IP '$ip'\n" if $ver;

                              my $response = $swis->Create('Orion.Nodes', {
                                      'DNS'=>' ',
                                      'IPAddress'=>$ip,
                                      'IPAddressGUID'=>ip2guid($ip),
                                      'Caption'=>$name,
                                      'SysName'=>$name,

                                      # ONEdb custom properties
                                      'BA_BU'=>$BA_BU,
                                      'City'=>$City,
                                      'Country'=>$Country,
                                      'CustomerName'=>$CustomerName,
                                      'Device_Type'=>$Device_Type,
                                      'DontSyncWithONEdb'=>0,
                                      'Excluded'=>0,
                                      'GMT_Offset'=>$GMT_Offset,
                                      'Local_Company'=>$Local_Company,
                                      'Provider'=>$Provider,
                                      'Region'=>$Region,
                                      'Layer'=>$Layer,
                                      # end of ONEdb custom properties

                                      'DynamicIP'=>0,

                                      'EngineID'=>leastLoadedEngine(),# Define the polling engine
                                      'Status'=>0,
                                      'UnManaged'=>0,
                                      'Allow64BitCounters'=>1,
                                      'SysObjectID'=>' ',
                                      # 'Description'=>' ', # Does not work, adding a node with this parameter will fail. But not adding it leaves the node details blank !
                                      'Contact'=>' ',
                                      'Location'=>' ',
                                      'MachineType'=>'Physical',
                                      'Vendor'=>'Volvo TEST',
                                      'VendorIcon'=>' ',
                                      'IOSImage'=>' ',
                                      'IOSVersion'=>' ',
                                      'ObjectSubType'=>"SNMP",
                                      'SNMPVersion'=>2,
                                      'SNMPV2Only'=>0,
                                      'External'=>0,
                                      'Community'=>$community,

                                      'RediscoveryInterval'=>30,      # minutes (5..525600=1 year)
                                      'PollInterval'=>120,            # seconds (1..1200)
                                      'StatCollection'=>5             # minutes (1..600)
                                  });

                              if(defined($response)){
                                      print "response: $response \n" if $ver>1;
                              } else {
                                      print "ERROR: Failed to create node '$name' with IP $ip!\n";
                                      return undef;
                              }

                              if($response=~/NodeID=(\d+)/){

                                      my $nodeID = $1;
                                      print "node '$name' with IP $ip created: nodeID=$nodeID\n";

                                      # create thecommon options for all pollers
                                      my %options = (
                                              'NetObject'=>"N:$nodeID",
                                              'NetObjectType'=>"N",
                                              'NetObjectID'=>$nodeID
                                      );

                                      $options{'PollerType'}="N.Details.SNMP.Generic";
                                      $response= $swis->Create( 'Orion.Pollers', \%options );
                                      if($response=~/PollerID=(\d+)/ && $ver){ print "\tpoller '$options{'PollerType'}' added (PollerID=$1)\n"; }

                                      $options{'PollerType'}="N.Uptime.SNMP.Generic";
                                      $response=$swis->Create( 'Orion.Pollers', \%options );
                                      if($response=~/PollerID=(\d+)/ && $ver){ print "\tpoller '$options{'PollerType'}' added (PollerID=$1)\n"; }

                                      $options{'PollerType'}="N.Cpu.SNMP.CiscoGen3";
                                      $response=$swis->Create( 'Orion.Pollers', \%options );
                                      if($response=~/PollerID=(\d+)/ && $ver){ print "\tpoller '$options{'PollerType'}' added (PollerID=$1)\n"; }

                                      $options{'PollerType'}="N.Memory.SNMP.CiscoGen3";
                                      $response=$swis->Create( 'Orion.Pollers', \%options );
                                      if($response=~/PollerID=(\d+)/ && $ver){ print "\tpoller '$options{'PollerType'}' added (PollerID=$1)\n"; }

                                      print "\n" if $ver;
                                      return $nodeID;
                              } else {
                                      print "ERROR: response did not contain a valid NodeID for node '$name' with IP $ip!\n";
                              }
                      }

                        • Re: Problems with creating nodes with interfaces when using SDK (Perl)
                          bart_vh

                          I compared with a node that was added through the GUI, and there, the native pollers are attached to the node, for the ones added through the SDK, they are not. When I explicitly add these, the nodes seem to be monitored as expected. (Only the SysObjectID remains blank)

                           

                          N.Status.ICMP.Native

                          N.Status.SNMP.Native

                          N.ResponseTime.ICMP.Native

                          N.ResponseTime.SNMP.Native

                           

                          Any idea why these native pollers are not there, or should I always add them when using the SDK?

                            • Re: Problems with creating nodes with interfaces when using SDK (Perl)
                              madhavan

                              Hi,

                               

                              You need to add them when you create nodes via SDK. Also provide values for below provided properties for proper polling.

                               

                                      'BufferNoMemThisHour'  => -2,

                                      'BufferNoMemToday'     => -2,

                                      'BufferSmMissThisHour' => -2,

                                      'BufferSmMissToday'    => -2,

                                      'BufferMdMissThisHour' => -2,

                                      'BufferMdMissToday'    => -2,

                                      'BufferBgMissThisHour' => -2,

                                      'BufferBgMissToday'    => -2,

                                      'BufferLgMissThisHour' => -2,

                                      'BufferLgMissToday'    => -2,

                                      'BufferHgMissThisHour' => -2,

                                      'BufferHgMissToday'    => -2,

                                      'PercentMemoryUsed'    => -2,

                                      'TotalMemory'          => -2,

                              • Re: Problems with creating nodes with interfaces when using SDK (Perl)
                                Jan Pelousek

                                Hi,

                                the CRUD operations are now pretty straight forward and don't do anything you ask it for as when implementing of more wise scripts this would be contraproductive (you can create also WMI nodes, SNMP status pollers instead of ICMP and so one). The SysObjectID should be updated after rediscovery, when set to NULL (you have set it to blank string). I hope it helps.

                              • Re: Problems with creating nodes with interfaces when using SDK (Perl)
                                tdanner

                                I tried your script in our lab. Here are the changes I needed to make to get it working:

                                 

                                # Add two properties to the $swis->Create('Orion.Nodes', { ... }) call:

                                        'NodeDescription'=>' ',

                                        'EntityType'   => 'Orion.Nodes',

                                 

                                Add the "N.ResponseTime.ICMP.Native" and "N.Status.ICMP.Native" pollers.

                                 

                                Note for future readers of this thread: NPM 11.5 (currently a release candidate) is a lot more forgiving about the properties you need to provide to create a node. It will provide default values for most properties and a reasonable error message for properties that are missing or have invalid values instead of just blindly creating the node in a non-working state. You still need to specify the pollers to use.

                        • Re: Problems with creating nodes with interfaces when using SDK (Perl)
                          tdanner

                          I was able to set a custom property to "Göteborg" through PowerShell and the REST API.

                           

                          For that issue, you might find it helpful to use a proxy to see the actual HTTP request. That can highlight issues like missing/incorrect character encoding headers. On windows, I like to use Fiddler for this purpose.