Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Monitoring Exchange database sizeSize

Posted on 2005-04-28
23
Medium Priority
?
332 Views
Last Modified: 2012-05-05
Hi there

I want to know how to monitor the total size of the exchange database size.

Basically, I want a notification email every morning, telling me the total size of the exchange database in GB.

Just like in Veritas we have email confirmation for the completion of the backup, I want same thing for exchange database size.

Dhaval
0
Comment
Question by:MICRONET2004
  • 11
  • 9
21 Comments
 
LVL 1

Expert Comment

by:dhaval001
ID: 13884223
Use WMI for monitoring the exchange database size.
0
 

Author Comment

by:MICRONET2004
ID: 13888002
Hi Kfullarton

Thanks for the links, but what do I do with these scrips?

Let me know

Dhaval
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 9

Accepted Solution

by:
kfullarton earned 750 total points
ID: 13888252
You can use these samples to monitor the files of your exchange database.  Follow each link and copy the contents of the scripts to individual text files.  Name the file deescriptively and give it a vbs extension.  You're going to need to add specifics such as filenames or directory paths to get it to work.  For example, copy the text below to notepad and save as a vbs file.

Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace ("C:\")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim arrHeaders(13)

For i = 0 to 13
    arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next

For Each strFileName in objFolder.Items
    For i = 0 to 13
        If i <> 9 then
            Wscript.echo arrHeaders(i) _
                & ": " & objFolder.GetDetailsOf (strFileName, i)
        End If
    Next
    Wscript.Echo
Next



This will give detailed summary information for all of the files under C:  Run it from the command line by typing "cscript <filename>.vbs".  You'll need to do the same for the others and with some tweaking, you should be able to produce the results you're looking for.
0
 

Author Comment

by:MICRONET2004
ID: 13892943
Hi Kfull

I am sorry, but I don't understand this script programming.

Also, your solution doesn't answer my root question.

I want to monitor the size of the Exchange databases, not size of all files in a specific folder like c:\ as you mentioned.

Now the other questions that I have is what will be the output format of your script?

Also how do I get the result in an email?

Dhaval
0
 
LVL 9

Expert Comment

by:kfullarton
ID: 13895433
OK.  Here is a sample script that will work on a server that has the smtp service enabled.  You will need to modify a few lines to fit your situation.

##########################################################################
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where name = 'c:\\Scripts\\Adsi.vbs'")   <-----Modify this for your exchange databse path

For Each objFile in colFiles
    Wscript.Echo "File name: " & objFile.FileName
    Wscript.Echo "File size: " & objFile.FileSize

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "monitor1@fabrikam.com"   <--------------------Modify this line
objEmail.To = "admin1@fabrikam.com"   <----------------------Modify this line
objEmail.Subject = "Exchange File Size"    <----------------------Modify this line
objEmail.Textbody = "File Name: & objFile.FileName & vbCRLF & "File Size: " & objFile.FileSize
objEmail.Send

###########################################################################

Scripting is an invaluable tool for systema administration.  You can poke around on Microsoft's site and find may useful scripts.  They don't always work out of the box, which is why you need to learn how to tweak them.  Take the script above, without the Modify comments, and copy it to notepad.  save the file as mail.vbs on the mail server.  Open a command prompt and type "cscript mail.vbs".  It should work.

0
 
LVL 9

Expert Comment

by:kfullarton
ID: 13897482
Additionally, the exchange datatbases equate to files like priv.edb and pub.edb.  Knowing the size of these files will give you the information you need.  The script above will put that information in an email and send it to the address that you specify.
0
 

Author Comment

by:MICRONET2004
ID: 13900497
Hi kfull

Thanks for the information.

I just want to clerify a few things before I try this.

In your script,

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where name = 'c:\\Scripts\\Adsi.vbs'")   <-----Modify this for your exchange databse path

Do I set it to

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where name = 'E:\Program files\Exchsrvr\MDBData\priv1.edb'")   <-----Modify this for your exchange databse path

Also, in the path, do I need two slashes as you have suggested or single slashes as we normally put in the path?

I am installing a new server for a customer for this weekend and I want to try it with this.

Dhaval

0
 
LVL 9

Expert Comment

by:kfullarton
ID: 13910863
You are correct.  The two slashes come from Microsoft's site, not a typo.  Let me know how it goes...
0
 

Author Comment

by:MICRONET2004
ID: 13951220
Hi Kfull

When I did this script, and just double clicked it, it gave me an error.

Below is my script

========================
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where name = 'E:\\Program Files\\Exchsrvr\\MDBDATA\\priv1.edb'")

For Each objFile in colFiles
    Wscript.Echo "File name: " & objFile.FileName
    Wscript.Echo "File size: " & objFile.FileSize

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "administrator@mnit.co.uk"  
objEmail.To = "dhaval001@hotmail.com"  
objEmail.Subject = "Exchange File Size"
objEmail.Textbody = "File Name: & objFile.FileName & vbCRLF & "File Size: " & objFile.FileSize
objEmail.Send
====================================

Below is the error I get

E:\script.vbs(17, 64) Microsoft VBScript compilation error: Expected end of stat
ement

My script is located on E: and name is script.vbs.

let me know what is wrong and what do I need to change.

Dhaval
0
 
LVL 9

Expert Comment

by:kfullarton
ID: 13961660
Dhaval,

That error indicates that there is an error on line 17, character 64.  That's the right line, not the right space.  Change the line so it looks like this add in a double quote after the colon:

objEmail.Textbody = "File Name: " & objFile.FileName & vbCRLF & "File Size: " & objFile.FileSize
0
 

Author Comment

by:MICRONET2004
ID: 13968781
Hi Kfull

I did that and now the error is on line 19 which I believe is the last line.

Does the script require something like end as the last line in the scrip or the last command on its own should be fine.

The error says Line 19, character1, but there is no line 19.

Dhaval
0
 

Author Comment

by:MICRONET2004
ID: 13973264
Hi Kfull

okey, I am making some progress here.

The error said "Expected: Next" at whatever location it said.

I saw a few examples of scripts and noticed Next at the end of the the script.

I am not sure if it is used to end the script, but I tried and it worked for me... almost.

The script runs and gives me the size of the file on the screen, but I don't get an email although I believe I have specified the values for emails correctly.

So what do I do next?

Dhaval
0
 

Author Comment

by:MICRONET2004
ID: 13973310
Hi Kfull

You might be amazed to my experiments, but I have got it working.

It is emailing me the file size and I can probably schedule the file to run at specific times of the day.

One last thing I want from you, two things actually.

1. To show the size of the file in gigabytes, i mean identify the size in gigabytes instead of just plain number of bytes.

2. The script should check the size of the file, compare it with a value I specify and then email me only if the size of the file exceeds that size. I mean I need an alert email saying for a specific file, the size has exceeded specific amount.

I really appriciate your help.

Dhaval
0
 
LVL 9

Expert Comment

by:kfullarton
ID: 13976572
Dhaval,

I'll check on those 2 and get back to you.
0
 

Author Comment

by:MICRONET2004
ID: 14025286
Hi Kfull

Something interesting.

The script is working and sending me the size. But funny enough, it is sending me the same size as of the day it started.

Although the file size keeps changing, everyday in the email, I get the same size.

I have scheduled a task to run the script at midnight everyday.

I wonder why I am getting the same size everyday.

Dhaval
0
 
LVL 9

Expert Comment

by:kfullarton
ID: 14026257
What is the size of your exchange database file?
0
 

Author Comment

by:MICRONET2004
ID: 14034297
This is what I get in email everyday

File Name: priv1
File Size: 1043406848


Dhaval
0
 

Author Comment

by:MICRONET2004
ID: 14058638
Hi Kfull

Any luck with the size being reported same all the time?

Dhaval
0
 
LVL 9

Expert Comment

by:kfullarton
ID: 14059492
I have not seen that issue in my testing.  I have see however, that for files of an extremely large size, no size is reported at all.  Have you tried this with any test files?  try a text file with a few characters, then add a few more, then add a few more and see if it changes.  The problem you're encountering may be similar to what I'm seeing.  I have emailed Microsoft Scripting Support but have not heard back.
0
 

Author Comment

by:MICRONET2004
ID: 14059611
i will try it with some test files for next few days.

Dhaval
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Web hosting control panels were first developed to make it faster and easier for most users to set up and operate websites. The graphical user interface (GUI) allows users to perform tasks by pointing and clicking rather than typing highly specific…
Eseutil Hard Recovery is part of exchange tool and ensures Exchange mailbox data recovery when mailbox gets corrupt due to some problem on Exchange server.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question