How to verify SQL Server Tempdb size via Script?

In my client place we have around 20 SQL Server Machine and i want to monitor Tempdb size (.mdf/ldf)in all the machine using script. 10 servers in 2005 and 10 servers in 2008 SQL Server. Please let me know the script. Thanks.
PKTGAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shannon_LowderCommented:
I believe the following code may have what you're looking for:

--exec usp_getmdfsize 'tempdb'
Create procedure usp_getmdfsize @dbname varchar(128)
as
declare @query varchar(200)
set @query ='begin use ' + @dbname + ' End begin DBCC showfilestats end'
create table #mytable(Fileid int, FileGroup int, Totalextents bigint,UsedExtents bigint,Name varchar(256),Filename varchar(600))
insert #mytable exec (@query)
select Name as DatabaseName,Filename,(TotalExtents*64)/1024 as TotalMB,(Usedextents*64)/1024 as UsedMB,
Free= ((TotalExtents*64) - (Usedextents*64))/1024,
FreePercent=(((TotalExtents*64*1.0) - (Usedextents*64*1.0))/(TotalExtents*64*1.0))*100
from #mytable
drop table #mytable
go

The first size is your mdf, the second is your ldf.  If I've misunderstood your request, please, let me know.  I'm here to help!
0
lofCommented:
it may be much simpler

either
exec sp_helpdb tempdb

or
select * from tempdb.sys.dm_db_file_space_usage
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.