Monday, March 25, 2019

Grant Solarwinds to access and monitor DB performance

If we use Solarwinds DPA to monitor the DB health and performance and want to get notified about the data file space and long-running sql queries, then first of all we have to grant access on all dbs to SW by below script..


---------------- Solarwinds DPA grant access script -------------
-- Change the DOMAINNAME\User

USE master
GO
IF NOT EXISTS(SELECT * FROM sys.syslogins WHERE name = 'MED\swadmin')
BEGIN
          print 'CREATE LOGIN'
       CREATE LOGIN "MED\swadmin" FROM WINDOWS
END
GO
GRANT VIEW SERVER STATE TO "MED\swadmin"
GO
GRANT VIEW ANY DEFINITION TO "MED\swadmin"
GO
print 'sp_adduser'
EXEC sp_adduser @loginame = 'MED\swadmin', @name_in_db = 'MED\swadmin'
GO
GRANT EXECUTE ON xp_readerrorlog TO "MED\swadmin"
GO
USE msdb
GO
print 'sp_adduser'
EXEC sp_adduser @loginame = 'MED\swadmin', @name_in_db = 'MED\swadmin'
GO
EXEC sp_addrolemember N'db_datareader', N'MED\swadmin'
GO
print 'Loop Start'
go
EXEC sp_MSforeachdb 'USE [?]; EXEC sp_adduser @loginame  = ''MED\swadmin'''
GO

No comments:

Post a Comment