Automon auto maintenance mode alert notification Automon DBA SPs – AM22


This script will check the Automon server status, when the ping fails five times based on the run schedule, it will automatically place it on maintenance mode.



-- exec usp_ping_server_morethan_5_fail_status_change
--  select * from DBA_All_servers where SVR_status<>'running'
-- select * from tbl_Error_handling where Module_name='ping'
alter proc usp_ping_server_morethan_5_fail_status_change
Summary:     Auto maintenance after 5 ping fails
Contact:     Muthukkumaran Kaliyamoorthy SQL DBA
Description: Auto maintenance after 5 ping fails

Date         Coder                          Description
2013-jan-21  Muthukkumaran Kaliyamoorhty     Updated the 2012 functionality                   

declare @count_s int

select @count_s=count(*) from tbl_Error_handling E
join DBA_All_servers A on (e.Server_name=a.Description)
where Module_name='ping' and  Upload_Date>=DATEADD(HH,-1,getdate())
--and a.SVR_status='running'
group by Server_name
having count(*)>=5
--select @count_s

if (@count_s>=5)

 DECLARE @server_name SYSNAME
      DECLARE @sql varchar(8000)
      DECLARE @minrow int
      DECLARE @maxrow int

 declare @ping_u table (id int  primary key identity, 
 servername varchar(100),count_R varchar(100)) 
insert into @ping_u

select Server_name,count(*) from tbl_Error_handling 
where Module_name='ping' and  Upload_Date>=DATEADD(HH,-1,getdate())
group by Server_name
having count(*)>=5
SELECT @minrow = MIN(id)FROM   @ping_u
SELECT @maxrow  = MAX(id) FROM   @ping_u
 while (@minrow <=@maxrow)
 select @Server_name=Servername  from @ping_u where ID = @minrow 
 --select @minrow,@maxrow

print @Server_name

update DBA_All_servers set SVR_status='not ping_U' where Description=@Server_name
update DBA_All_servers set maintenance_date= getdate() where Description=@Server_name
--select Description,SVR_status from DBA_All_servers where Description=@Server_name

 set @minrow =@minrow +1 





I’m currently working as a SQL server DBA in one of the top MNC. I’m passionate about SQL Server And I’m specialized in Administration and Performance tuning. I’m an active member of SQL server Central and MSDN forum. I also write articles in SQL server Central. For more Click here

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + 1 =

hacklink panel hacklink al hacklink sollet hdxvipizle resim yükleme onwin venüsbet ai nude 1xbet güncel giriş eskort yeşilköy cami avizesi seo paneli soma kömür bahis forum backlink al pgslot สล็อตเวตรง holiganbetvds
hack forum hacklink panel hacklink hacklink cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami avizesi cami avizesi cami süpürgesi cami süpürgesi cami ısıtma cami ısıtma evden eve nakliyat ofis taşıma seo hizmeti Onwin Rulet Casino Slot Oyna Bahigo 1xbet Deneme bonusu Bahis siteleri Maç özetleri Bahsegel Canlı Casino Siteleri Sweet Bonanza Blackjack Casino Rulet Oyna Canlı Casino takipçi satın al smm panel m