Hi All,
I wanted to know how many physical interfaces existed on a device. I didn't want to use discovery or list resource.
I thought of custom polling for OperationalStatus and NPM let us create a custom poller for that OID, but it does not capture the value.

So, lets have powershell poll it and push the values to a custom property.
I'm using three custom properties: 1) phyInt - number of physical interfaces (ethernet); 2) number of Up from (1); 3) number of down from (1).
# Get a list of switches
$ErrorActionPreference = 'Stop'
Add-PSSnapin SwisSnapin
$swis = Connect-Swis -Hostname x.x.x.x -Username xxxx" -Password xxxx
$query = "SELECT top 1 n.ip_address, n.CustomProperties.Uri as [uri] from Orion.Nodes n WHERE vendor like 'Cisco'"
$nodes = Get-SwisData -SwisConnection $swis -Query $query
# foreach ($node in $nodes) {Write-Host "$($node)" }
# Go through the nodes
foreach ($node in $nodes) {
# Open SNMP
$SNMP = New-Object -ComObject olePrn.OleSNMP
$SNMP.open($node.ip_address ,'Password',2,1000)
# Get SNMP ifType
try { $SNMPDATA1=$SNMP.GetTree(".1.3.6.1.2.1.2.2.1.3") }
catch { $SNMP.Close() }
# Get SNMP ifOperatioanlStatus
try { $SNMPDATA2=$SNMP.GetTree(".1.3.6.1.2.1.2.2.1.8") }
catch { $SNMP.Close() }
#Close SNMP
$SNMP.close()
$phyInterfaces=0
$phyOperStatusUp=0
$phyOperStatusDown=0
# Go thru each interface and do Counts
for($i=0;$i-lt $SNMPDATA1.length/2;$i++)
{
if ($SNMPDATA1[1,$i] -eq 6) { $phyInterfaces+=1}
if (($SNMPDATA1[1,$i] -eq 6) -and ($SNMPDATA2[1,$i] -eq 1)) { $phyOperStatusUp+=1}
if (($SNMPDATA1[1,$i] -eq 6) -and ($SNMPDATA2[1,$i] -eq 2)) { $phyOperStatusDown+=1}
}
Write-Host "$($node.ip_address) phyInterfcaes:$($phyInterfaces) Up:$($phyOperStatusUp) Down:$($phyOperStatusDown) uri:$($node.uri)"
Set-SwisObject $swis -uri $node.uri -Properties @{phyInt=$phyInterfaces; phyUp=$phyOperStatusUp; phyDown=$phyOperStatusDown}
}

While we're at it - lets create a widget to show the values

SELECT
TOUPPER(SUBSTRING(n.Caption,1,case when charindex('.',n.caption,1) <=4 then length(n.Caption) else (charindex('.',n.Caption,1)-1) end)) AS [Node Name]
,DetailsUrl AS [_LinkFor_Node Name]
,'/Orion/images/StatusIcons/Small-' + StatusIcon AS [_IconFor_Node Name]
,(select count(*) as d from orion.NPM.Interfaces i where i.NodeID=n.nodeid) as [Monitored ports]
,(select count(*) as d from orion.NPM.Interfaces i where i.NodeID=n.nodeid and i.InterfaceType=6) as [Monitored physical ports]
,n.CustomProperties.phyInt
,n.CustomProperties.phyUp
,n.CustomProperties.phyDown
from Orion.Nodes n
WHERE vendor like 'Cisco'
This tells me that for the first device - there are 9 ports monitored and 6 of them are physical. ALso, there are 24 physical ports on the device of which 6 are up and 18 down.
Thank you,
Amit
Loop1 Systems
https://loop1.com/