[mrtg] Re: Monitoring A file size....
Williams, Garth
gkwilliams at epcor.ca
Tue Feb 25 19:09:11 MET 2003
There are two vbs files pasted into this message. Cut where appropriate,
and save one as filesize.vbs and the other as foldersize.vbs. Then you
can call them from the Target[]: line as usual. You will then be able
to monitor folder and file size.
Run without commands (i.e. cscript //nologo filename.vbs) will display
usage information.
Hope this helps people! Should work on NT/2K and XP.
Garth Williams
SNMP for the Public Community
(www.snmp4tpc.com)
' -------------------------------------------------------
' FILESIZE.VBS - File Size Monitor helper for MRTG
' -------------------------------------------------------
' Garth K. Williams - garth.williams at wtcs.org
' -------------------------------------------------------
' Version 1.0
' Enhancements to include uptime
' -------------------------------------------------------
Set sh = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject ("Scripting.FileSystemObject")
Dim Target, HostName, oArgs
Set oArgs=wscript.arguments
If wscript.arguments.Count <>2 Then
wscript.echo "Incorrect arguments!"
wscript.echo "----------------------------------------"
wscript.echo "Only \\UNC\Path\To\File (or Drive:\directory\file)
needed!"
wscript.echo "Note: Permissions must be valid for target! Will not work
on hidden files!"
wscript.echo "Usage: cscript //nologo filesize.vbs [hostname]
[target_file]"
wscript.echo "File size returned in bytes; use MRTG math to adjust if
necessary."
wscript.echo "MRTG Config File Usage Examples:"
wscript.echo "Target[xyz]: `cscript //nologo filesize.vbs WIN2KFS1
\\WIN2KFS1\share\File.ext`"
wscript.echo "Target[xyz]: `cscript //nologo filesize.vbs WIN2KFS1
c:\temp\File.ext`"
wscript.echo "----------------------------------------"
wscript.quit 1
End If
HostName = oArgs.item(0)
Target = oArgs.item(1)
set MyTarget = fso.GetFile(Target)
' --------------------------------
' Output in MRTG friendly format
' --------------------------------
wscript.echo MyTarget.size
wscript.echo MyTarget.size
wscript.echo HostName
wscript.echo "Uptime not available (yet)"
' ---------------------------------
' "and several butchers' aprons"
' (End of FileSize.vbs)
' ---------------------------------
' -------------------------------------------------------
' FOLDERSIZE.VBS - Directory Size Monitor helper for MRTG
' -------------------------------------------------------
' Garth K. Williams - garth.williams at wtcs.org
' -------------------------------------------------------
' Version 1.0
' Enhancements to include uptime
' -------------------------------------------------------
Set sh = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject ("Scripting.FileSystemObject")
Dim Target, HostName, oArgs
Set oArgs=wscript.arguments
If wscript.arguments.Count <>2 Then
wscript.echo "Incorrect arguments!"
wscript.echo "----------------------------------------"
wscript.echo "Only \\UNC\Path\To\Folder (or Drive:\directory) needed!"
wscript.echo "Note: Permissions must be valid for target! Will not work
on hidden folders!"
wscript.echo "Usage: cscript //nologo foldersize.vbs [hostname]
[target_folder]"
wscript.echo "Folder size returned in bytes; use MRTG math to adjust if
necessary."
wscript.echo "MRTG Config File Usage Examples:"
wscript.echo "Target[xyz]: `cscript //nologo foldersize.vbs WIN2KFS1
\\WIN2KFS1\share\Folder`"
wscript.echo "Target[xyz]: `cscript //nologo foldersize.vbs WIN2KFS1
c:\temp`"
wscript.echo "----------------------------------------"
wscript.quit 1
End If
HostName = oArgs.item(0)
Target = oArgs.item(1)
set MyTarget = fso.GetFolder(Target)
' --------------------------------
' Output in MRTG friendly format
' --------------------------------
wscript.echo MyTarget.size
wscript.echo MyTarget.size
wscript.echo HostName
wscript.echo "Uptime not available (yet)"
' ---------------------------------
' "Y'are Mary, Queen of Scots?"
' "I am!"
' much mayhem ensues
' (End of FolderSize.vbs)
' ---------------------------------
This e-mail contains confidential information that is proprietary to EPCOR and its subsidiary companies in all respects. This information is intended only for the person(s) named in the destination address. Distribution, copying or disclosure is strictly prohibited. If you receive this e-mail in error, please delete it immediately.
This message scanned for viruses by the EPCOR anti-virus gateway.
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list