[hobbit] BBWin - Monitoring size of Exchange database files

Storer, Raymond storerr at nibco.com
Mon Aug 24 16:23:02 CEST 2009


Thomas, you can try the code someone else pointed to at deadcat and you can also try this:

Ray

'Author: Ray Storer
'Date: 2009-08-24
'Purpose: Check file size and existence

Option Explicit

'If you want to use the registry to find this, feel free to change this.
Const BBWIN_TMP_DIR = "C:\Program Files\BBWin\tmp\" 'change to meet your environment, but leave the trailing backslash
Const BBWIN_TEST_NAME = "fsize" 'change to meet your requirements

'If you want to use the environment variables feel free to change this.
Const HOST_NAME = "YOUR_MACHINE_NAME" 'change to meet your environment

'16 gigabytes
Const MAX_TOTAL_FILE_SIZE = 17179869184 'change to meet your requirements
Dim RED_FILE_SIZE
RED_FILE_SIZE = MAX_TOTAL_FILE_SIZE * 0.85 'change to meet your requirements
Dim YELLOW_FILE_SIZE
YELLOW_FILE_SIZE = MAX_TOTAL_FILE_SIZE * 0.70 'change to meet your requirements

'change the arrFiles(1) to the number of elements (files) you need minus 1.
Dim oFso, arrFiles(1), strStatus, oFile, iSumFileSize, strRedGreen, strFileInfo
iSumFileSize = 0
strRedGreen = "GREEN"
Set oFso = CreateObject("Scripting.FileSystemObject")

'change to meet your environment
arrFiles(0) = "C:\Program Files\BBWin\bin\cpu.dll"
arrFiles(1) = "C:\Program Files\BBWin\bin\disk.dll"
'keep adding arrFiles(...) here if you need more
strStatus = ""
strFileInfo = ""

'get the file sizes and set red if they do not exist
Dim sFile
for each sFile in arrFiles
        if (oFso.FileExists(sFile)) then
                Set oFile = oFso.GetFile(sFile)
                strFileInfo = strFileInfo & vbcrlf & sFile & vbtab & CStr(oFile.Size)
                iSumFileSize = iSumFileSize + oFile.Size
        else
                strRedGreen = "RED"
                if (len(strStatus) = 0) then
                        strStatus = strRedGreen & " " & HOST_NAME & " " & CStr(Now())
                        strStatus = strStatus & VbCrLf
                        strStatus = strStatus & " " & sFile & " file does not exist."
                else
                        strStatus = strStatus & " " & sFile & " file does not exist."
                end if 'check len of strStatus
        end if 'check for file existence
next 'iterate over the files

'set red,yellow,green based on file sizes
if (iSumFileSize >= RED_FILE_SIZE) then
        strRedGreen = "RED"
else
        if (iSumFileSize >= YELLOW_FILE_SIZE) then
                if (strRedGreen <> "RED") then
                        strRedGreen = "YELLOW"
                end if
        else
                if (strRedGreen <> "RED") then
                        strRedGreen = "GREEN"
                end if
        end if
end if

if (len(strStatus) = 0) then
        strStatus = strRedGreen & " " & HOST_NAME & " " & CStr(Now())
        strStatus = strStatus & vbcrlf
        strStatus = strStatus & strFileInfo
        strStatus = strStatus & vbcrlf
        strStatus = strStatus & "Total File Size: " & CStr(iSumFileSize)
else
        strStatus = strStatus & vbcrlf
        strStatus = strStatus & strFileInfo
        strStatus = strStatus & vbcrlf
        strStatus = strStatus & "Total File Size: " & CStr(iSumFileSize)
end if

Set oFile = ofso.CreateTextFile(BBWIN_TMP_DIR & BBWIN_TEST_NAME, true)
oFile.WriteLine(strStatus)
oFile.Close

Set oFile = Nothing
Set oFso = Nothing

CONFIDENTIALITY NOTICE:  This email and any attachments are for the
exclusive and confidential use of the intended recipient.  If you are not
the intended recipient, please do not read, distribute or take action in
reliance upon this message. If you have received this in error, please
notify us immediately by return email and promptly delete this message
and its attachments from your computer system. We do not waive
attorney-client or work product privilege by the transmission of this
message.




More information about the Xymon mailing list