cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mkhuber1
Engaged Sweeper III

I have discovered a problem with switch and asset relationships. If an asset is discovered on a switchport and then the asset is moved to a different switchport or even to a different switch, the asset will still show on the switchport that the asset was originally discovered on.

1 ACCEPTED SOLUTION
Obi_1_Cinobi
Lansweeper Tech Support
Lansweeper Tech Support

Hello there!

If you have many switches in your network, this might indeed be a cumbersome task, so what you could also do is run a database script to clean up all your switches at once. We have provided a script below. This script will delete any MAC address in tblSNMPAssetMAC if the Lastseen date for the MAC is smaller than the Lastseen date of the switch. The script will delete this information for all switches, so it must only be run once. To run the script, follow the steps below:

  • Just to be safe, we do recommend performing a database backup prior to running any scripts. Do not skip this step. Backup instructions can be found here: https://www.lansweeper.com/knowledgebase/backing-up-your-installation/
  • Stop the following services:
    • The Lansweeper server service (on all your scanning servers).
    • The web server service on your Lansweeper web server. Your web server service is either World Wide Web Publishing Service (IIS) or IIS Express.
  • Afterward, open the DatabaseMaintenance.exe tool, which can be found under Program Files (x86)\Lansweeper\Tools on your Lansweeper server or, alternatively, use SQL Server Management Studio if your Lansweeper database is hosted on SQL Server.
  • Copy/paste the script below in the second tab labeled Script Execution, and click Execute.
  • Restart your services.
DELETE tblSNMPAssetMac 
FROM tblSNMPAssetMac 
INNER JOIN tblAssets On tblSNMPAssetMac.AssetID = tblAssets.AssetID 
WHERE tblAssets.Lastseen > tblSNMPAssetMac.LastSeen

 

View solution in original post

3 REPLIES 3
mkhuber1
Engaged Sweeper III

That fixed the immediate problem.

Is there a way to automate this function?

Obi_1_Cinobi
Lansweeper Tech Support
Lansweeper Tech Support

Hello there!

If you have many switches in your network, this might indeed be a cumbersome task, so what you could also do is run a database script to clean up all your switches at once. We have provided a script below. This script will delete any MAC address in tblSNMPAssetMAC if the Lastseen date for the MAC is smaller than the Lastseen date of the switch. The script will delete this information for all switches, so it must only be run once. To run the script, follow the steps below:

  • Just to be safe, we do recommend performing a database backup prior to running any scripts. Do not skip this step. Backup instructions can be found here: https://www.lansweeper.com/knowledgebase/backing-up-your-installation/
  • Stop the following services:
    • The Lansweeper server service (on all your scanning servers).
    • The web server service on your Lansweeper web server. Your web server service is either World Wide Web Publishing Service (IIS) or IIS Express.
  • Afterward, open the DatabaseMaintenance.exe tool, which can be found under Program Files (x86)\Lansweeper\Tools on your Lansweeper server or, alternatively, use SQL Server Management Studio if your Lansweeper database is hosted on SQL Server.
  • Copy/paste the script below in the second tab labeled Script Execution, and click Execute.
  • Restart your services.
DELETE tblSNMPAssetMac 
FROM tblSNMPAssetMac 
INNER JOIN tblAssets On tblSNMPAssetMac.AssetID = tblAssets.AssetID 
WHERE tblAssets.Lastseen > tblSNMPAssetMac.LastSeen

 

Obi_1_Cinobi
Lansweeper Tech Support
Lansweeper Tech Support

Hello there!

You can clear old switch connections by clicking the Remove Disconnected Devices button in the left-hand pane of switch asset pages (see screenshot below). This button will clear all switch port connections that are older than the last successful scan time of the switch in question. 

2022-11-03 15_36_58-Window.png