SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Script For Monitoring State of other servers and alerting !!!


Script For Monitoring State of other servers and alerting !!!

Author
Message
bobnysoftz
bobnysoftz
Valued Member
Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)

Group: General Forum Members
Points: 54 Visits: 281
Please can you help I need a script that will use a centralized server to monitor other sql servers state and if a server is offline it will send a email to alert the dba about which server has a database that is offline . Pleaase do great assist and all your help is greatly appreciated.
benjamin.reyes
benjamin.reyes
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1219 Visits: 2286
I'm sure there is a better way. This was just fast to throw together.


This assumes you have dbmail setup and a valid operator.

Run this on the server you want to monitor:

create database dbadmin
go
use dbadmin
go
create table serverstatus (
isawake char(1))
GO
insert into serverstatus
values(1)

create a least privelidged login and a link server connection from your monitor to the monitoree with that account.


Then throw this in a job step


Declare @isawake char(1)

set @isawake = (select isawake
from [SERVERIWANTTOMONITOR].dbadmin.dbo.serverstatus)

if @isawake <> '1'

begin
raiserror('Test Notify Server Failure', 16, 1, 1)
end


Set the notifications on the job to email the operator on failure. Also have a second server that points back to the monitor server to validate that is awake as well.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search