This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

API created ICMP node never gets polled

I'm using PS and the API to add nodes from a CSV, and set custom properties. Here is the content of the CSV:

Code,     Hostname,     IpAddr,          Department,             Env,                  TimeOffset

C1,          DAG01,         10.0.0.1,    Win DBA,                    Testing,            0

C2,          DAG02,         10.0.0.2,     Server Operations,     Production,      0

The nodes get created, the custom properties get set, but they are never polled and the NodeID is not inserted into the Pollers table. The IP (changed for this thread) is pingable. When I use the GUI "Add Node" and the same IP it gets into the poller table and comes up right away.

What am I missing?

Here is the code:

#requires -version 2
<#
.SYNOPSIS
This script is used to add a new node using CRUD operations from a CSV file
It adds the node in Alert_Muted_Node = TRUE state
Other customproperties can be set

The script progresses in several steps:
1. Create the node based on caption and IP
1a. Optionally set a trailing caption qualifier
2. Assign ICMP pollers
3. Set custom properties
.DESCRIPTION
Run via SWIS.
.OUTPUTS
None.
.NOTES
Version: 1.0
Author: Michael Landman <Michael.Landman@FirstCitizens.com>
Creation Date: MAR. 01, 2017
Purpose/Change: Initial script development.
#>

#---------------------------------------------------------[Initializations]--------------------------------------------------------

# set error action to silently continue
$ErrorActionPreference = "SilentlyContinue"


#----------------------------------------------------------[Declarations]----------------------------------------------------------

# script version
$scriptVersion = "1.0"

#-------------------------------------------------------------[Init]---------------------------------------------------------------

$hostname = "REDACTED";
$Nodename = @();
$IPAddr = @();
$Dept = @();
$Environ = @();
$TimeO = @();
$customProps = @();
$CaptionQualifier = "";
$PathToFile = "D:\temp\TestClustersIP.csv";
$msg="";
$now = (get-date -Format s);
$outFile = ("d:\temp\$now.AddIcmpNodeSWISlog.txt").Replace(":",".");

#-----------------------------------------------------------[Functions]------------------------------------------------------------

#-----------------------------------------------------------[Execution]------------------------------------------------------------

