28 Replies Latest reply on Mar 10, 2016 11:49 AM by mulder85gr

    Orion SDK, Add network interface and Volumes

    lmas

      Hi,

      First of all, thanks for the great SDK you provide :d). I'm using the powershell api, and it works fine.

      I have several questions about how to add network interface and volumes for monitoring.

      My problem is how to find the network interface index and name, and how to find the volumes index and caption; Is there a way to collect them using API as in the web interface when we click on List Resources?

      My second question is about when I had a volume (I get the index and the name manually) and I'm using the API (following code), i have an error on Volume Polling Details : The "Volume Polling Details " resource threw an exception..
      Specified cast is not valid.

       

      powershell Code:

      $newVolProps = @{
       NodeID=$nodeProps["NodeID"]; # NodeID on which the interface is working on
       VolumeIndex=[int]$VolumeIndex;
       Status=0;
       Type ="Fixed Disk";
       Icon ="FixedDisk.gif";
       Caption=$VolumeCaption;
       VolumeDescription=$VolumeDescription;

       }
       $newVolUri = New-SwisObject $swis –EntityType "Orion.Volumes" –Properties $newVolProps
       $VolProps = Get-SwisObject $swis -Uri $newVolUri
       # register specific pollers for the node
       # Disk Poller
       
       $poller = @{
       PollerType="Poller_VO";
       NetObject="V:"+$VolProps["VolumeID"]
       }
       $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

       

      thanks for your help

        • Re: Orion SDK, Add network interface and Volumes
          tom.rybka

          Imas,

          To your first question, we are working on a design of more comfortable API that would cover the complexity of respective use cases.

          To the second question, please try to initialize/set the RediscoveryInterval (PollInterval and StatCollection eventually, too) properties for volume entities. Although the properties are not declared in Orion.Volumes entity type, they should be recognized and this should help you.

          • Re: Orion SDK, Add network interface and Volumes
            tdanner

            Here's an updated version of this script that works with NPM 10.6:

             

            Add-PSSnapin SwisSnapin

            $nodeProps = @{NodeID=6}

            $VolumeIndex = 31

            $VolumeDescription = '/'

            $VolumeCaption = '/'

            $swis = Connect-Swis -Certificate

             

             

            $newVolProps = @{

                NodeID=$nodeProps["NodeID"]; # NodeID on which the interface is working on

                VolumeIndex=[int]$VolumeIndex;

                Status=0;

                Type ="Fixed Disk";

                Icon ="FixedDisk.gif";

                Caption=$VolumeCaption;

                VolumeDescription=$VolumeDescription;

                PollInterval=120;

                StatCollection=15;

                RediscoveryInterval=30;

                NextRediscovery=[DateTime]::UtcNow;

            }

            $newVolUri = New-SwisObject $swis -EntityType "Orion.Volumes" -Properties $newVolProps

            $VolProps = Get-SwisObject $swis -Uri $newVolUri

             

             

            Write-Host $newVolUri

             

            foreach ($pollerType in @('V.Status.SNMP.Generic','V.Details.SNMP.Generic','V.Statistics.SNMP.Generic')) {

                $poller = @{

                    PollerType=$pollerType;

                    NetObject="V:"+$VolProps["VolumeID"];

                    NetObjectType="V";

                    NetObjectID=$VolProps["VolumeID"];

                }

                $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

            }

             

             

            # Trigger a PollNow on the node to cause other properties and stats to be filled in

            Invoke-SwisVerb $swis Orion.Nodes PollNow @("N:" + $nodeProps["NodeID"])

              • Re: Orion SDK, Add network interface and Volumes
                HerrDoktor

                Hi TIm, will the NextRediscovery variable also work for other Locals?

                e.g. on a german Machine?

                 

                I also want to set the NextRediscovery but once I add this Parameter the Script errors out.

                 

                I assume this is because the SQL Database requres this in US - Locals format.

                • Re: Orion SDK, Add network interface and Volumes
                  hodgese

                  I used tdanner's code and it works to create a volume on my Windows host - but it doesn't work right when it comes to actually polling the drive.

                   

                  I put in "1", "C:\", and "C:\" for the Index, Description, and Caption. Although C:\ now shows up on the device's status page, it can't actually poll the drive. Perhaps I've specified the wrong information? How does SolarWinds link up the volume I've created with the SDK to an actual volume on the Windows host?

                    • Re: Orion SDK, Add network interface and Volumes
                      tdanner

                      Are you polling this Windows host from Orion using SNMP or WMI? My script above is for SNMP nodes.

                       

                      "How does SolarWinds link up the volume I've created with the SDK to an actual volume on the Windows host?"

                      For SNMP, this works by matching up the VolumeIndex property with the corresponding SNMP volume index (1.3.6.1.2.1.25.2.3.1.1).

                        • Re: Orion SDK, Add network interface and Volumes
                          hodgese

                          I'm polling the Windows host with SNMP. I walked the MIB to 1.3.6.1.2.1.25.2.3.1.1 (which I confirmed corresponds to C:) and indeed it has an index of 1. So basically I run the code you have above but with a VolumeIndex of 1.

                           

                          Here is the strange thing though: I run the code, and query the Orion.Volumes table and see the disk in there with an Index and VolumeIndex of 1. However, when I query a few moments later, the Index and VolumeIndex have changed to "0"! Of course, it's not going to successfully poll the drive using an index of 0. Any idea why that may be happening?

                            • Re: Orion SDK, Add network interface and Volumes
                              tdanner

                              I think I see what the problem is. Orion needs the VolumeDescription property to exactly match the value in the hrStorageDescr OID (1.3.6.1.2.1.25.2.3.1.3). The reason for this is that the index for volumes can change over time and Orion uses this hrStorageDescr value to keep the volume connected with its history even when it changes indexes. Unlike net-snmp on Linux, which just puts the volume mount point in hrStorageDescr, Windows populates hrStorageDescr with the drive letter, the volume label, and the volume serial number. So the hrStorageDescr for the C: drive on my desktop machine is "C:\ Label:Primary  Serial Number fe6f1d6b". When I use that as the value for VolumeDescription, Orion polls the newly-created volume object correctly.

                                • Re: Orion SDK, Add network interface and Volumes
                                  hodgese

                                  Got it! You were right that it has to do with the VolumeDescription property. But even when copied and pasted the value in SNMP from a MIB walker into my script, it still failed. After examining a GUI-created volume (for the 3rd time) I finally noticed an extra space in the VolumeDescription property vs. what was in SNMP. There are two spaces after the volume label and before the word "Serial". So a volume that had the description "D:\ Label:Data Serial Number 38606a01" in SNMP had the description "D:\ Label:Data  Serial Number 38606a01" in SolarWinds.

                                   

                                  After changing my code to add the extra space, it worked. I'm working on a script that will add a node, with volumes found on the computer using WMI. When I'm done with it, I'll post it on the forum for anyone else who may find it useful.

                                  1 of 1 people found this helpful
                          • Re: Orion SDK, Add network interface and Volumes
                            achtest

                            Hi Tim,

                             

                            when i run the script it says the following:

                             

                            New-SwisObject : Entity â?EntityType Orion.Volumes â?Properties not found.

                            At C:\volumeadd.ps1:22 char:28

                            + $newVolUri = New-SwisObject <<<<  $swis â?"EntityType $entity â?"Properties $newVolProps

                                + CategoryInfo          : InvalidOperation: (:) [New-SwisObject], FaultException`1

                                + FullyQualifiedErrorId : SwisError,SwisPowerShell.NewSwisObject

                            Get-SwisObject :The argument can not be bound to the parameter "uri" because it is NULL.

                            At C:\volumeadd.ps1:23 char:38

                            + $VolProps = Get-SwisObject $swis -Uri <<<<  $newVolUri

                                + CategoryInfo          : InvalidData: (:) [Get-SwisObject], ParameterBindingValidationException

                                + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,SwisPowerShell.GetSwisObject

                             

                            Can you tell me whats wrong? I only changed the volumeindex, description and Caption.

                          • Re: Orion SDK, Add network interface and Volumes
                            Vanzhou

                            i want to use SDK.

                            thanks for your help.

                            http://thwack.solarwinds.com/thread/59387

                            • Re: Orion SDK, Add network interface and Volumes
                              sw_ross


                              This looks helpful.  But I'm also looking for how to set "Asset Inventory".

                              Is that possible via the SDK?

                                • Re: Orion SDK, Add network interface and Volumes
                                  sw_ross

                                  I was able to get the physical drives added properly:

                                   

                                  $drives = Get-WmiObject -ComputerName hvacn02 -Class win32_Volume -Filter DriveType=3

                                  $drives = $drives | sort DriveLetter

                                  foreach ($drive in $drives){

                                      $VolumeDescription = "$($drive.Caption) Label:$($drive.Label)  Serial Number $([Convert]::ToString($drive.SerialNumber, 16))";

                                      $VolumeCaption = "$($drive.Caption) Label:$($drive.Label)  $([Convert]::ToString($drive.SerialNumber, 16))";

                                   

                                  but I'm still having trouble figuring out how to get "Asset Inventory" to work.  I've run this, but it's not showing checked for the node.  What am I missing?

                                      $poller = @{
                                          PollerType='N.AssetInventory.Snmp.Generic';
                                          NetObject="N:"+[int]$NodeID;
                                          NetObjectType="N";
                                          NetObjectID=[int]$NodeID;
                                      }

                                      $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

                                   

                                  Fixed a typo above.  There is a space after Serial Number not a colon in the the VolumeDescription.

                                • Re: Orion SDK, Add network interface and Volumes
                                  HolyGuacamole

                                  I'm not entirely sure if this will help your specific question, but micheal100 has been trying to simplify the use of API in PowerShell. If you haven't seen this, be sure to take a look at  PowerShell Module based on the SDK . One of the Cmdlets available in this module is

                                  • New-OrionInterface