9 Replies Latest reply on Feb 27, 2013 6:57 AM by Bohumil Klimek

    How do I get the prod.state from nodes table using the SDK with VB.NET 2010

    a001615

      Under normal circumstances, i would just use a direct sql query on the database table, however I'm being asked to use the SDK.

      The example supplied with the SDK isnt really clear on how to go about this.

      Is there documentation somewhere on what Classes exist besides AlertInfo.

      What would be really helpful is a tutorial type howto using Visual Studio.


        • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
          tdanner

          What do you mean by "prod.state"?

           

          If you know what SQL query you would use, I can help you find an equivalent.

            • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
              a001615

              select prod_state from nodes

               

              This may be an additional field that we added to the Nodes table, that we are populating to determine production vs. non production systems.

               

              I was attempting to modify the query string in the GetOneAlert function supplied in the documentation.

                • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
                  tdanner

                  Ok, in that case you will probably find it under CustomProperties. Like this:

                   

                  SELECT N.NodeID

                  FROM Orion.Nodes N

                  WHERE N.CustomProperties.prod_state = 'production'

                   

                  I recommend you use the SWQL Studio application to work out your query, then update the program.

                    • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
                      a001615

                      The issue isnt knowing what the query should be, the issue is the syntax needed in the vb.net application to obtain the data.

                      The example shows functions for GetOneAlert and a DataContract for AlertInfo, where can I find the same information for data from the Nodes table.

                       

                      <DataContract(Name:="AlertInfo", [Namespace]:="http://schemas.solarwinds.com/2008/Orion")> _

                      Class Alertinfo

                      <DataMember(Order:=1)> Public DefinitionId as String

                      <DataMember(Order:=2)> Public ObjectType as String

                      <DataMember(Order:=3)> Public ObjectId as String

                       

                      Would I change "AlertInfo" to "Node" or "Nodes" and what is DefinitionId, ObjectType, etc

                      Where can I find what is available?

                      Sorry, I'm new to accessing data using services, normally I would just create a data connection object in the app, execute the query and go through the recordset.

                        • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
                          tdanner

                          That AlertInfo class is the parameter to the Orion.AlertStatus.Acknowledge verb. It is used for specifying which alerts you want to acknowledge, not parsing the query results.

                           

                          In the GetOneAlert function, the query results are parsed by looking for the "data" result element, then the "A" element under that. The "data" element will always be present. The child element of data is "A" because that is the alias specified for Orion.AlertStatus in the query. There is only one "A" element because the query specifies "TOP 1" - if there were more result rows then there would be more "A" elements to iterate through.

                           

                          Hope that helps.

                            • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
                              Leon Adato

                              I'm working with Josh (a001615) and I think the point he (and I) are trying to get to is understanding the more than just the usage flow.

                               

                              For example: If I'm running the query "Select nodes.nodeid, nodes.caption, nodes.ip_address from nodes" and I get a particular resultset back, how do I iterate over each record and parse out the requested fields?

                               

                              Does this process change if one of the fields I'm pulling is a custom field.

                               

                              I got this working through trial and error using Perl, but now we're trying to create our own set of code snippets for VB, JavaScript and Powershell so that we can use the right technique depending on our situation. But it's a challenge since the documentation doesn't really give command syntax, parameters, possible output, or even a guide about HOW to take things step by step.

                               

                              Thanks for your patience in the face of our frustration.

                               

                              - Leon

                                • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
                                  tdanner

                                  We have samples for VB and PowerShell. What sort of environment are you using for JavaScript? A browser? Node.js? Something else?

                                   

                                  I think I could provide better assistance if you can post a partial script, i.e., we got this far and are not sure what to write next.

                                    • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
                                      Leon Adato

                                      In this case, what we want is very simple (or at least, a simple example, which we can build from there):

                                       

                                      I want to "select nodes.nodeid, nodes.caption, nodes.ip_address, nodes.city from nodes"

                                      I'm including city because I want at least one custom property, because I know (from doing this in Perl) that custom properties don't show up in the same "space" in the result set as the regular node fields.

                                       

                                      Once the record set is back, I want to print (to screen, to file, whatever) the sentence:

                                      For node $nodeid, the name is $caption, ip is $ipaddress and the city is $city

                                       

                                      Which is really just a way for me to see the structure of walking through a recordset and doing SOMETHING to it.

                                       

                                      If you have that handy, I'd be appreciative and grateful.

                                        • Re: How do I get the prod.state from nodes table using the SDK with VB.NET 2010
                                          Bohumil Klimek

                                          Hello Adatole,

                                           

                                          Is this what are you seeking for?

                                           

                                          $SWIS_Connection = Connect-Swis -Hostname "YOUR IP ADDRESS" -UserName "YOUR USERNAME" -Password "YOUR PASSWORD"

                                          $SWIS_Data = Get-SwisData $SWIS_Connection "SELECT T1.NodeID, T1.IP_Address, T1.Caption, T2.City FROM Orion.Nodes as T1 JOIN Orion.NodesCustomProperties AS T2 ON T1.nodeid=T2.nodeid"

                                           

                                          foreach ($Item in $SWIS_Data)

                                          {

                                              Write-Host ("For node " + $Item.NodeID + ", the name is " + $Item.Caption + ", ip is " + $Item.IP_Address + " and the city is " + $Item.City)

                                          }