How to Add/Remove a New Server to the Monitoring Process?
- Create the dbamaint database on the new server.
if not exists (select * from master..sysdatabases where name=’dbamaint’)
create database dbamaint
go - Create a new “Microsoft OLE DB connection” to the new server in the DTS package.
- Create a new “Execute SQL task” in DTS package with the following query:
use dbamaint
go
if not exists (select * from dbamaint..sysobjects where name=’errorlog_srv’ and type=’U’)
create table dbamaint..errorlog_srv
(server_name varchar(25) default @@servername,errlog_text varchar(255),c2 int)if exists (select * from dbamaint..sysobjects where name=’temp_errorlog’ and type=’U’)
drop table dbamaint..temp_errorlogcreate table dbamaint..temp_errorlog
(server_name varchar(25) default @@servername,errlog_text varchar(255),c2 int)insert dbamaint..temp_errorlog (errlog_text,c2)
exec master..xp_readerrorlogif exists (select * from dbamaint..sysobjects where name=’new_errorlog_rows’ and type=’U’)
drop table dbamaint..new_errorlog_rowscreate table dbamaint..new_errorlog_rows
(server_name varchar(25) default @@servername,errlog_text varchar(255),c2 int)insert dbamaint..new_errorlog_rows (errlog_text,c2)
select errlog_text,c2 from dbamaint..temp_errorlog where errlog_text not in (select errlog_text from dbamaint..errorlog_srv)–select * from dbamaint..new_errorlog_rows
insert dbamaint..errorlog_srv
select * from dbamaint..new_errorlog_rows - Create a “Transform Data Task Properties” task and enter the following query:
select * from dbamaint..new_errorlog_rows
- Add the workflow so that the transform step runs after the “Execute sql task.”
- Don’t forget to save the DTS package.
You have now successfully completed the setup of errorlog monitoring.
In the next article, I will explain how to set up the space monitoring report.
]]>