ALTER PROCEDURE [dbo].[sp_exec_getDiskSpace] AS
BEGIN
-- 只监控部分重要的盘符
declare @MBfree int ;
declare @Drive varchar(10) ;
declare @bd varchar(4000) ;
create table #tb_DiskSpace( [Drive] varchar(2),[MBfree] int) ;
insert into #tb_DiskSpace([Drive],[MBfree]) exec master.dbo.xp_fixeddrives
select @MBfree=[MBfree] from #tb_DiskSpace where [Drive] ='C';
if @MBfree<2048 begin
set @bd='C盘空间不足,剩余'+ltrim(str(@MBfree/1024))+'G'
exec managerDB.dbo.[spSendMail] @from='dwchaoyue@163.com',
@to='v.dengwang@snda.com',
@bcc='', -- 抄送
@subject='磁盘空间不足',
@htmlBody=@bd,
@addAttachment='' -- 附件
end ;
select @MBfree=[MBfree] from #tb_DiskSpace where [Drive] ='D';
if @MBfree/1024<30 begin
set @bd='D盘空间不足,剩余'+ltrim(str(@MBfree/1024))+'G'
exec managerDB.dbo.[spSendMail] @from='dwchaoyue@163.com',
@to='v.dengwang@snda.com',
@bcc='', -- 抄送
@subject='磁盘空间不足',
@htmlBody=@bd,
@addAttachment='' -- 附件
end ;
END
本文出自 “SQLServer MySQL” 博客,请务必保留此出处http://dwchaoyue.blog.51cto.com/2826417/1439119