I would like to add/remove custom pollers with the SDK. The only thread I found was from 2012, so I wanted to ask if it's possible now.
Thanks!
This support was added in 11.5, so it will be waiting for you when you get there.
Hi,
You can assign custom pollers to nodes or interfaces. Sample provided below.
New-SwisObject $swis –EntityType 'Orion.NPM.CustomPollerAssignmentOnNode' -Properties @{Description='Test';CustomPollerID='a519ce64-33c3-490c-b0f8-04982911cd3e';NodeID='1';}
use Orion.NPM.CustomPollerAssignmentOnInterface for adding custom pollers to interfaces.
Thanks for pointing that out. I'll give it a go.
What version of Powershell are you using to execute this? I've tried with both version 2 & 3 using both the ISE and Non-ISE versions with no luck.
The script is able to Get-SwisData, but trying to trying New-SwisObject throws this:
New-SwisObject : Operation not supported on Orion.NPM.CustomPollerAssignmentOnNode
This is the meat and potatoes of how I'm trying to do this:
$NodeID = Get-SwisData $swis "Select NodeID FROM Orion.Nodes WHERE IP_Address = @NodeIP" @{NodeIP = $NodeIP}
$CustomPollerID = Get-SwisData $swis "SELECT CustomPollerID FROM Orion.NPM.CustomPollers WHERE UniqueName = @UnDPName" @{UnDPName = $CustomPollerName}
$NodeBag = @{
Description='Test';
CustomPollerID=[System.Guid]$CustomPollerID;
NodeID=[Int]$NodeID;
}
#New-SwisObject $swis –EntityType 'Orion.NPM.CustomPollerAssignmentOnNode' -Properties @{Description='Test';CustomPollerID='c58f3b64-b9bc-448f-8a82-4975758736f6';NodeID='4466';}
New-SwisObject $swis –EntityType 'Orion.NPM.CustomPollerAssignmentOnNode' -Properties $NodeBag
The version of powershell wouldn't matter. What version of NPM are you using?
10.7 at the moment. (I've been delaying the 11.5 upgrade until the next NCM is released.)
Circling back to this finally after upgrading a couple of months ago. There seems to be something I'm still missing.
function AssignUnDPToNode ($NodeIP, $UnDPName){ [Int]$NodeID = Get-SwisData $swis "Select NodeID FROM Orion.Nodes WHERE IP_Address = @IP" @{IP = $NodeIP} [System.Guid]$CustomPollerID = Get-SwisData $swis "SELECT CustomPollerID FROM Orion.NPM.CustomPollers WHERE UniqueName = @UName" @{UName = $UnDPName} $UnDPProperties = @{ Description = ''; CustomPollerID = $CustomPollerID; NodeID = $NodeID; } New-SwisObject $swis –EntityType "Orion.NPM.CustomPollerAssignmentOnNode" -Properties $UnDPProperties}
function AssignUnDPToNode ($NodeIP, $UnDPName){
[Int]$NodeID = Get-SwisData $swis "Select NodeID FROM Orion.Nodes WHERE IP_Address = @IP" @{IP = $NodeIP}
[System.Guid]$CustomPollerID = Get-SwisData $swis "SELECT CustomPollerID FROM Orion.NPM.CustomPollers WHERE UniqueName = @UName" @{UName = $UnDPName}
$UnDPProperties = @{
Description = '';
CustomPollerID = $CustomPollerID;
NodeID = $NodeID;
New-SwisObject $swis –EntityType "Orion.NPM.CustomPollerAssignmentOnNode" -Properties $UnDPProperties
The error I get is:
At C:\orionScripts\AssignUnDP\AssignUnDP.ps1:41 char:48+ Write-Output "$UnDPName assigned to $NodeIP"+ ~The string is missing the terminator: ".At C:\orionScripts\AssignUnDP\AssignUnDP.ps1:28 char:47+ function AssignUnDPToNode ($NodeIP, $UnDPName){+ ~Missing closing '}' in statement block. + CategoryInfo : ParserError: (:) [], ParseExcepti + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
At C:\orionScripts\AssignUnDP\AssignUnDP.ps1:41 char:48
+ Write-Output "$UnDPName assigned to $NodeIP"
+ ~
The string is missing the terminator: ".
At C:\orionScripts\AssignUnDP\AssignUnDP.ps1:28 char:47
+ function AssignUnDPToNode ($NodeIP, $UnDPName){
Missing closing '}' in statement block.
+ CategoryInfo : ParserError: (:) [], ParseExcepti
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
If I comment out the New-SwisObject line, I can Write-Host my NodeID, IP, UnDP Name, and UnDP ID, so I know those are populating. It seems something is breaking or missing in the grab bag perhaps? Any thoughts?
Turns out, this was something weird happening in powershell. I was running this from the Posh command line, but when I ran the same script through the ISE, it worked fine... Go figure.
The problem is that on your New-SwisObject line, the "EntityType" flag is preceded by a "–" character (en dash, unicode 8211) instead of a normal "-" character (hyphen, ascii/unicode 45). ISE apparently treats them the same but the CLI does not! And in most monospace fonts they are visually indistinguishable.