Resource type2 (index = 136.117.86.59.62.96.0.2, channelno=2,
apName=AP30f7.0de6, apIpAddress=10.211.10.1,
resolvedMacAddress=88-75-56-3B-3E-40)
Resource type3 (index = 136.117.86.59.62.96.0.3, channelno=3,
apName=AP30f7.0de6, apIpAddress=10.211.10.1,
resolvedMacAddress=88-75-56-3B-3E-40)
Resource type4 (index = 136.117.86.59.62.160.0.1, channelno=1,
apName=AP30f7.4f9d, apIpAddress=10.211.10.2,
resolvedMacAddress=88-75-56-3B-20-A0)
Resource type5 (index = 136.117.86.59.62.160.0.2, channelno=2,
apName=AP30f7.4f9d, apIpAddress=10.211.10.2,
resolvedMacAddress=88-75-56-3B-20-A0)
Scenario2: Creating property from the multiple fields of an index
Discovery can be extended further to access and retrieve the value as part of properties. You can access and retrieve the three fields from 136.117.86.59.62.96.0.3
as three different properties.
136.117.86.59.62.96
0
3
Combine the SQL AS to assign an object name to a property and the expression that can be further enhanced to include the regex function.
SELECT
bsnAPIfChannelInterferenceInfoTable.index,
bsnapifinterferencechannelno AS channelno,
bsnAPTable.index,
bsnapname AS apName,
bsnApIpAddress AS apIpAddress,
bsnapdot3macaddress AS resolvedMacAddress,
regexp_replace(bsnAPIfChannelInterferenceInfoTable.index, '[.][0-9]+[.][0-9]+$', '') AS tempMacAddress,
regexp_replace(bsnAPIfChannelInterferenceInfoTable.index, '^.*[.]([0-9]+)[.][0-9]+$', '$1') AS apSlotId,
regexp_replace(bsnAPIfChannelInterferenceInfoTable.index, '^.*[.][0-9]+[.]([0-9]+)$', '$1') AS channel
FROM AirespaceWirelessMib.bsnAPTable INNER JOIN AirespaceWirelessMib.bsnAPIfChannelInterferenceInfoTable
ON bsnAPTable.index = regexp_replace(bsnAPIfChannelInterferenceInfoTable.index, '[.][0-9]+[.][0-9]+$', '')
With the specified select statement, five resource types can be obtained.
Resource type1 (index = 136.117.86.59.62.96.0.1, channelno=1,
apName=AP30f7.0de6, apIpAddress=10.211.10.1,
resolvedMacAddress=88-75-56-3B-3E-40,
tempMacAddressIndex=136.117.86.59.62.96, apSlotId=0, channel=1)
Resource type2 (index = 136.117.86.59.62.96.0.2, channelno=2,
apName=AP30f7.0de6, apIpAddress=10.211.10.1,
resolvedMacAddress=88-75-56-3B-3E-40,
tempMacAddressIndex=136.117.86.59.62.96, apSlotId=0, channel=2)
Resource type3 (index = 136.117.86.59.62.96.0.3, channelno=3,
apName=AP30f7.0de6, apIpAddress=10.211.10.1,
resolvedMacAddress=88-75-56-3B-3E-40,
tempMacAddressIndex=136.117.86.59.62.96, apSlotId=0, channel=3)
Resource type4 (index = 136.117.86.59.62.160.0.1, channelno=1,
apName=AP30f7.4f9d, apIpAddress=10.211.10.2,
resolvedMacAddress=88-75-56-3B-20-A0,
tempMacAddressIndex=136.117.86.59.62.160, apSlotId=0, channel=1)
Resource type5 (index = 136.117.86.59.62.160.0.2, channelno=2,
apName=AP30f7.4f9d, apIpAddress=10.211.10.2,
resolvedMacAddress=88-75-56-3B-20-A0,
tempMacAddressIndex=136.117.86.59.62.160, apSlotId=0, channel=2)
Add a condition to filter the necessary resource types and ensure that all the mandatory properties are defined.
SELECT
bsnAPIfChannelInterferenceInfoTable.index,
bsnapifinterferencechannelno AS channelno,
bsnAPTable.index,
bsnapname AS apName,
bsnApIpAddress AS apIpAddress,
bsnapdot3macaddress AS resolvedMacAddress,
regexp_replace(bsnAPIfChannelInterferenceInfoTable.index, '[.][0-9]+[.][0-9]+$', '') AS tempMacAddress,
regexp_replace(bsnAPIfChannelInterferenceInfoTable.index, '^.*[.]([0-9]+)[.][0-9]+$', '$1') AS apSlotId,
regexp_replace(bsnAPIfChannelInterferenceInfoTable.index, '^.*[.][0-9]+[.]([0-9]+)$', '$1') AS channel
FROM AirespaceWirelessMib.bsnAPTable INNER JOIN AirespaceWirelessMib.bsnAPIfChannelInterferenceInfoTable
ON bsnAPTable.index = regexp_replace(bsnAPIfChannelInterferenceInfoTable.index, '[.][0-9]+[.][0-9]+$', '')
WHERE bsnapifinterferencepower IS NOT NULL
SET type = 'channel'
SET id = context.host + '_channel:<' + resource.index + '>'
SET index = resource.index
With the specified select statement, five resource types can be obtained.
Resource type1 (id=10.1.1.12_channel:<136.117.86.59.62.96.0.1>,
type=channel, index = 136.117.86.59.62.96.0.1, channelno=1,
apName=AP30f7.0de6, apIpAddress=10.211.10.1,
resolvedMacAddress=88-75-56-3B-3E-40,
tempMacAddressIndex=136.117.86.59.62.96, apSlotId=0, channel=1)