Friday, June 7, 2019

OrionToolkit: A PowerShell module for interacting with the SolarWinds NPM API

Background

Over the years, I've cobbled together PS scripts for doing this and that with Orion's API.

Recently, I needed some advanced syslog filtering. Rather than write another hack-job, I decided to do it right (or at least, better).

Then I thought, why not do the same for my other tools?

A few days of refactoring and OrionToolkit was born.

While in early development, I'll leave it on GitHub. I plan to post to the PS Gallery once it reaches a certain level of completeness.

Contributions welcome.

Implemented cmdlets

  • Add-OrionNodes - Add one or more nodes, and their interfaces, to NPM
  • Get-OrionNodes - Query and filter nodes based on many properties, including wildcards
  • Get-OrionSyslog - Query syslog messages with advanced inclusion/exclusion filtering

Example usage

Add a single node, including all interfaces with descriptions containing the string "LINK", and add custom properties for DeviceClass and DeviceType:

PS C:\Users\austindcc> Add-OrionNodes -NodeIP "10.100.20.40" -SNMPv3CredentialName "access" -CustomProperties @{'DeviceClass' = 'Network'; 'DeviceType' = 'Network_SwitchAccess'} -IncludeInterfaces "*LINK*" NodeName NodeID IPAddress Interfaces -------- ------ --------- ---------- Switch-Example 2200 10.100.20.40 {PscxDynamicType69} 

Get all Cisco nodes with average polling response times greater than 100ms, or polling packet loss greater than 1%:

PS C:\Users\austindcc> Get-OrionNodes -Vendor Cisco | ? { $_.AvgResponseTime -gt 100 -or $_.PercentLoss -gt 1} | ft nodename, avgresponsetime, percentloss NodeName AvgResponseTime PercentLoss -------- --------------- ----------- Switch0001 13 10 Switch0002 13 20 

Get syslog messages from all Cisco devices for the past hour:

PS C:\Users\austindcc> Get-OrionSyslog -IncludeVendor Cisco | ft datetime, nodename, message DateTime NodeName Message -------- -------- ------- 6/7/2019 10:21:10 AM Router-01 Te1/0/5: Rx power low warning; Operating value: -22.5 dBm, Threshold value: -19.0 dBm. 6/7/2019 10:16:31 AM Router-02 Gi0/1: Rx power high warning; Operating value: -2.1 dBm, Threshold value: -3.0 dBm. 6/7/2019 10:07:08 AM Router-03 Duplicate address 10.51.182.1 on Vlan50, sourced by ec9b.8b07.6793 6/7/2019 10:06:42 AM Switch-02 Faulty fan detected 6/7/2019 10:06:42 AM Switch-02 Abnormal temperature detected 6/7/2019 10:06:41 AM Switch-02 Fan Failure 6/7/2019 10:04:06 AM Router-03 Duplicate address 10.51.184.1 on Vlan60, sourced by 943f.c25f.4627 6/7/2019 10:03:36 AM Router-03 Duplicate address 10.51.184.1 on Vlan60, sourced by ec9b.8b07.679d 6/7/2019 9:49:11 AM Switch-01 FRU Power Supply is not responding 6/7/2019 9:43:30 AM CoreAgg-01 Snooping Querier received a non-matching query interval (125000 msec), 

GitHub



No comments:

Post a Comment