Lan-Secure Logo

Lan-Secure Network Blog

Network Management and Security

Find technical networking articles
Use our network management and security blog to find technical articles and knowledge base information about networking related issues.

Lan-Secure Networking Blog

Network topology using Visio 2007

Using visual diagrams of networks asset for management and maintenance can improve the stability and performance of enterprise networks as well as creating network design information base. But, keeping networks topology updated can be a frustrated task that involved in daily maintenance and human resources. Using Visio 2007 that integrates visual display with network topology database can make this task quite easy.

Integrating network topology database
There are some nice tools that can be found on the net that provides network and equipment topology. Some of them provide database exporting capabilities like Lan-Secure Switch Center and Lan-Secure Security Center. Using the Visio 2007 link data to shapes capability provides database information for diagram visual shapes including asset equipment and asset connectors. The Visio 2007 database link feature enables importing data information from several sources including Microsoft Access Database and SQL database. Those capabilities integrated with topology database create a complete network topology diagram that can be maintained and updated automatically using a simple script.

Visio database integration script
The following Visio 2007 database integration script visualize network components asset from selected database information and creates physical connections between them. For simplicity, the script is using Microsoft Access database or SQL database and two record sets one for the components shapes and one for the physical connectors which needs to be filled in using the appropriate query string of the selected database structure.

VBScript (should be copied and saved as .vbs file after modifying brackets information):
'Select database provider connect string
'Const dbProvider = "Driver={Microsoft Access Driver (*.mdb)};DBQ=[Database File (*.mdb)];"
'Const dbProvider = "{SQL Server};SERVER=[Server Name];DATABASE=[Database Name];"

'Add new visio page
Set visioApplication = WScript.CreateObject("Visio.Application")
Set visioPeriphDoc = visioApplication.Documents.Open("PERIPH_M.VSS")
Set visioDocument = visioApplication.Documents.Add("")
Set visioPage = visioDocument.Pages(1)

'Load database to visio
Set Shapes = visioDocument.DataRecordsets.Add(dbProvider, "[Database shapes query string]", 0, "Shapes")
Set Connectors = visioDocument.DataRecordsets.Add(dbProvider, "[Database connectors query string]", 0, "Connectors")

'Set shapes
shapesIndex = 0
ReDim shapesArray(shapesIndex)
Set server = visioPeriphDoc.Masters("Server")
Set shapesRecordset = visioDocument.DataRecordsets(1)
shapesIDs = shapesRecordset.GetDataRowIDs("")
For shapesRow = LBound(shapesIDs) + 1 To UBound(shapesIDs) + 1
Set shapesArray(shapesIndex) = visioPage.DropLinked(server, 0, 0, shapesRecordset.ID, shapesRow, False)
shapeData = shapesRecordset.GetRowData(shapesRow)
shapesArray(shapesIndex).Text = shapeData(0)
shapesIndex = shapesIndex + 1
ReDim Preserve shapesArray(shapesIndex)

'Set connectors
Set connectorsRecordset = visioDocument.DataRecordsets(2)
connectorsIDs = connectorsRecordset.GetDataRowIDs("")
For connectorsRow = LBound(connectorsIDs) + 1 To UBound(connectorsIDs) + 1
connectorData = connectorsRecordset.GetRowData(connectorsRow)
Set connector = visioPage.Drop(visioApplication.ConnectorToolDataObject, 1, 1)
connector.Text = connectorData(0)
childIndex = 0 'Search appropriate index from shapes array
parentIndex = 0 'Search appropriate index from shapes array
Set parentConnector = shapesArray(parentIndex).Cells("Connections.X1")
Set childConnector = shapesArray(childIndex).Cells("Connections.X1")
connector.Cells("BeginX").GlueTo parentConnector
connector.Cells("EndX").GlueTo childConnector

'Set layout