Web Hosting Talk







View Full Version : Script or Utility Needed


fasttrak
11-08-2002, 09:33 AM
Hi,

This sounds crazy but I need to be able to find our how much room a client has taken on one of our virtual servers (we resell). I have been told by the support desk at the hosting company that the only way I can find this out is to add up every file in the root directory manually. This is insane but they will not budge on this.

Does any one know of a script or utility I can place in the root that will report back on the size of the folder and all sub folders contained.

MarkIL
11-08-2002, 10:04 AM
cd /usr/home/client
du -sH .

fasttrak
11-08-2002, 10:53 AM
Can I do that with Win2K? If so how? Sorry if this is a basic thing, but its new to me.

Thanks for the help

MarkIL
11-08-2002, 11:25 AM
http://www.md-network.de/jp/downloads/du-en.html

ServerCorps
11-10-2002, 06:16 PM
A few questions first:
- These servers are Win2K
- Do they run IIS?
- Do they run .asp pages?

If so, it is very easy to recurse directories and count the space used. There are several MSDN articles on this.

One better would be to enable disk space quotas in Win2k. It enforces disk space quotas for you. If you don't have access to this on a reseller account, I'd ditch the account and get a dedicated w2k server somewhere. you GOTTA have root priveleges on w2k if your going to run a good hosting biz. <<<this is only my opinion, take it with a grain of salt.

ServerCorps
11-10-2002, 06:57 PM
Here's how to check space usage of an entire directory structure, 1 level deep from the root.
This means you have a dir structure like:

d:\
users\
username1\
username2\


This script will report the total space used of:
username1
username2
...
Including all subdirs under each user dir
ENJOY

<%
' Disk Space Usage
' By Winshack.net Hosting

'this is the root of the directory youwant to check space usage on
'If your structure looks like:
'd:\
' users\
' username1\
' username2\
'then put this here:
RootDir="d:\users"
%>


<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<TITLE>Disk Space Usage</TITLE>
</HEAD>
<BODY>
<TABLE align="center" border="1">
<TR>
<TD width=150><B>Directory</B></TD>
<TD width=150><B>Megabytes</B></TD>
<TD width=150><B>Kilobytes</B></TD>
<TD width=150><B>Bytes</B></TD>
</TR>
<%
' Create a file system object to read all the directories
' beneath the current directory split_name(num_directory)

Set directory=server.createobject("scripting.filesystemobject")
Set allfiles=directory.getfolder(RootDir)
total_size=allfiles.size


' Lists all the files found in the directory
For Each directory In allFiles.subfolders


'total_size=total_size + directory.size %>

<TD width=150><%= directory.name %></TD>
<TD width=150><%= formatnumber((directory.size/1024/1024),2) %></TD>
<TD width=150><%= formatnumber((directory.size/1024),0) %></TD>
<TD width=150><%= formatnumber(directory.size,0) %></TD>
</TR>
<%
Next 'end of the For next Loop %>
<TR>
<TD width=150><B>Total</B></TD>
<TD width=150><%= formatnumber((total_size/1024/1024),2) %></TD>
<TD width=150><%= formatnumber((total_size/1024),0) %></TD>
<TD width=150><%= formatnumber(total_size,0) %></TD>
</TR>
</TABLE>
</BODY>
</HTML>

ServerCorps
11-10-2002, 06:59 PM
MODS:
This should probably be moved to programming

fasttrak
11-13-2002, 10:02 AM
Thanks Nikko,

Thats great.

ServerCorps
11-13-2002, 10:34 AM
Originally posted by fasttrak
Thanks Nikko,

Thats great.

I take it that it did what you needed?

fasttrak
11-13-2002, 11:04 AM
Perfectly. In actual fact it is very similar to a couple of scripts that others had directed me to.

Thanks very much for the help

ServerCorps
11-13-2002, 11:09 AM
Yeah, it came from some code at Planet Source Code I think, but that script had a bunch of code that didn't do anything. I just cleaned it up and parameter-ized it.