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