Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Checking for free disk space & gettting a mail

Author  Topic 

vaddi
Posting Yak Master

145 Posts

Posted - 2006-09-13 : 16:43:35
Hello

I have a script which checks the disk space and when it falls a certain size , it mails the dba mail box.

I would like to know how I can change it , as a percentage calculation.

For example when the free space is less than 20% of the total space on the drive I should be receiving a mail.

The script I have is :

declare @MB_Free int

create table #FreeSpace(
Drive char(1),
MB_Free int)

insert into #FreeSpace exec xp_fixeddrives
-- Free Space on F drive Less than Threshold
if @MB_Free < 4096
exec master.dbo.xp_sendmail
@recipients ='dvaddi@domain.edu',
@subject ='SERVER X - Fresh Space Issue on D Drive',
@message = 'Free space on D Drive
has dropped below 2 gig'
drop table #freespace


Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-09-13 : 16:55:27
You can't easily get to this information from T-SQL. As you've noticed, xp_fixeddrives only gives you free space. If there were a way to get total space, then you could easily do the math on it. I don't know of a DOS way to do it, but if there is then you could run that through xp_cmdshell.

You can use a Performance Monitor object in a .NET application though. I went this route when I needed to know when the disk space went below 10% free space.

Tara Kizer
Go to Top of Page
   

- Advertisement -