#122235 - 2004-07-06 11:36 PM
Dir Size Script
|
bpogue99
Fresh Scripter
Registered: 2004-04-19
Posts: 15
Loc: USA
|
Hi, I went through all the UDF's in the library and searched using several dozen keywords but didn't find anything similar to what I'm looking for. I suspect though that it's been done already, or I hope so, if not, we'll build it and post it.
Anyway, there are many programs out there that will give you the size of the directories on your system. Select a drive and they'll give you a nice gui chart or report of each directory on your machine and the size of it. Primarily this is used to find those hogs <g>
Is there a Kix script to generate a report, just plain ol' text? What I want to do is automate the reporting of directory sizes across about 12 servers. Pass the routine \\server\c$ or \\server\d$, etc. and it'll provide back a basic report of directories sizes starting from the path specified.
Right now I have to access each server, run one of those dumb dirsize programs, save the report (by finding the centralized storage location), give it a name dated already. A serious pain in the butt for 12 servers and 2 drives each (24 runs/saves).
What I have so far is... don't laugh... untested...
Used like this: KIX32 SaveDirSizeLogs.KIX $$SVR=SERVER1 $$RDRV=C $$SDRV=C KIX32 SaveDirSizeLogs.KIX $$SVR=SERVER1 $$RDRV=C $$SDRV=D KIX32 SaveDirSizeLogs.KIX $$SVR=SERVER2 $$RDRV=C $$SDRV=C KIX32 SaveDirSizeLogs.KIX $$SVR=SERVER2 $$RDRV=C $$SDRV=D
Code:
; Save Directory Reports ; ; This script will generate directory size reports on the specified server, ; and then write an event to it.
Break on
; Server specified? If $SVR = 0 ? "No server specified..." ? ? "KIX32 SaveDirSizeLogs.KIX $$SVR=servername $$RDRV=reportdrive $$SDRV=scandrive" QUIT 1 EndIf If $RDRV = 0 ? "No report drive specified. Please specify the server's drive for storing the reports..." ? ? "KIX32 SaveDirSizeLogs.KIX $$SVR=servername $$RDRV=reportdrive $$SDRV=scandrive" QUIT 1 EndIf If $SDRV = 0 ? "No scan drive specified. Please specify the server's drive to scan..." ? ? "KIX32 SaveDirSizeLogs.KIX $$SVR=servername $$RDRV=reportdrive $$SDRV=scandrive" QUIT 1 EndIf
; Format today's date for use in file names $DATE = Substr(@DATE,1,4) + Substr(@DATE,6,2) +Substr(@DATE,9,2) ; Location to store archived logs (this is a central storage depot) $LOG = "\\SERVER1\DATA\IT\Servers\DirectorySizeLogs\$SVR" ; In case the directory does not exist, let's make it md $LOG
; Location to store the event logs on the server being checked $LOC = "\\$SVR\$RDRV$$\DIRSIZELOGS" ; Make this directory so it exists md $LOC
; Clear Logs? Set this to TRUE to clear them - not implemented really $CLR = 1
; Process Log StoreDirLog($CLR)
EXIT
Function StoreDirLog($CLR) ; Process Log $LogName=$SDRV + "-DriveScan"
; Remove spaces from the name $LOGFILE = join(split($LogName),'') $LOGNAME= $LOGFILE + "Log-$DATE.EVT" $ARCHIVE = "$LOG\$LOGNAME" $MAINLOG = "$LOC\$LOGNAME" $LOCALLOG = "$DRV:\DIRSIZELOGS\$LOGNAME" ? "Building... $SVR - $LOGNAME"
; Remove any existing log del "$ARCHIVE" del "$MAINLOG"
$RTN = DirSize($SERVER,$SDRV) ; Doesn't exist yet If @ERROR = 0 EndIf
; Archive the logfile copy $MAINLOG $ARCHIVE ? "Storing... $ARCHIVE"
$RC = LogEvent( 0 , 1 , "$LogName successfully created and archived." , "\\$SVR", "Log-$LOGFILE") EndFunction
_________________________
KiXing to the limits!
|
|
Top
|
|
|
|
#122236 - 2004-07-07 12:16 AM
Re: Dir Size Script
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
here is a quick and dirty UDF....
you need wshpipe() UDF
and DIRUSE.EXE from the MS resource kit
Code:
for each $line in diruse("\\flag-fs01\resource", "/* /m /,")
? $line
next
Function DirUse($Source, optional $options)
dim $i, $return
$return = wshpipe('diruse ' + $options + ' ' + $source,1)
dim $out[ubound($return)-4]
for $i = 2 to ubound($return)-2
$out[$i-2] = $return[$i]
next
$diruse = $out
endfunction
Edited by Bryce (2004-07-07 12:19 AM)
|
|
Top
|
|
|
|
#122237 - 2004-07-07 02:02 AM
Re: Dir Size Script
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Henriques)
and 2516 anonymous users online.
|
|
|