July 20, 2010 at 4:08 am
Hi Team,
Please help me in developing a script.
The script is like we need to give instance name as a parameter and it should check whether that instance is able connect or not and if it is not able to connect to that instance it should send us a mail ?
Your help is much appriciated.
Thanks in Advance
Thank You.
Regards,
Raghavender Chavva
July 20, 2010 at 4:21 am
set all your instances up as linked servers. write a script to query the master database (any table). if it errors you know you have a problem somewhere (assuming you have no network issues and you know your script works you can assume the sql server is offline)
Only problem with this approach is if your main monitoring server goes down your screwed 🙂
Have you looked at using any third party tools to monitor windows services?
July 20, 2010 at 5:49 am
Can you please provide me the sample script for it ?
Thank You.
Regards,
Raghavender Chavva
July 20, 2010 at 7:17 am
edit: wrong post 🙂
July 20, 2010 at 8:04 am
Animal Magic (7/20/2010)
create table testcharindex
(Name varchar(50),
HasSpace bit default(0)
)
insert into testcharindex (Name)
select 'Morris'
union
select 'Taylor'
union
select 'Two names'
union all
select 'Taylor ' -- Notice the trailing space
select * from testcharindex
--not using trim
update testcharindex
set HasSpace = 1
where charindex(' ',Name) > 1
select * from testcharindex
--using trim
update testcharindex set HasSpace= 0
update testcharindex
set HasSpace = 1
where charindex(' ',rtrim(Name)) > 1
select * from testcharindex
drop table testcharindex
I dont think this is related to this post ?
I can do it using the OSQL script...but I need a script with if the connection not successfull we need a mail indicating that instance name ?
Thank You.
Regards,
Raghavender Chavva
July 20, 2010 at 8:51 am
ahhh yeah sorry, that was for another post i was responding too!! My bad 😛
I dont have a script that loops round multiple servers but im sure you can find one in the scripts section, or a quick google search
July 21, 2010 at 2:56 am
Can any Body please help me in this ?
Your help much appriciated....
Thank You.
Regards,
Raghavender Chavva
July 22, 2010 at 5:26 pm
Well, as pointed out earlier, set all your servers as Linked Servers. Create a table in master db of a monitoring server which will keep the inventory of all your SQL Servers. And then you could run a simple loop against that table by ServerNames(or ServerIds) to ping each server, one a time.
osql -E -S ' + @ServerID + ' -q "SELECT @@ServerName"
Capture the output of this execution. If 0 (server is pingable), then server is available, otherwise server is not available, so you can send an error message that that particular server is not available.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply