Microsoft Sql Server - Database Detail Pattern - Documentation for Bmc Discovery Content Reference

Microsoft Sql Server - Database Detail Pattern - Documentation for Bmc Discovery Content Reference

The goal of the Microsoft SQL Server Database Detail pattern is to obtain the list of databases being managed by the SQL Server.

The information is then stored within the Discovery model as Database nodes. The Database node representing each SQL Server database has additional attributes added, which permit easy mapping by the CMDB sync mechanism to the BMC_Database CIs in CMDB.

The pattern connects to the SQL Server using a JDBC connection. The IP address used to connect to the database server is determined by the pattern, with the default IP address the host is being scanned on. However, as of Discovery 8.2 and TKU January 2011, the pattern will access the database server on a specific IP address if determined and set as 'bind_address' (SQL Server 2005 and later) by the main Microsoft SQL Server pattern.

If the pattern is unable to connect to the SQL Server using a JDBC connection, it will attempt to do one of the following actions:

  • obtain the list of managed databases either by executing a WMI query
  • execute a command requiring local admin privileges
  • read the value of a Windows Registry entry pointing to a Windows folder where a directory listing is then performed.

Note

The patterns will not by default return the list of all tables within the discovered databases as this can have a marked impact on discovery of hosts with large database installations.

Configuration Options

There are several configuration options available for this Extended Discovery:

  • ignore_databases := [] (""); - allows to ignore databases.
  • ignore_databases_substring := [ 'ISALOG' ]; - allows to ignore selected databases.
  • default_to_secondary := false; - allows to use secondary method by default to obtain list of databases.
  • get_db_individ := false; - allows to obtain database size by querying individual databases.
  • retrieve_tables := false; -  allows to retrieve tables in each database.
  • file_db_discovery := false; - allows to use file-based method by default to obtain list of databases.
  • errorlog_discovery := false; allows discovery of managed databases from the error log file.

The pattern also references the following configuration options attached to the pattern:

  • db_queries - Determine if database queries are to be run via DB ABP
  • use_osql - Determine if database queries are to be run via osql command

Setting the port

The option to set the default port no longer exists in the Microsoft SQL Server Database Detail pattern.

The SQL Server Database Detail pattern behavior is now as follows:

  • If the core TKU Microsoft SQL Server Pattern discovers the listening port, this is the port that will be used.
  • Alternatively, the SQL Server Database Detail pattern will use the port that has been set in the database credentials by the user.
  • If no port was retrieved and port DB listening port was not set by the user, the SQL Server Database Detail pattern will not attempt to perform database queries.
    The reason for this change is to minimize the number of configuration steps required and prevent errors due to forgotten changes in pattern configuration.

The pattern executes the following SQL Queries

QueryReasonPermissionMore details
SELECT name AS database_name, compatibility_level, database_id, state_desc FROM sys.databasesGet database name, compatibility level, ID and state.Public role  Docs
SELECT database_id, physical_name FROM sys.master_filesMap Database ID to physical nameVIEW ANY DEFINITON permission for all rows in this databaseDocs
sp_helpdb  Get database sizesPublic role in the master databaseDocs
sp_helpdb <database name>Get database sizesPublic roleDocs
sp_databasesGet database name and sizesRequires VIEW ANY DEFINITION or higherDocs
SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG = %db_name%"Get information on tables in a databasegrant select on master.information_schema.tables to [a_db_user]SQL Server Central Forum
SELECT ar.group_id, name as group_name, Db_name(drs.database_id) AS database_name, hars.role_desc, ar.replica_server_name FROM sys.dm_hadr_database_replica_states DRS full JOIN sys.availability_replicas AR ON drs.replica_id = ar.replica_id full JOIN sys.availability_groups AGS ON ar.group_id = ags.group_id full JOIN sys.dm_hadr_availability_replica_states HARS ON ar.group_id = hars.group_id AND ar.replica_id = hars.replica_idGet details of Availability Groups
  • sys.dm_hadr_database_replica_states and sys.dm_hadr_availability_replica_states require VIEW SERVER STATE permission
  • sys.availability_replicas and sys.availability_groups require VIEW ANY DEFINITION permission
Docs
Docs
Docs
Docs
SELECT group_id, ip_configuration_string_from_cluster as listener_ip FROM sys.availability_group_listenersAdd Listener Ips to relevant ClusterService nodeNeed to be granted some permission for all securables you wish to discover deeplyDocs
select data_source, product, provider from SYS.servers where server_id > 0 and is_linked > 0Get OLE recordsPublic role, but see notes in the linkDocs
Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.