PersonTX
Contributor
Contributor

Detecting Open Snapshots in ESXi?

Jump to solution

I just recently finished an upgrade to vCenter 4.1.0 345043 and ESXi 4.1.0 348481. Before this upgrade I have always ran ESX but decided to go to ESXi since ESX will not be upgraded after this release.

In my ESX environment I had a script that I found on this community that would email me a list of open snapshots once a day. I put this script in place because of issues where a backup left a snapshot open and I was unaware of it for quite some time.

Is there anything builit in the new version of vCenter or ESXi that will alert me on open snapshots in a similar manor?

Any information is greatly appreciated.


Thanks,

PersonTX

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership

To e-mail the report you can do something like the following script. The e-mail part of this script is taken from Alan Renouf's vCheck script:

# Set the SMTP Server address
$SMTPSRV = "mysmtpserver.mydomain.local"
# Set the Email address to recieve from
$EmailFrom = "me@mydomain.local"
# Set the Email address to send the email to
$EmailTo = "me@mydomain.local"

function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) {
    $mailer = new-object Net.Mail.SMTPclient($smtpserver)
    $msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
    $msg.IsBodyHTML = $true
    $mailer.send($msg)
}

Connect-VIServer -Server "vCenterServer"

$MyReport = Get-ChildItem vmstores: -Recurse | `
Where-Object {$_.Name -like  "*000001.vmdk" -or $_.Name -like  "*000002.vmdk"} | `
ConvertTo-Html

send-SMTPmail $EmailTo $EmailFrom "Snapshot Report" $SMTPSRV $MyReport

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
12 Replies
DSTAVERT
Immortal
Immortal

Welcome to the Communities

A simple search should turn up a bunch of scripts.

http://communities.vmware.com/search.jspa?peopleEnabled=true&userID=&containerType=&container=&q=fin...

-- David -- VMware Communities Moderator
0 Kudos
a_p_
Leadership
Leadership

Since you are asking for a script, I moved your question to the PowerCLI forum. I'm sure the guys here will shortly come up with a solution.

BTW did you take a look at RVTools yet? This has a nice GUI where you can see an overview of almost all settings, including snapshots.

André

0 Kudos
PersonTX
Contributor
Contributor

Thanks for the link to a good search.  I found one script that searches vCenter for snapshots which works great but not exactly what I was looking for.  I am looking for a script that works with ESXI hosts that will actually search for delta files.  This way if vCenter does not know about the snapshot I can still find them.


Thanks again,

PersonTX

0 Kudos
RvdNieuwendijk
Leadership
Leadership

Is this script what you need?

Get-ChildItem vmstores: -Recurse | `
Where-Object {$_.Name -like  "*.000001.vmdk" -or $_.Name -like  "*.000002.vmdk"}


Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
PersonTX
Contributor
Contributor

Thanks for the info!  I am not very good with Powershell and the vSphere power CLI so I am having some problems getting this to run.  Any tips on how I would use this command in a script or do you know of any scripts already created for this?


Thanks again,

PersonTX

0 Kudos
RvdNieuwendijk
Leadership
Leadership

To be able to run a PowerCLI script you first have to make a connection to a vCenter server or an ESX server with the Connect-VIServer cmdlet. E.g.

Connect-VIServer -Server "vCenterServer"

After you made the connection you can run my script or another PowerCLI script.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
PersonTX
Contributor
Contributor

Thanks.  I tried that and I was getting a connection to the ESXi server and/or the vCenter server.  Then when I run the script it just sits there and does not return anything.  I know there are some open snaphots but it is not finding them.  I know I must be doing something wrong.

After I enter the below command is there anything else I need to do?

Get-ChildItem vmstores: -Recurse | `
Where-Object {$_.Name -like  "*.000001.vmdk" -or $_.Name -like  "*.000002.vmdk"}

Thanks,

PersonTX

0 Kudos
PersonTX
Contributor
Contributor

I see what I was doing wrong.   I needed to search for *000001.vmdk instead of *.000001.vmdk.  This did give me the list I was looking for.

Now onto trying to figure out how to get it to email to me.

Thanks again,

PersonTX

0 Kudos
RvdNieuwendijk
Leadership
Leadership

To e-mail the report you can do something like the following script. The e-mail part of this script is taken from Alan Renouf's vCheck script:

# Set the SMTP Server address
$SMTPSRV = "mysmtpserver.mydomain.local"
# Set the Email address to recieve from
$EmailFrom = "me@mydomain.local"
# Set the Email address to send the email to
$EmailTo = "me@mydomain.local"

function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) {
    $mailer = new-object Net.Mail.SMTPclient($smtpserver)
    $msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
    $msg.IsBodyHTML = $true
    $mailer.send($msg)
}

Connect-VIServer -Server "vCenterServer"

$MyReport = Get-ChildItem vmstores: -Recurse | `
Where-Object {$_.Name -like  "*000001.vmdk" -or $_.Name -like  "*000002.vmdk"} | `
ConvertTo-Html

send-SMTPmail $EmailTo $EmailFrom "Snapshot Report" $SMTPSRV $MyReport

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
oboloori
Contributor
Contributor

I've used Alan Renouf's vCheck script, but I like this one much better: http://blog.axiomdynamics.com/2010/03/powercli-script-for-snapshot-reporting.html

0 Kudos
PersonTX
Contributor
Contributor

I use that one right now and it is a nice report but it is my understanding that it asks vCenter for open snapshots.  I am more worried about snapshots vCenter does not know about.


Does that one actually search for delta files?


Thanks,

PersonTX

0 Kudos
PersonTX
Contributor
Contributor

Thank you very much!  This is exactly what I was looking for.

0 Kudos