Managing Node Pollers Via API

This quick guide provides an example of using PowerShell to add a node with multiple pollers, use the Remove-SwisObject, Invoke-SwisVerb, Set-SwisObject cmdlets to perform actions using the URI for those items.

It shows the basic concepts for these actions and is not an extensive guide to SWQL and assumes a basic working knowledge of the Orion entity model.

Consider the following results of 'List Resources' for a node.

Looking at the Orion.Pollers entity we can see the following are assigned to this node.

  17547 N.Status.ICMP.Native N:22775 N 22775 True
  17548 N.Status.SNMP.Native N:22775 N 22775 True
  17549 N.ResponseTime.ICMP.Native N:22775 N 22775 True
  17550 N.ResponseTime.SNMP.Native N:22775 N 22775 True
  17551 N.Details.SNMP.Generic N:22775 N 22775 True
  17552 N.Uptime.SNMP.Generic N:22775 N 22775 True
  17553 N.Cpu.SNMP.CiscoGen3 N:22775 N 22775 True
  17554 N.Memory.SNMP.CiscoGen3 N:22775 N 22775 True
  17555 N.Routing.SNMP.Ipv4CidrRoutingTable N:22775 N 22775 True
  17556 N.RoutingNeighbor.SNMP.BGP N:22775 N 22775 True
  17557 N.RoutingNeighbor.SNMP.OSPF N:22775 N 22775 True
  17558 N.VRFRouting.SNMP.CiscoVrfMib N:22775 N 22775 True
  17559 N.HardwareHealthMonitoring.SNMP.NPM.Cisco N:22775 N 22775 True
  17560 N.Topology_Vlans.SNMP.VtpVlan N:22775 N 22775 True
  17561 N.Topology_CDP.SNMP.cdpCacheTable N:22775 N 22775 True
  17562 N.Topology_Layer3.SNMP.ipNetToMedia N:22775 N 22775 True
  17563 N.Topology_Layer3_IpRouting.SNMP.ipCidrRouter N:22775 N 22775 True

To Add a node with these pollers using the API, you could use something like this

# This sample script demonstrates how to add a new node using CRUD operations.
#
# Please update the hostname and credential setup to match your configuration, and
# information about the node you would like to add for monitoring.

# Connect to SWIS
Import-Module SwisPowerShell
Add-PSSnapin SwisSnapin
$hostname = ""
$swis = Connect-Swis -Hostname $hostname

$ip = ""

# add a node
$newNodeProps = @{
    IPAddress = $ip;
    EngineID = 1;
  
    # SNMP v2 specific
    ObjectSubType = "SNMP";

    SNMPVersion = 2;

    DNS = "";
    SysName = "";
    
    # === 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

$poller["PollerType"]="N.Status.SNMP.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

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

# Details
$poller["PollerType"]="N.Details.SNMP.Generic";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

# Uptime
$poller["PollerType"]="N.Uptime.SNMP.Generic";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

# CPU
$poller["PollerType"]="N.Cpu.SNMP.CiscoGen3";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

# Memory
$poller["PollerType"]="N.Memory.SNMP.CiscoGen3";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

# Routing
$poller["PollerType"]="N.Routing.SNMP.Ipv4CidrRoutingTable";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

$poller["PollerType"]="N.RoutingNeighbor.SNMP.BGP";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

$poller["PollerType"]="N.RoutingNeighbor.SNMP.OSPF";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

$poller["PollerType"]="N.VRFRouting.SNMP.CiscoVrfMib";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

# HWH
$poller["PollerType"]="N.HardwareHealthMonitoring.SNMP.NPM.Cisco";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

# Topology
$poller["PollerType"]="N.Topology_Vlans.SNMP.VtpVlan";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

$poller["PollerType"]="N.Topology_CDP.SNMP.cdpCacheTable";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

$poller["PollerType"]="N.Topology_Layer3.SNMP.ipNetToMedia";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

$poller["PollerType"]="N.Topology_Layer3_IpRouting.SNMP.ipCidrRouter";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

What if I need to remove a poller?

If you look at the Orion.Poller's entity in SWQL studio you will notice it support CRUD operations

To delete any of the assigned pollers we can pass the URI for the poller to the Remove-SwisObject

# This sample script demonstrates how to remove a poller from a node. replace xxxx with the NodeID of the target node
#
# Please update the hostname and credential setup to match your configuration
Connect to SWIS
Import-Module SwisPowerShell
Add-PSSnapin SwisSnapin
$hostname = ""
$swis = Connect-Swis -Hostname $hostname

$query = Get-SwisData $swis "SELECT URI FROM Orion.Pollers where NetObject = 'N:xxxx' and POllerType ='N.RoutingNeighbor.SNMP.BGP'"
Remove-SwisObject $swis $query

To initiate the 'poll now' action for a node we can use:

# This sample script demonstrates how to initiate a poll now. Replace xxxx with the NodeID of the target node
#
# Please update the hostname and credential setup to match your configuration
Connect to SWIS
Import-Module SwisPowerShell
Add-PSSnapin SwisSnapin
$hostname = ""
$swis = Connect-Swis -Hostname $hostname



Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.Nodes" -Verb "PollNow" @("N:xxxx")

To update an object based on its URI, for example to disable a poller assigned to a node you can use.

# This sample script demonstrates how to disable a poller assigned to a node. Replace xxxx with the NodeID of the target Node
#
# Please update the hostname and credential setup to match your configuration
Connect to SWIS
Import-Module SwisPowerShell
Add-PSSnapin SwisSnapin
$hostname = "10.199.20.200"
$swis = Connect-Swis -Hostname $hostname


#1. Define values for nodesettings to be updated.
$PollerSettings = @{  
    Enabled = 'False';
   
}


#get the URI for the setting.
$Query = 'SELECT uri from Orion.Pollers where NetObject =''N:xxxx'' and POllerType=''N.Cpu.SNMP.CiscoGen3''';
$Uri = get-swisData $swis $Query

#3. Update the entity
Set-SwisObject $swis $Uri -Properties $PollerSettings