The goal of the Microsoft SQL Server Database Detail pattern is to obtain the list of databases being managed by the SQL Server. 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. 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 Atrium 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 being the IP address the host is being scanned on, although as of Atrium Discovery 8.2 and TKU January 2011 the pattern will access the database server on a specific IP address if this has been 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 obtain the list of managed databases either by executing a WMI query, executing a command requiring local admin privileges, or, finally, reading the value of a Windows Registry entry pointing to a Windows folder where a directory listing is then performed. There are several configuration options available for this Extended Discovery: The option to set the default port no longer exists in the Microsoft SQL Server Database Detail pattern. In order for Atrium Discovery to retrieve the database details via a JDBC connection, it will need to be able to access the database as a legitimate user with privileges to execute the SQL queries below. Note If the SQL Server has been configured to allow only Windows domain users, then the jTDS driver should be used when creating database credentials and the additional parameters section populated with 'domain=Actual Windows Domain Name'. Furthermore, if the domain controller requires NTLM v2 authentication add the parameter: 'useNTLMv2=true'. The pattern executes the following SQL queries. For SQL Server 2000 the pattern runs the following query For all modern versions of SQL Server the pattern runs the following queries. Any database that appears in at least one result will have a Database node If the list of databases was obtained by sp_databases every database should have size information. If it doesn't (perhaps because the list was obtained by querying sys.databases) the pattern tries one of the following two methods to obtains size Full information on the database permissions required is given in the publisher's documentation Note Enabling the get_db_individ configuration option can adversely affect pattern performance. You should only enable this option if database permissions require this. This only happens if the retrieve_tables configuration option is enabled To obtain a list of tables within a database the pattern executes the following SQL Query: Shows availability groups group_id, ip_configuration_string_from_cluster as listener_ip. The pattern gets compatibility level and database ID from the "SELECT name AS database_name, compatibility_level, database_id FROM sys.databases" query used to find the list of managed databases The pattern gets physical name from the query "SELECT database_id, physical_name FROM sys.master_files". This links database_id to physical_name. We link physical_name to database name using the above query. Note that one database might have several physical names The pattern attempts to obtain a list of databases using these additional methods The pattern attempts to run the following WMI queries Where server name is not known and edition = "Express Edition" Otherwise Should the first WMI query fail, the second one is then attempted. The name of each database is then extracted from the output and a DatabaseDetail node created for each as well as adding each one to the 'db_list' (array) and 'dbs' attributes of the SI previously created by the SQLServer pattern, except those in the Configuration ignore_databases list. Should a server name contain an underscore, a dollar or a # the pattern will perform various substitutions to ensure the WMI query runs successfully Note Depending on Discovery version containing a pattern for the actual database, Discovery uses either Database or DatabaseDetails nodes for database representation. The pattern attempts to execute the following osql.exe command. The output of the command is then parsed and a DatabaseDetail node created for each database as well as adding each one to the 'db_list' (array) and 'dbs' attributes of the SI previously created by the SQLServer pattern. This is attempted only if the file_db_discovery configuration option is enabled. The pattern obtains a list of all .mdf files in the SQL Server data directory and its sub-directories. It then creates a Database node whose physical_name attribute is the path to the .mdf file. The instance name is: If we subsequently find a database with the same physical name (most probably via a SQL query) we will only update the discovered instance name and we will not create another Database node If the errorlog_discovery configuration option is enabled the pattern searches the ERRORLOG file for text: If it is found a Database node is created Note The errorlog_discovery configuration option is disabled by default. We recommend you do not enable it unless you are having major difficulties with other discovery methods. This method will create Database nodes for databases that have been started and subsequently stopped, not just databases that are started and still running Always On availability groups feature is a high-availability and disaster-recovery solution that provides an enterprise-level alternative to database mirroring. Availability group supports a fail-over environment for a discrete set of user databases, known as availability databases, that fail over together. An availability group supports a set of read-write primary databases and one to eight sets of corresponding secondary databases. Optionally, secondary databases can be made available for read-only access and/or some backup operations. Microsoft Cluster report all ClusterResources that are SQL Server Availability Groups. The SQL Server extended discovery pattern adds linking and extra detail. The pattern creates a SoftwareService link from the ClusterService that hosts the Availability Group ClusterResource to the DatabaseDetails that make up the Availability Group. The ClusterService is the service, the DatabaseDetail is the ServiceProvider. The pattern finds the information by running the following SQL query: Note that due to a limitation in BMC Discovery this link will not be shown in visualizations. To see what DatabaseDetails are part of a given Availability Group you must execute the following generic search If BMC Discovery was capable of producing visualizations for this model, then would look as follows: The pattern also adds extra details to existing nodes. This information is obtained from the database query: On every SQL Server instance that the pattern discovers it executes the following query For each entry that refers to a SQL Server database the pattern creates a Client Server link from the triggering SQL Server Software Instance to the SQL Server Software Instance referred to in data_source. The OLE database is the client. If data_source is of the form <hostname>\<instance name> we use both host name and instance name to do the linking. Otherwise we link to a SQL Server Software Instance with instance MSSQLSERVER on the host described in data_source We do not process entries that do not refer to SQL Server (i.e. where the product field is not “SQL Server” and the provider field is not “SQLNCLI”)
Pattern Goal
Configuration Options
Setting of Database Integration Point
Setting the port
The SQL Server Database Detail pattern behavior is now as follows:
The reason for this change is to minimize the number of configuration steps required and prevent errors due to forgotten changes in pattern configuration.Database User Configuration
We believe that in case of:
Example: domain=MY_DOMAIN;useNTLMv2=trueSQL Queries Executed
List of Managed Databases
Database Size
List of Tables
show Listener IP
Other Attributes
Additional methods
WMI Query
Discovery continues to use DatabaseDetails nodes only until the expiration of the 11.1 version.Command
<path_to_osql> -S <hostname\servername> -w 65000 -E -Q "USE master; SELECT Name FROM sysdatabases"
Directory Listing - file-based discovery method
ERRORLOG file
Starting up database ['"](\S+)['"]\.
Availability Groups
Linking
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_id
Background to the query is represented hereOLE Linking
2 Comments
Michael D
It would be helpful if you add a BMC Discovery availability group visualization screenshot.
Chris Blake
Discovery does not currently have the ability to visualize ClusterServices and ClusterResources so we cannot visualize an AlwaysOn Availability Group. I have submitted an RFE for this feature to be included in a future version