42 Replies Latest reply on Mar 9, 2017 2:32 PM by tdanner

    Add pollers and interfaces via SDK

    kev!

      Howdy,

       

        When we add a node manually via the Orion GUI, setting the interfaces and pollers are steps in the process.

      I have been able to script adding nodes, but must then go in to set the poller and interfaces via the GUI.

       

      Can someone let me know what to send in order to add these two configurations after adding a new node?

       

       

      Please advise,

      Kev!

        • Re: Add pollers and interfaces via SDK
          tdanner

          Have you tried using the Discovery API to add the nodes? Discovery · solarwinds/OrionSDK Wiki · GitHub

            • Re: Add pollers and interfaces via SDK
              kev!

              Howdy,

               

                I don't see anything about enabling pollers. It could be useful, but seems complex when all I want is to select one or only a few interfaces. There should be some xml I can send to accomplish this. In the GUI, they are simple checkboxes during the add.

               

              Thanks,

              Kev!

              P.S. There is a bit of meta data that needs to be associated with individual nodes added, which I am doing already, that cannot be "discovered". I just need to also enable the custom poller and set the interfaces as well...

            • Re: Add pollers and interfaces via SDK
              kev!

              Howdy,

               

              Perhaps this would work for the pollers?

               

              NPM Universal Device Pollers · solarwinds/OrionSDK Wiki · GitHub

               

              Thanks,

              Kev!

              1 of 1 people found this helpful
              • Re: Add pollers and interfaces via SDK
                kev!

                Howdy,

                 

                When I try this...

                 

                  print $swis->Create('Orion.NPM.CustomPollerAssignmentOnNode', {

                 

                    'CustomPollerID' => 'cd827980-cafd-4816-910a-ba6ecdf59e7d',

                    'NodeID' => $NodeId

                    });

                 

                I get this in return...

                 

                <s:Header>

                  <log xmlns="http://schemas.solarwinds.com/2007/08/informationservice">

                    2016-11-17 12:24:10,318 [181] WARN  SolarWinds.InformationService.ChangeBroker.Broker - (null) (null)

                    Change indication for Orion.NPM.CustomPollerAssignmentOnNode is required to contain {ID, NodeID} key properties, but {ID} missing.&#xD;

                  </log>

                </s:Header>

                 

                But it works and an ID is assigned?

                 

                Please advise,

                Kev!

                • Re: Add pollers and interfaces via SDK
                  kev!

                  Howdy,

                   

                    This seems to add something...

                   

                  print $swis->Create('Orion.NPM.Interfaces', {

                   

                      'Caption' => 'wan-0',

                      'Name' => 'wan-0',

                      'IfName' => 'wan-0',

                      'InterfaceIndex' => '158',

                      'ObjectSubType' => 'SNMP',

                      'Status' => '0',

                      'RediscoveryInterval' => '5',

                      'PollInterval' => '120',

                      'StatCollection' => '9',

                      'NodeID' => $NodeId

                      });

                   

                  }

                   

                  But it does not seem to be associated with the node properly? do I need to get the InterfaceID and invoke AddInterfacesOnNode? how do I format the discovered interfaces to include only the one interface?

                   

                  Please advise,

                  Kev!

                    • Re: Add pollers and interfaces via SDK
                      tdanner

                      The AddInterfacesOnNode verb is the way to go. You have to feed it input that you get from calling the DiscoverInterfacesOnNode verb first. DiscoverInterfacesOnNode will enumerate all of the interfaces on the target node and return some data about them, but won't modify Orion configuration at all. Filter out the interfaces you don't care about and pass what's left to AddInterfacesOnNode. I don't have a sample for that in Perl, but here's one in Python: https://github.com/solarwinds/orionsdk-python/blob/master/samples/discover_and_add_interfaces.py

                        • Re: Add pollers and interfaces via SDK
                          kev!

                          Howdy,

                           

                            I guess I need a perl example for filtering the results...

                           

                           

                          Thanks though,

                          Kev!

                          • Re: Add pollers and interfaces via SDK
                            kev!

                            Howdy,

                             

                              This seems to work...

                             

                            my $discos = $swis->Invoke("Orion.NPM.Interfaces", "DiscoverInterfacesOnNode", [673] );

                             

                            When I do this...

                             

                            print $swis->Invoke("Orion.NPM.Interfaces", "AddInterfacesOnNode", [673, $discos, 'AddDefaultPollers'] );

                             

                            I get this...

                             

                            <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><log xmlns="http://schemas.solarwinds.com/2007/08/informationservice"/></s:Header><s:Body><InvokeResponse xmlns="http://schemas.solarwinds.com/2007/08/informationservice"><InvokeResult><Return z:Id="1" xmlns="http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract" xmlns:d1p1="http://schemas.solarwinds.com/2008/NPM" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/"><d1p1:DiscoveredInterfaces z:Id="2" z:Size="0"/><d1p1:Result>Succeed</d1p1:Result></Return></InvokeResult></InvokeResponse></s:Body></s:Envelope>

                             

                            But the interface does not show as added in Orion?

                             

                            Please advise,

                            Kev!

                            • Re: Add pollers and interfaces via SDK
                              kev!

                              Howdy,

                               

                                I saw in another thread you correct a guy trying to build the payload from scratch.

                               

                              When I try this ...

                               

                              print $swis->Invoke("Orion.NPM.Interfaces", "AddInterfacesOnNode", [673,[

                              {

                                      'ifIndex'=>158,

                                      'Caption'=>'wan-0',

                                      'ifType'=>69,

                                      'IfSubType'=>0,

                                      'InterfaceID'=>0,

                                      'Manageable'=>'true',

                                      'ifSpeed'=>0

                              }]

                              , 'AddDefaultPollers'] );

                               

                              I get this error?

                              System.Runtime.Serialization.SerializationException: Element ':arg' contains data from a type that maps to the name ':namesp9'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type corresponding to 'namesp9' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.

                               

                              Please advise,

                              Kev!

                                • Re: Add pollers and interfaces via SDK
                                  tdanner

                                  Can you send me a complete script? With that I can try to reproduce your issue and make a better recommendation.

                                    • Re: Add pollers and interfaces via SDK
                                      kev!

                                      Howdy

                                       

                                        Thanks for your help. I am trying to find the correct format for the "discovered" interfaces to pass in the 2nd argument to addInterfacesOnNode. I took the format below from a reponse of yours to another poster, however it does not seem to know the "type" for the hash or array as constructed.

                                      The xml looks good except it wraps the elements I pass in an "arg" tag of type "namesp9" and chokes on it...

                                       

                                      Any insight is appreciated.

                                       

                                      Kev!

                                       

                                      [code]

                                      #!/usr/bin/perl

                                      use SW::InformationService;

                                      use SW::Orion;

                                      use SOAP::Lite;

                                       

                                      my $hostname = "11.22.33.44";

                                      my $username = "circus\\bozo";

                                      my $password = "bigtop";

                                       

                                      my $endpoint = "https://$hostname:17778/SolarWinds/InformationService/v3/OrionBasic";

                                      my $swis = SW::InformationService->new();

                                      $swis->outputxml("true");

                                      $swis->proxy($endpoint);

                                      $swis->proxy->http_request->authorization_basic($username, $password);

                                       

                                      #code above is verified good

                                       

                                      #$swis->QueryXml,

                                      #$swis->Invoke("Orion.NPM.Interfaces", "DiscoverInterfacesOnNode", [673] )

                                      #$swis->Read('swis://localhost/Orion/Orion.Nodes/NodeID=903/CustomProperties')

                                      #$swis->Create('Orion.Nodes',

                                      #$swis->Create('Orion.Pollers',

                                      #all work fine

                                       

                                      #code below fails

                                       

                                      print $swis->Invoke("Orion.NPM.Interfaces", "AddInterfacesOnNode", [673,

                                      {

                                              'ifIndex'=>158,

                                              'Caption'=>'wan-0',

                                              'ifType'=>69,

                                              'IfSubType'=>0,

                                              'InterfaceID'=>0,

                                              'Manageable'=>'true',

                                              'ifSpeed'=>0

                                      }

                                      , 'AddDefaultPollers'] );

                                       

                                      [/code]

                                       

                                      [error]

                                       

                                      Use of uninitialized value in substitution (s///) at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 1117.

                                      Use of uninitialized value in exists at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 1118.

                                      Use of uninitialized value in hash element at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 1118.

                                      Use of uninitialized value in hash element at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 1122.

                                      Use of uninitialized value in hash element at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 1122.

                                       

                                      <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><log xmlns="http://schemas.solarwinds.com/2007/08/informationservice">2016-12-09 13:19:41,301 [38] ERROR SolarWinds.InformationService.Core.InformationService - (null) (null)   Exception for Operation: &lt;soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:msa="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:namesp9="http://namespaces.soaplite.com/perl" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:swis="http://schemas.solarwinds.com/2007/08/informationservice" xmlns:swpb="http://schemas.solarwinds.com/2007/08/informationservice/propertybag" xmlns:sys="http://schemas.datacontract.org/2004/07/System.Xml" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;&#xD;

                                        &lt;s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;&#xD;

                                          &lt;To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;https://168.127.9.90:17778/SolarWinds/InformationService/v3/OrionBasic</To>

                                          &lt;Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://schemas.solarwinds.com/2007/08/informationservice/InformationService/Invoke</Action>

                                        &lt;/s:Header&gt;&#xD;

                                        &lt;soap:Body&gt;&#xD;

                                          &lt;swis:Invoke&gt;&#xD;

                                            &lt;swis:entity xsi:type="xsd:string"&gt;Orion.NPM.Interfaces&lt;/swis:entity&gt;&#xD;

                                            &lt;swis:verb xsi:type="xsd:string"&gt;AddInterfacesOnNode&lt;/swis:verb&gt;&#xD;

                                            &lt;swis:parameters&gt;&#xD;

                                              &lt;sys:XmlElement&gt;&#xD;

                                                &lt;arg&gt;673&lt;/arg&gt;&#xD;

                                              &lt;/sys:XmlElement&gt;&#xD;

                                              &lt;sys:XmlElement&gt;&#xD;

                                       

                                                &lt;arg xsi:type="namesp9"&gt;&#xD;

                                       

                                                  &lt;Manageable xsi:type="xsd:boolean"&gt;true&lt;/Manageable&gt;&#xD;

                                                  &lt;Caption xsi:type="xsd:string"&gt;wan-0&lt;/Caption&gt;&#xD;

                                                  &lt;InterfaceID xsi:type="xsd:int"&gt;0&lt;/InterfaceID&gt;&#xD;

                                                  &lt;ifSpeed xsi:type="xsd:int"&gt;0&lt;/ifSpeed&gt;&#xD;

                                                  &lt;IfSubType xsi:type="xsd:int"&gt;0&lt;/IfSubType&gt;&#xD;

                                                  &lt;ifType xsi:type="xsd:int"&gt;69&lt;/ifType&gt;&#xD;

                                                  &lt;ifIndex xsi:type="xsd:int"&gt;158&lt;/ifIndex&gt;&#xD;

                                                &lt;/arg&gt;&#xD;

                                              &lt;/sys:XmlElement&gt;&#xD;

                                              &lt;sys:XmlElement&gt;&#xD;

                                                &lt;arg&gt;AddDefaultPollers&lt;/arg&gt;&#xD;

                                              &lt;/sys:XmlElement&gt;&#xD;

                                            &lt;/swis:parameters&gt;&#xD;

                                          &lt;/swis:Invoke&gt;&#xD;

                                        &lt;/soap:Body&gt;&#xD;

                                      &lt;/soap:Envelope&gt;&#xD;

                                      2016-12-09 13:19:41,301 [38] ERROR SolarWinds.InformationService.Core.InformationService - (null) (null)         Exception caught in method SolarWinds.InformationService.Core.InformationService.Invoke&#xD;

                                      SolarWinds.InformationService.Verb.VerbExecutorException: Verb Orion.NPM.Interfaces.AddInterfacesOnNode cannot unpackage parameter 1 of type SolarWinds.NPM.Common.Models.Discovery.InterfaceDiscovery.DiscoveredLiteInterface[] ---&gt;

                                       

                                      System.Runtime.Serialization.SerializationException: Element ':arg' contains data from a type that maps to the name ':namesp9'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type corresponding to 'namesp9' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.&#xD;

                                       

                                         at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)&#xD;

                                         at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)&#xD;

                                         at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;

                                         at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;

                                         at SolarWinds.InformationService.Verb.VerbExecutorContext.&lt;&gt;c__DisplayClass19_0.&lt;UnpackageParameters&gt;b__0(Int32 index)&#xD;

                                         --- End of inner exception stack trace ---&#xD;

                                         at SolarWinds.InformationService.Verb.VerbExecutorContext.&lt;&gt;c__DisplayClass19_0.&lt;UnpackageParameters&gt;b__0(Int32 index)&#xD;

                                         at SolarWinds.InformationService.Verb.VerbExecutorContext.CreateParameters(Func`2 getParameterAt, Int32 parametersCount, Stream stream)&#xD;

                                         at SolarWinds.InformationService.Verb.VerbExecutorContext.UnpackageParameters(XmlElement[] parameters, Stream stream)&#xD;

                                         at SolarWinds.InformationService.Core.InformationService.Invoke[T](String entity, String verb, Action`1 setupParameters, Func`2 extractReturnValue)&#xD;

                                      </log></s:Header><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="en-US">Orion.NPM.Interfaces.AddInterfacesOnNode failed, check fault information.

                                      Verb Orion.NPM.Interfaces.AddInterfacesOnNode cannot unpackage parameter 1 of type SolarWinds.NPM.Common.Models.Discovery.InterfaceDiscovery.DiscoveredLiteInterface[]</faultstring><detail><InformationServiceFaultContract xmlns="http://schemas.solarwinds.com/2007/08/informationservice" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Message>Verb Orion.NPM.Interfaces.AddInterfacesOnNode cannot unpackage parameter 1 of type SolarWinds.NPM.Common.Models.Discovery.InterfaceDiscovery.DiscoveredLiteInterface[]</Message><ExceptionType>SolarWinds.InformationService.Verb.VerbExecutorException</ExceptionType><FullException>SolarWinds.InformationService.Verb.VerbExecutorException: Verb Orion.NPM.Interfaces.AddInterfacesOnNode cannot unpackage parameter 1 of type SolarWinds.NPM.Common.Models.Discovery.InterfaceDiscovery.DiscoveredLiteInterface[] ---&gt; System.Runtime.Serialization.SerializationException: Element ':arg' contains data from a type that maps to the name ':namesp9'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type corresponding to 'namesp9' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.&#xD;

                                         at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)&#xD;

                                         at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)&#xD;

                                         at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;

                                         at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)&#xD;

                                         at SolarWinds.InformationService.Verb.VerbExecutorContext.&lt;&gt;c__DisplayClass19_0.&lt;UnpackageParameters&gt;b__0(Int32 index)&#xD;

                                         --- End of inner exception stack trace ---&#xD;

                                         at SolarWinds.InformationService.Verb.VerbExecutorContext.&lt;&gt;c__DisplayClass19_0.&lt;UnpackageParameters&gt;b__0(Int32 index)&#xD;

                                         at SolarWinds.InformationService.Verb.VerbExecutorContext.CreateParameters(Func`2 getParameterAt, Int32 parametersCount, Stream stream)&#xD;

                                         at SolarWinds.InformationService.Verb.VerbExecutorContext.UnpackageParameters(XmlElement[] parameters, Stream stream)&#xD;

                                         at SolarWinds.InformationService.Core.InformationService.Invoke[T](String entity, String verb, Action`1 setupParameters, Func`2 extractReturnValue)</FullException></InformationServiceFaultContract></detail></s:Fault></s:Body></s:Envelope>

                                       

                                      [/error]

                                        • Re: Add pollers and interfaces via SDK
                                          tdanner

                                          Apologies - I lost track of this thread in December and haven't responded. Is this still a problem for you or have you found a solution already?

                                            • Re: Add pollers and interfaces via SDK
                                              kev!

                                              Howdy,

                                               

                                              Thank you for following up. I have not found a solution.

                                               

                                              Any help would be appreciated,

                                              Kev!

                                                • Re: Add pollers and interfaces via SDK
                                                  tdanner

                                                  I have stopped fighting with SOAP encoding for these things. It is too finicky. Fortunately SWIS also supports json encoding. Here's a Perl script that calls AddInterfacesOnNode using the JSON encoding instead:

                                                   

                                                  AddInterfacesOnNode.pl · GitHub

                                                   

                                                  (thwack formatting was giving me too much trouble, so I posted it as a gist instead)

                                                  1 of 1 people found this helpful
                                                    • Re: Add pollers and interfaces via SDK
                                                      kev!

                                                      Howdy,

                                                       

                                                        OK! Many thanks. This has got me farther along to a useful stage.

                                                       

                                                      Just to let you know though, the code produced errors for ssl_opts and parse_json as “Can’t locate object method”. Luckily, I don’t need those apparently. Cert checks are off by default, and the parse was to check the result, which I can do in another manner.

                                                       

                                                      My question now is, how can I set the Interface Name? By default it has a bunch of 0000 after it and I would like to truncate at the first white space.

                                                       

                                                       

                                                      Thanks again,

                                                      Kev!

                                                        • Re: Add pollers and interfaces via SDK
                                                          kev!

                                                          Howdy,

                                                           

                                                            This worked for me.

                                                           

                                                          print $swis->Update("swis://localhost/Orion/Orion.Nodes/NodeID=$NodeId/Interfaces/InterfaceID=$InterfaceId", {

                                                           

                                                                          'DisplayName' => 'wan-0'

                                                                  });

                                                           

                                                           

                                                          Kev!

                                                          1 of 1 people found this helpful
                                                        • Re: Add pollers and interfaces via SDK
                                                          kev!

                                                          Howdy,

                                                           

                                                            This issue just keeps on keeping on... I have some systems that when I try to addInterfacesOnNode it gives back "Result:0" but both InterfaceId's returned are "-1", and the ports are NOT added on the node.

                                                           

                                                          The same code on another type of device works fine.

                                                           

                                                           

                                                          Any Ideas?

                                                           

                                                          Please advise,
                                                          Kev!

                                                            • Re: Add pollers and interfaces via SDK
                                                              tdanner

                                                              Can you see anything notably different between systems where it works as expected and systems where it does not? All polled via SNMP? Same vendors?

                                                                • Re: Add pollers and interfaces via SDK
                                                                  kev!

                                                                  Howdy,

                                                                   

                                                                    Yes, the devices are totally different types and vendors. All are polled via snmp. Calix ONT’s are the devices that it works for. Accedian devices do not work correctly. I will try some Juniper devices to see how they behave. The only difference is for the ONT’s I add a custom poller to retrieve FSAN serial number before adding the interfaces. I tried adding the default pollers first as well but it did not change the behavior.

                                                                   

                                                                  Kev!

                                                                  • Re: Add pollers and interfaces via SDK
                                                                    kev!

                                                                    Howdy,

                                                                     

                                                                      Could you provide a perl example of the interface discovery and filtering out only the interfaces of interest? I can’t figure it out from the power shell examples…

                                                                     

                                                                     

                                                                    Please advise,

                                                                    Kev!

                                                                    • Re: Add pollers and interfaces via SDK
                                                                      kev!

                                                                      Howdy,

                                                                       

                                                                      It was the community string. I am still interested in the interface discovery filter perl example if you can provide one.

                                                                       

                                                                       

                                                                      Thanks,

                                                                      Kev!

                                                                        • Re: Add pollers and interfaces via SDK
                                                                          tdanner

                                                                          Can you show us what you have so far?

                                                                            • Re: Add pollers and interfaces via SDK
                                                                              kev!

                                                                              Howdy,

                                                                               

                                                                                So far I am able to addInterfacesToNode if I know the ifIndex. My next step requires me to add interfaces that I do not know the ifIndex.

                                                                               

                                                                               

                                                                               

                                                                              my $interface = {

                                                                               

                                                                                      'ifIndex'=>158,

                                                                                      'Caption'=>'wan-0',

                                                                                      'ifType'=>69,

                                                                                      'IfSubType'=>0,

                                                                                      'InterfaceID'=>0,

                                                                                      'Manageable'=>'true',

                                                                                      'ifSpeed'=>0

                                                                                };

                                                                               

                                                                                my $port4 = {

                                                                               

                                                                                      'ifIndex'=>4,

                                                                                      'Caption'=>'PORT-4',

                                                                                      'ifType'=>6,

                                                                                      'IfSubType'=>0,

                                                                                      'InterfaceID'=>0,

                                                                                      'Manageable'=>'true',

                                                                                      'ifSpeed'=>0

                                                                                };

                                                                               

                                                                                $interfaceList = ;

                                                                               

                                                                              my $argList = ;

                                                                               

                                                                              my $response = $client->POST('/SolarWinds/InformationService/v3/Json/Invoke/Orion.NPM.Interfaces/AddInterfacesOnNode', encode_json($argList), { "Content-type" => 'application/json'});

                                                                               

                                                                               

                                                                               

                                                                              Please advise,

                                                                              Kev!

                                                                                • Re: Add pollers and interfaces via SDK
                                                                                  tdanner

                                                                                  Ok, so you are not calling DiscoverInterfacesOnNode and using that list. Let me see if I can put something together in Perl.

                                                                                    • Re: Add pollers and interfaces via SDK
                                                                                      tdanner

                                                                                      Here's some sample code that works. Warning! This is written by someone who knows just enough Perl to get by. Please don't take this as advice on how to write good Perl, just a demonstration that you can call DiscoverInterfacesOnNode, filter the discovered interfaces, and then pass them to AddInterfacesOnNode.

                                                                                       

                                                                                      I was having trouble with the syntax highlighting formatter on thwack, so I made a gist instead.

                                                                                       

                                                                                      DiscoverInterfacesOnNode.pl · GitHub

                                                                                        • Re: Add pollers and interfaces via SDK
                                                                                          kev!

                                                                                          Howdy,

                                                                                           

                                                                                                         From your code I was able to figure it out!

                                                                                           

                                                                                          So the next piece I need is to enable NCM management and set the Global connection profile. Can you give me a hint?

                                                                                           

                                                                                          Thanks,

                                                                                          Kev!

                                                                                            • Re: Add pollers and interfaces via SDK
                                                                                              tdanner

                                                                                              To enable NCM management of a node, call the verb "AddNodeToNCM" on the entity "Cirrus.Nodes". It has one parameter: the NodeID to add.

                                                                                               

                                                                                              What is the use case for programmatically changing the global connection profile?

                                                                                                • Re: Add pollers and interfaces via SDK
                                                                                                  kev!

                                                                                                  Howdy,

                                                                                                   

                                                                                                    When we manually set a node up in the gui, and select manage node with NCM yes, The global connection profile has to be set for the customer/device type so the correct creds and what not are used.

                                                                                                   

                                                                                                  I really appreciate all the help you have given me.

                                                                                                   

                                                                                                  Thanks,

                                                                                                  Kev!

                                                                                                    • Re: Add pollers and interfaces via SDK
                                                                                                      tdanner

                                                                                                      Oh, I see. Once you have called AddNodeToNCM, the node will appear in Cirrus.Nodes. You can update the connection profile for the node with a SWIS update operation. To execute an update, you will need to retrieve the SWIS Uri for the new node. You can get that with a query like "SELECT Uri FROM Cirrus.Nodes WHERE CoreNodeID=123".

                                                                                                        • Re: Add pollers and interfaces via SDK
                                                                                                          kev!

                                                                                                          Howdy,

                                                                                                           

                                                                                                          Can you tell me the syntax for these calls? This does not work for me…

                                                                                                           

                                                                                                          my $conprofs = $swis->Invoke('Cirrus.Nodes', 'GetAllConnectionProfiles'  );

                                                                                                           

                                                                                                          I need this to identify which profile to add?

                                                                                                           

                                                                                                          And I don’t know the usage for  these…

                                                                                                           

                                                                                                          $swis->Invoke('Cirrus.Nodes', 'AddNodeToNCM', ???  ) # what paramerters go here?

                                                                                                           

                                                                                                           

                                                                                                          Will AddNodeToNCM return the CoreNodeid? What is the relationship between CoreNodeId and NodeId?

                                                                                                           

                                                                                                           

                                                                                                          $swis->update('Cirrus.Node.Properties', { 'NodeID' => $NodeId, 'CoreNodeID' => $CNodeId, 'ConnectionProfile' => $myconprof  })

                                                                                                           

                                                                                                          Please advise,

                                                                                                          Kev!

                                                                                                            • Re: Add pollers and interfaces via SDK
                                                                                                              tdanner

                                                                                                              1. What happens with your call to GetAllConnectionProfiles? That one takes no arguments. Are you getting an error back?

                                                                                                               

                                                                                                              2. AddNodeToNCM takes one parameter: the NodeID to add to NCM. In your call to $swis-Invoke, the verb parameters need to be in a perl array. Like this:

                                                                                                               

                                                                                                              $swis->Invoke('Cirrus.Nodes', 'AddNodeToNCM', [ $nodeId ] );

                                                                                                               

                                                                                                              3. NCM ("Cirrus") has its own IDs for nodes. These are easily distinguished from the regular Orion NodeID values because NCM node IDs are GUIDs and the regular Orion NodeIDs are integers. Within Cirrus.Nodes, the "NodeID" property is the NCM NodeID (a GUID) and the "CoreNodeID" property is the regular Orion NodeID (integer). AddNodeToNCM will return the NCM NodeID.

                                                                                                               

                                                                                                              4. The first parameter to the Update call is a SWIS Uri. The second parameter is a perl hash of the properties to change. If you only want to change the 'ConnectionProfile' property, then that should be the only thing in the hash.

                                                                                                  • Re: Add pollers and interfaces via SDK
                                                                                                    kev!

                                                                                                    Howdy,

                                                                                                     

                                                                                                    It’s me again… How do I query the NPM Custom pollers? I need a specific CustomPollerId for a UniqueName so I can add the correct ones to the node. My swis->XMLQuery is failing.

                                                                                                     

                                                                                                    Please advise,

                                                                                                    Kev!

                                                                                                      • Re: Add pollers and interfaces via SDK
                                                                                                        Martin.Krivanek

                                                                                                        If you're looking for SWIS entity or query example, it can be something like this:

                                                                                                         

                                                                                                        SELECT CustomPollerID, UniqueName, Description, OID, MIB FROM Orion.NPM.CustomPollers WHERE UniqueName='uniqueName'
                                                                                                        

                                                                                                         

                                                                                                        If you're after how to query this though Perl, I'll leave this to someone familiar with that :-)

                                                                                                         

                                                                                                        Regards,

                                                                                                        Martin

                                                                                                          • Re: Add pollers and interfaces via SDK
                                                                                                            kev!

                                                                                                            Howdy,

                                                                                                             

                                                                                                            Hmm,I don’t know why it did not work initially. Using your example I was able to get it going.

                                                                                                             

                                                                                                            Here is what is ended up with…

                                                                                                             

                                                                                                             

                                                                                                            my $xmlpids = $swis->QueryXml('SELECT CustomPollerId FROM Orion.NPM.CustomPollers WHERE UniqueName LIKE @id', {'id'=>'Jun%'} );

                                                                                                             

                                                                                                            my $cpids = [];

                                                                                                             

                                                                                                            foreach my $cpid ( $xmlpids =~ /.row..c0.(.*?)..c0/g ) {

                                                                                                             

                                                                                                              print $swis->Create('Orion.NPM.CustomPollerAssignmentOnNode', {

                                                                                                             

                                                                                                                'CustomPollerID' => $cpid,

                                                                                                                'NodeID' => $NodeId

                                                                                                                });

                                                                                                            }

                                                                                                             

                                                                                                             

                                                                                                            Thanks,

                                                                                                            Kev!