We have 300+ subnetworks and very difficult to stay them actually.
So we decide to create some rules for their inventory:
1. You have to resolve all undefined IP location via correction of a description on Assets Groups page
2. IP location must contains IP address of network default gateway and be more or equal of IP Scanning Range. It helps to track cross-subnet assets moving https://community.lansweeper.com/t5/reports-analytics/asset-s-networks-tracker/m-p/81505
3. Names of scopes better to be equal.
So we create report for supporting this rules:
Select Top 1000000 allscopes.*,
Case
When allscopes.iplocation <> allscopes.description And
allscopes.in_IPLocation = allscopes.in_ScanRange Then
'Scopes names are different but scopes have same number of assets'
When allscopes.iplocation = allscopes.description And
allscopes.in_IPLocation <> allscopes.in_ScanRange Then
'Scopes names are same but scopes have different number of assets'
When allscopes.iplocation <> allscopes.description And
allscopes.in_IPLocation <> allscopes.in_ScanRange Then
'Scopes names are different and scopes have different number of assets'
When allscopes.iplocation = allscopes.description And
allscopes.in_IPLocation = allscopes.in_ScanRange Then 'OK'
Else 'Please fill names of scopes'
End As Scopes_status,
Case
When allscopes.iplocation <> allscopes.description And
allscopes.in_IPLocation = allscopes.in_ScanRange Then 'Orange'
When allscopes.iplocation = allscopes.description And
allscopes.in_IPLocation <> allscopes.in_ScanRange Then 'LightSalmon'
When allscopes.iplocation <> allscopes.description And
allscopes.in_IPLocation <> allscopes.in_ScanRange Then 'Tomato'
When allscopes.iplocation = allscopes.description And
allscopes.in_IPLocation = allscopes.in_ScanRange Then 'LightGreen'
Else 'skyblue'
End As backgroundcolor
From (Select Top 1000000 ips.IPLocation,
ips.Realstart,
ips.Realend,
Sum(Case
When a.locationid = ips.locationid Then 1
Else 0
End) in_IPLocation,
ips.Description,
ips.Ipstart,
ips.Ipend,
ips.Enabled,
Sum(Case
When (a.ipnumeric Between Convert(numeric,Right('000' +
IsNull(ParseName(ips.Ipstart, 4), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipstart, 3), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipstart, 2), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipstart, 1), ''),
3)) And Convert(numeric,Right('000' + IsNull(ParseName(ips.Ipend, 4),
''), 3) + Right('000' + IsNull(ParseName(ips.Ipend, 3), ''),
3) + Right('000' + IsNull(ParseName(ips.Ipend, 2), ''), 3) +
Right('000' + IsNull(ParseName(ips.Ipend, 1), ''), 3))) Then 1
Else 0
End) in_ScanRange
From (Select s.Ipstart,
s.Ipend,
s.Description,
s.Enabled,
l.IPLocation,
l.Realstart,
l.Realend,
l.locationid
From tsysIPLocations l
Inner Join tsysIPScanRanges s On
l.startip <= Convert(numeric,Right('000' +
IsNull(ParseName(s.Ipend, 4), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 3), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 2), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 1), ''), 3)) And
Convert(numeric,Right('000' + IsNull(ParseName(s.Ipstart, 4), ''),
3) + Right('000' + IsNull(ParseName(s.Ipstart, 3), ''), 3) +
Right('000' + IsNull(ParseName(s.Ipstart, 2), ''), 3) +
Right('000' + IsNull(ParseName(s.Ipstart, 1), ''), 3)) <= l.endip
Union
Select s.Ipstart,
s.Ipend,
s.Description,
s.Enabled,
Null IPLocation,
Null Realstart,
Null Realend,
Null locationid
From tsysIPScanRanges s
Except
Select s.Ipstart,
s.Ipend,
s.Description,
s.Enabled,
Null IPLocation,
Null Realstart,
Null Realend,
Null locationid
From tsysIPLocations l
Inner Join tsysIPScanRanges s On
l.startip <= Convert(numeric,Right('000' +
IsNull(ParseName(s.Ipend, 4), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 3), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 2), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 1), ''), 3)) And
Convert(numeric,Right('000' + IsNull(ParseName(s.Ipstart, 4), ''),
3) + Right('000' + IsNull(ParseName(s.Ipstart, 3), ''), 3) +
Right('000' + IsNull(ParseName(s.Ipstart, 2), ''), 3) +
Right('000' + IsNull(ParseName(s.Ipstart, 1), ''), 3)) <= l.endip
Union
Select Null Ipstart,
Null Ipend,
Null Description,
Null Enabled,
l.IPLocation,
l.Realstart,
l.Realend,
l.locationid
From tsysIPLocations l
Except
Select Null Ipstart,
Null Ipend,
Null Description,
Null Enabled,
l.IPLocation,
l.Realstart,
l.Realend,
l.locationid
From tsysIPLocations l
Inner Join tsysIPScanRanges s On
l.startip <= Convert(numeric,Right('000' +
IsNull(ParseName(s.Ipend, 4), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 3), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 2), ''), 3) + Right('000' +
IsNull(ParseName(s.Ipend, 1), ''), 3)) And
Convert(numeric,Right('000' + IsNull(ParseName(s.Ipstart, 4), ''),
3) + Right('000' + IsNull(ParseName(s.Ipstart, 3), ''), 3) +
Right('000' + IsNull(ParseName(s.Ipstart, 2), ''), 3) +
Right('000' + IsNull(ParseName(s.Ipstart, 1), ''), 3)) <=
l.endip) ips
Left Join tblassets a On a.ipnumeric Is Not Null And (ips.locationid =
a.locationid Or (a.ipnumeric Between Convert(numeric,Right('000' +
IsNull(ParseName(ips.Ipend, 4), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipend, 3), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipend, 2), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipend, 1), ''),
3)) And Convert(numeric,Right('000' +
IsNull(ParseName(ips.Ipstart, 4), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipstart, 3), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipstart, 2), ''), 3) + Right('000' +
IsNull(ParseName(ips.Ipstart, 1), ''), 3))))
Group By ips.IPLocation,
ips.Realstart,
ips.Realend,
ips.Description,
ips.Ipstart,
ips.Ipend,
ips.Enabled) As allscopes