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]