cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 16

Is there someone who is adding different types of devices using OrionSDK to SolarWinds automatically

Is there someone who is adding different types of devices using OrionSDK to SolarWinds automatically.. there is a requirement for 1 of our customer...

i did chek few information but for adding a device i see only SNMPv3 option and nothing else..

can someone assist?

0 Kudos
4 Replies
Level 9

Hey @pratikmehta003,

@mesverrum is right, this is something I've been working on. In the next month or so, I hope to have this ready to provide to the community. I got about 300 lines into this response and then decided to stop. There are so many interdependent components to make this work that, if I try to piecemeal it together, it won't likely yield the results you need. I'll provide the code I use, at the end, to actually add the nodes, interfaces, and volumes, which might get you started. All of the data that goes into the $props variables can come from the discovery tables (Orion.DiscoveredNodes, Orion.DiscoveredVolumes, Orion.NPM.DiscoveredInterfaces, and Orion.DiscoveredPollers), if you want to just manually kick off a discovery (auto import set to false) on the web UI. I've also added some CSV's I use as lookup tables (attached)

# SNMPv2 Node
$newNodeProps = @{
    EntityType = 'Orion.Nodes'
    EngineID = $nodeToAdd.EngineID;
    DynamicIP = $false;
    IPAddress = $nodeToAdd.IPAddress;
    IPAddressGUID = $nodeToAdd.IPAddressGUID;
    ObjectSubType = "SNMP";
    SNMPVersion = $nodeToAdd.SnmpVersion;
    Community="SomeCommunityString";
    DNS = $nodeToAdd.DNS;
    SysName = $nodeToAdd.SysName;
    Caption = $nodeToAdd.SysName;
    SysObjectID = $nodeToAdd.SysObjectID;
    Vendor = $nodeToAdd.Vendor;
    VendorIcon = $nodeToAdd.VendorIcon;
    MachineType = $nodeToAdd.MachineType;
    Location = $nodeToAdd.Location;
    Contact = $nodeToAdd.Contact;
    NodeDescription = $nodeToAdd.SysDescription;
}

# SNMPv3 Node
$newNodeProps = @{
    EntityType = 'Orion.Nodes'
    EngineID = $nodeToAdd.EngineID;
    DynamicIP = $false;
    IPAddress = $nodeToAdd.IPAddress;
    IPAddressGUID = $nodeToAdd.IPAddressGUID;
    ObjectSubType = "SNMP";
    SNMPVersion = $nodeToAdd.SnmpVersion;
    SNMPV3Username = "user1";
    SNMPV3PrivMethod = "SHA1";
    SNMPV3PrivKey = "somePrivKey";
    SNMPV3PrivKeyIsPwd = $true;
    SNMPV3AuthMethod = "AES128";
    SNMPV3AuthKey = "SomeAuthKey";
    SNMPV3AuthKeyIsPwd = $false;
    DNS = $nodeToAdd.DNS;
    SysName = $nodeToAdd.SysName;
    Caption = $nodeToAdd.SysName;
    SysObjectID = $nodeToAdd.SysObjectID;
    Vendor = $nodeToAdd.Vendor;
    VendorIcon = $nodeToAdd.VendorIcon;
    MachineType = $nodeToAdd.MachineType;
    Location = $nodeToAdd.Location;
    Contact = $nodeToAdd.Contact;
    NodeDescription = $nodeToAdd.SysDescription;
}

$newNodeUri = New-SwisObject $swisConnection -EntityType "Orion.Nodes" -Properties $newNodeProps
$nodeProps = Get-SwisObject $swisConnection -Uri $newNodeUri

# For each poller, you want to do this
$poller = @{
    PollerType=$pollerType;
    NetObject="N:"+$nodeProps["NodeID"];
    NetObjectType="N";
    NetObjectID=$nodeProps["NodeID"];
}
$pollerUri = New-SwisObject $swisConnection -EntityType "Orion.Pollers" -Properties $poller