if (-not (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {
    Add-PSSnapin "SwisSnapin"
}

# Connect to SWIS

$cred = Get-Credential
$swis = Connect-Swis -host $hostname -cred $cred

Import-Csv $PathToFile |ForEach-Object {
   $Nodename += $_."Hostname";
   $IPAddr += $_."IpAddr";
            $Dept += $_."Department";
            $Environ += $_."Env";
            $TimeO += $_."TimeOffset";
  }
#$ip = "10.0.0.1"

# add a node
for ($i=0; $i -lt $Nodename.length; $i++)
{
    If($Nodename[$i] -match "sd")
    {
        $CaptionQualifier = "_SqlCluster";
    }
    else
    {
        $CaptionQualifier = "_Cluster";
    }

$newNodeProps = @{
  IPAddress = $IPAddr[$i];
  EngineID = 1;
  ObjectSubType = "ICMP";
  Caption = $Nodename[$i] + $CaptionQualifier;
  # SNMP v2 specific
  #ObjectSubType = "SNMP";

  #SNMPVersion = 2;

  # === default values ===

  # EntityType = 'Orion.Nodes'
  # Caption = ''
  # DynamicIP = false
  # PollInterval = 120
  # RediscoveryInterval = 30
  # StatCollection = 10 
}

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

# register specific pollers for the node

$poller = @{
  NetObject="N:"+$nodeProps["NodeID"];
  NetObjectType="N";
  NetObjectID=$nodeProps["NodeID"];
      
}

# Status
$poller["PollerType"]="N.Status.ICMP.Native";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

# Response time
$poller["PollerType"]="N.ResponseTime.ICMP.Native";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

    # set Alert_muted_Node to True and other custom properties

    # prepare a custom property value. These MUST be present or no properties will be set
    $customProps = @{
        Alert_Muted_Node=1;
        Department = $Dept[$i];
        Environment = $Environ[$i];
        TimeOffset=$TimeO[$i];
    }

    # build the node URI
    $uri = "swis://$hostname/Orion/Orion.Nodes/NodeID=$($nodeProps["NodeID"])/CustomProperties";

    # set the custom property
    Set-SwisObject $swis -Uri $uri -Properties $customProps
}

  • Hey mlandman​, long time no talk!

    When I write something like this I usually just carve the NodeID off the end of the URI instead of trying to query for it immediately after it's created. Maybe check out $nodeProps to make sure you're getting a valid value?

    $newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps

    $nodeProps = Get-SwisObject $swis -Uri $newNodeUri

  • Hi Steve

    Still unknown this morning.

    BTW...Since I do not like leaving connections open, what is the PS call to close the connection?

    Looks like good data:

    PS C:\WINDOWS\system32> $nodeProps

    Key                                                                                                 Value

    ---                                                                                                 -----

    NodeID                                                                                                285

    ObjectSubType                                                                                        ICMP

    IPAddress                                                                                    10.xxx.xxx.xxx

    IPAddressType                                                                                        IPv4

    DynamicIP                                                                                           False

    Caption                                                                                   NPDAWBlahBlahBlah

    NodeDescription                                                                                         

    Description                                                                                       Unknown

    DNS                                                                                                     

    SysName                                                                                                 

    Vendor                                                                                            Unknown

    SysObjectID                                                                                             

    Location                                                                                                

    Contact                                                                                                 

    VendorIcon                                                                           Unknown.gif        

    Icon                                                                                 Unknown.gif        

    Status                                                                                                  0

    StatusLED                                                                                               

    StatusDescription                                                                 Node status is Unknown.

    CustomStatus                                                                                        False

    IOSImage                                                                                                

    IOSVersion                                                                                              

    GroupStatus                                                      Unknown.gif                            

    StatusIcon                                                       Unknown.gif                            

    LastBoot                                                                                                

    SystemUpTime                                                                                            

    ResponseTime                                                                                            

    PercentLoss                                                                                             

    AvgResponseTime                                                                                         

    MinResponseTime                                                                                         

    MaxResponseTime                                                                                         

    CPULoad                                                                                                -2

    MemoryUsed                                                                                             -2

    MemoryAvailable                                                                                         

    PercentMemoryUsed                                                                                       

    PercentMemoryAvailable                                                                                  

    LastSync                                                                                                

    LastSystemUpTimePollUtc                                                                                 

    MachineType                                                                                       Unknown

    IsServer                                                                                                

    Severity                                                                                                

    UiSeverity                                                                                              

    ChildStatus                                                                                             1

    Allow64BitCounters                                                                                   True

    AgentPort                                                                                             161

    TotalMemory                                                                                             

    CMTS                                                                                                    N

    CustomPollerLastStatisticsPoll                                                      12/30/1899 5:00:00 AM

    CustomPollerLastStatisticsPollSuccess                                               12/30/1899 5:00:00 AM

    SNMPVersion                                                                                             0

    PollInterval                                                                                          120

    EngineID                                                                                                1

    RediscoveryInterval                                                                                    30

    NextPoll                                                                              3/1/2017 9:15:14 PM

    NextRediscovery                                                                       3/1/2017 9:45:11 PM

    StatCollection                                                                                         10

    External                                                                                                

    Community                                                                                          public

    RWCommunity                                                                                             

    IP                                                                                           10.xxx.xxx.xxx

    IP_Address                                                                                   10.xxx.xxx.xxx

    IPAddressGUID                                                        7301d00a-0000-0000-0000-000000000000

    NodeName                                                                                  NPDAWBlahBlahBlah

    BlockUntil                                                                          12/30/1899 5:00:00 AM

    BufferNoMemThisHour                                                                                    -2

    BufferNoMemToday                                                                                       -2

    BufferSmMissThisHour                                                                                   -2

    BufferSmMissToday                                                                                      -2

    BufferMdMissThisHour                                                                                   -2

    BufferMdMissToday                                                                                      -2

    BufferBgMissThisHour                                                                                   -2

    BufferBgMissToday                                                                                      -2

    BufferLgMissThisHour                                                                                   -2

    BufferLgMissToday                                                                                      -2

    BufferHgMissThisHour                                                                                   -2

    BufferHgMissToday                                                                                      -2

    OrionIdPrefix                                                                                          N:

    OrionIdColumn                                                                                      NodeID

    SkippedPollingCycles                                                                                    

    MinutesSinceLastSync                                                                                    

    EntityType                                                                                    Orion.Nodes

    DetailsUrl                                             /Orion/NetPerfMon/NodeDetails.aspx?NetObject=N:285

    DisplayName                                                                               NPDAWBlahBlahBlah

    UnManaged                                                                                           False

    UnManageFrom                                                                       12/30/1899 12:00:00 AM

    UnManageUntil                                                                      12/30/1899 12:00:00 AM

    Image                                                                                                   

    AncestorDisplayNames                                                                    {NPDAWBlahBlahBlah}

    AncestorDetailsUrls                                  {/Orion/NetPerfMon/NodeDetails.aspx?NetObject=N:285}

    StatusIconHint                                                                                          

    InstanceType                                                                                  Orion.Nodes

    Uri                                   swis://NPDARBlahBlahBlah.DC.DC.net/Orion/Orion.Nodes/NodeID=285

  • There's no connection to close - that Connect-Swis name is a little misleading. It's just setting up a connection string for the REST calls that happen when you run the commandlets. Each one sets up a TCP connection, gets what it needs, and closes it like normal.

    The data you have look good. You said that you're sure that no pollers make it into the Orion.Pollers entity for this new node?

  • I threw the call to assign the poller into a Try{} /Catch{} loop and got this:

    try{

    # Status

    $poller["PollerType"]="N.Status.ICMP.Native";

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

    }

    catch{

    $errMsg = $_.Exception.Message

    Write-Host $errMsg

    }

    " Cannot convert value "PollerType" to type "System.Int32". Error: "Input string was not in a correct format." "

  • Nope,

    SELECT *   FROM [QaSolarWindsOrion].[dbo].[Pollers] where PollerType = 'N.Status.ICMP.Native'

    returns 35 rows and never changes.

    If I change it to the NodeID I get 0 returns:
    SELECT *  FROM [QaSolarWindsOrion].[dbo].[Pollers] where NetObjectID = 287

  • Correction...
    It changes if I add the IP from the GUI. Then the pollers get assigned.

  • Let me see the $poller variable just before the call to New-SwisObject?

  • BTW...
    What is the HTML for this format?

    pastedImage_1.png

  • PS C:\WINDOWS\system32> $Poller

    Name                           Value                                                                                                                                                         

    ----                           -----                                                                                                                                                         

    NetObjectType                  N                                                                                                                                                             

    NetObjectID                    292                                                                                                                                                           

    NetObject                      N:292                                                                                                                                                         

  • Ah well, there you go - it's missing the PollerType key. emoticons_happy.png