加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

监控sql server 2008 R2群集状态

发布时间:2016-01-15 08:26:34 所属栏目:MsSql教程 来源:网络整理
导读:declare @OutputType varchar(20) declare @debug char(1) declare @ForceRefresh char(1) declare @xp_cmdshell_available char(1) set @OutputType=LIST set
declare @OutputType varchar(20)
declare @debug char(1)
declare @ForceRefresh char(1)
declare  @xp_cmdshell_available char(1)

set @OutputType='LIST'
set  @Debug= 'Y'
set  @ForceRefresh= 'Y'
set  @xp_cmdshell_available = 'Y'

begin
 set nocount on
declare @id int
declare @id2 int
declare @Line varchar(300)
declare @CurrentCmd varchar(30)
declare @Cmd varchar(300)
declare @Node varchar(100)
declare @Resource varchar(100)
declare @Status varchar(20)
declare @i int
declare @Group varchar(100)
declare @Num varchar(10)
declare @ClusterID int
declare @tmp int
declare @ThisGroupsCurrentNode varchar(100)
declare @DoneClusterName char(1)
declare @RunningOnACluster char(1)
declare @Line2 varchar(300)
declare @SQLName sysname
declare @WindowsMachineName sysname
declare @PreferredServer sysname
declare @SQL varchar(4100)
declare @FailCnt int
declare @PreferredServers int
declare @z int
declare @CurrentSQLServerGroup sysname
declare @CurrentSQLServer sysname
declare @QuorumResource varchar(300)
declare @CreatedTempTables char(1)
declare @LoopGroup varchar(300)
declare @PreferredServerExists char(1)
if @Debug = 'Y' print convert(varchar (30),getdate(),109) + ': ' + object_name(@@procid) + ' started.'
select @DoneClusterName = 'N'

--验证@OutputType类型
if lower (@OutputType) in ('q', 'quick', 's', 'summary', 'sum') select @OutputType = 'Quick'
else if lower(@OutputType) in ('l', 'list') select @OutputType = 'List'
else
begin
select @Cmd = 'Error in ' + object_name(@@procid) +
  ': @OutputType parameter must be ''Quick'' or ''List'', not ''' +
  isnull(@OutputType,'<null>') + '''.'
raiserror 50001 @Cmd
return
end

if UPPER (@xp_cmdshell_available) in ('Y','')
SET @xp_cmdshell_available = 'Y'
else
SET @xp_cmdshell_available = 'N'
if @Debug = 'Y' print convert(varchar(30),getdate(),109) + ': Calling Spot_CheckCluster...'
select @FailCnt = 0, @PreferredServers = 0

--检查 xp_cmdshell是否开启

--declare @LocalTable table(result int, ErrorCode int)
-- insert into @LocalTable
-- execute QS_SoSS58_CheckCmdShell
--if 1 <> (select count(*) from @LocalTable where result = 1)

 if (0 = (select value_in_use from sys.configurations where name = 'xp_cmdshell'))
set @xp_cmdshell_available = 'N'

select @RunningOnACluster = case when convert(int,serverproperty('IsClustered')) = 1 then 'Y' else 'N' end
 set @SQLName = convert(sysname,serverproperty('ServerName'))

 set @WindowsMachineName = convert(sysname,serverproperty ('MachineName'))

if @Debug = 'Y' print convert(varchar (30),getdate(),109) + ': 创建临时表...'
create table #w3
(id int identity,
ParentID int null,
Type varchar(20) null,
Name sysname null,
OtherData sysname null,
Status varchar(20) null,
Comment varchar (255) null,
PreferredServerExists char(1),
RunningOnPreferredServer char(1) null,
ControlsTheCurrentSQLServer char(1) null,
TakeOfflineCmd char(1) null,
BringOnlineCmd char(1) null,
MoveGroupCmd char(1) null,
StopMSCSCmd char(1) null,
StartMSCSCmd char(1) null,
RunningOnServer sysname null,
Sequencer smallint null
)

create table #w4 (id int identity (1,1), group_name varchar(255) NULL)

create table #CmdOutput
(
id int identity,
OutputLine varchar(255) null
)
create unique clustered index #PK_CmdOutput on #CmdOutput(id)
select @CreatedTempTables = 'Y'

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读