Solved

How to check the disk space of shared disk on cluster environment?

Posted on 2009-04-06
5
517 Views
Last Modified: 2012-05-06
We created all user databases on shared disk Lun1 and Lun2 on drive D: (Lun1 and Lun2 were subfolder undre drive D:). If I ran xp_fixeddrives, it would only tell me how much space left on drive D:,  and didnt tell me how much free space on the shared disk Lun1 and Lun2. Right I just manually checked by check the properties of Lun1 and Lun2 to get the information. Do you have any commands or any stored procedures for monitoring the disk space on shared disk?
Thanks!
0
Comment
Question by:luyan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:MohammedU
ID: 24131648
You can try using DIR command with XP_CMDSHELL...
Check the following url...
http://bytes.com/groups/ms-sql/477715-check-diskspace-unc-via-t-sql
0
 

Author Comment

by:luyan
ID: 24226633
I could create the stored procedure sp_checkdbspace. But when I ran it, got the following error message.
Msg 208, Level 16, State 1, Procedure sp_checkdbspace, Line 52
Invalid object name 'msdb..DBSpaceHistory'.

0
 
LVL 15

Accepted Solution

by:
MohammedU earned 500 total points
ID: 24226949
You have to modify the proc...
Use the following...


CREATE procedure sp_checkdbspace
AS
SET nocount ON

CREATE TABLE #DriveList (
name varchar(20) null,
lowfree int null,
highfree int null,
mediatype int null
)

CREATE TABLE #DirList (
Drive varchar(20) null,
DirResults varchar(255) null
)

INSERT INTO #DriveList EXEC master.dbo.xp_availablemedia

DECLARE @Drive varchar(20),
@CMD varchar(255)

DECLARE mycursor CURSOR
FOR
SELECT name
FROM #DriveList
ORDER BY name

OPEN mycursor

FETCH mycursor INTO @Drive

IF CURSOR_STATUS('variable', '@mycursor') = 0
BEGIN
PRINT 'No such device'
CLOSE mycursor
DEALLOCATE mycursor
return
END

WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @CMD = 'insert into #DirList (DirResults) EXEC
master..xp_cmdshell ''DIR /-C ' + @Drive + ''''
EXEC (@CMD)
UPDATE #DirList SET Drive = @Drive WHERE Drive IS NULL
FETCH mycursor INTO @Drive
END

CLOSE mycursor
DEALLOCATE mycursor


SELECT *, BytesFree = convert(numeric(18,0),
rtrim(ltrim(substring(replace(DirResults, ' bytes free', ''), 26,
50))))
INTO #SpaceOnDisk
FROM #DirList
WHERE DirResults LIKE '%bytes free%'



select Drive, DiskMBFree = convert(numeric(10,3), BytesFree / 1048576) from #SpaceOnDisk

drop table #DriveList, #SpaceOnDisk, #DirList
0
 

Author Comment

by:luyan
ID: 24251062
Thanks for your script. It's good to find the free space information for every drives. How can I get the information of different Lun (such as sub-directories D:\Lun1 and D:\Lun2) of storage device through running script?
I could get the information by running diskmgnt.msc.  How to put the output into report? I would like to get email of this report.
Thanks!
0
 

Author Closing Comment

by:luyan
ID: 31567166
Thanks!
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Do not display comma when no last name 8 48
SQL Server Agent "Access Denied" Error 3 35
Migrate SQL 2005 DB to SQL 2016 4 28
T-SQL Query 9 35
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question