# INTERFACES
$newIntProps = @{
    NodeID=$node.NodeID;
    InterfaceIndex=[int]$interfaceToAdd.InterfaceIndex;
    Status=0;
    InterfaceType=$interfaceToAdd.InterfaceType;
    InterfaceTypeName=($lookup_interfaceType | Where InterfaceType -eq $interfaceToAdd.InterfaceType).InterfaceTypeName;
    InterfaceTypeDescription=($lookup_interfaceType | Where InterfaceType -eq $interfaceToAdd.InterfaceType).InterfaceTypeDescription;
    Icon=$([string]$interfaceToAdd.InterfaceType + '.gif');
    InterfaceName=$interfaceToAdd.InterfaceName;
    IfName=$interfaceToAdd.IfName;
    ObjectSubType="SNMP";
    PollInterval=120;
    StatCollection=9;
    RediscoveryInterval=30;
    #NextRediscovery=[DateTime]::UtcNow;
}

$newIntUri = New-SwisObject $swisConnection -EntityType "Orion.NPM.Interfaces" -Properties $newIntProps
$IntProps = Get-SwisObject $swisConnection -Uri $newIntUri

# For each poller, you want to do this
$poller = @{
    PollerType=$pollerType;
    NetObject="I:"+$IntProps["InterfaceID"];
    NetObjectType="I";
    NetObjectID=$IntProps["InterfaceID"];
}
$pollerUri = New-SwisObject $swisConnection -EntityType "Orion.Pollers" -Properties $poller

# VOLUMES
$newVolProps = @{
    NodeID=$node.NodeID;
    VolumeIndex=[int]$volumeToAdd.VolumeIndex;
    Status=0;
    VolumeTypeID=$volumeToAdd.VolumeType;
    Type =($lookup_volumeType | Where VolumeTypeID -eq $volumeToAdd.VolumeType).VolumeType;
    Icon =($lookup_volumeType | Where VolumeTypeID -eq $volumeToAdd.VolumeType).VolumeTypeIcon;
    Caption=$volumeToAdd.VolumeDescription;
    VolumeDescription=$volumeToAdd.VolumeDescription;
    PollInterval=120;
    StatCollection=15;
    RediscoveryInterval=30;
    #NextRediscovery=[DateTime]::UtcNow;
}

$newVolUri = New-SwisObject $swisConnection -EntityType "Orion.Volumes" -Properties $newVolProps
$VolProps = Get-SwisObject $swisConnection -Uri $newVolUri

# For each poller, you want to do this
$poller = @{
    PollerType=$pollerType;
    NetObject="V:"+$VolProps["VolumeID"];
    NetObjectType="V";
    NetObjectID=$VolProps["VolumeID"];
}
$pollerUri = New-SwisObject $swisConnection -EntityType "Orion.Pollers" -Properties $poller

For those pollers, you're going to need to look through that poller table and do some joins to get the list of pollers for each discovered node and then you'll need to setup some loops.

You should also keep in mind, there appears to be a bug with the SNMPv3 node add, where the SNMPV3PrivKeyIsPwd and SNMPV3AuthKeyIsPwd values don't appear to be properly implemented, so I end up just going in for any SNMPv3 nodes we add and I manually set the credential set to use and then 'rediscover' and 'poll now' and after a few minutes those come up. I've got a post here and a ticket open with support, where I'm hoping to better understand why that's happening:

https://thwack.solarwinds.com/t5/Orion-SDK-Discussions/SDK-Adding-Node-SNMPV3PrivKeyIsPwd-amp-SNMPV3...

Sorry, I know that leaves a bit out, but it would be much more confusing if I posted the rest of the code, since there are so many dependent components. Hopefully I'll be able to provide version 1 of the module on GitHub here in the next month or so.

0 Kudos

Quick note here. I ended up getting a resolution on the issues I was having with the SNMPv3 $newNodeProps. The SDK works fine, when you don't misinterpret values in the database, haha. This was one of the roadblocks for me publishing to the community, so hopefully you'll see something from me here in a few weeks (of course that assumes I have time given all of the other work commitments I've got).

0 Kudos

@bhumphrey has been developing something really impressive for building a template for importing nodes and setting up all their attributes based on a set of standards that can be adjusted for different teams. Hopefully he's got something sanitized for public consumption to share soon.
- Marc Netterfield, Github
0 Kudos
Level 11

You could create a discovery job via the API and then set custom properties, pollers, resources afterwards.

I started working on something similar a while ago but did not get the chance to finish it.

0 Kudos