What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

VMware snapshots

Votes:

0

Your Vote:

Up

Down

Are there plans for being able to monitor snapshots in VMware? I've created a custom SSH sensor to achieve this with powershell and plink, however it is resource intensive.

custom-script-exe custom-sensor snapshot ssh vmware

Created on Dec 9, 2011 10:14:55 PM by  RandyB (0) 1

Last change on Mar 19, 2015 3:46:37 PM by  Martina Wittmann [Paessler Support]



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

I am doing just that with prtg.

Install the VMware Infrastructure (VI) Toolkit on Your probes.

Enable powershell script on probe.

Create this custom xml powershell script. Place it on Your probes and central server.

Do remember to call it with parameters like in the following decription.

And set timeout higher than 100 sec. it's a slow mofo depending on the size of Your Vmware farm offcourse :)

#---------------------------------------------------------------------------------------------
# Get the number of VM snapshots on ESX host or vCenter
#
# This script requires the installation of the VMware Infrastructure (VI) Toolkit for Windows.
# 
# Args[0]:Server
# Args[1]:Protocol (HTTP/HTTPS)
# Args[2]:User
# Args[3]:Password
# Args[4]:Location (VI container(s), e.g. folders, datacenters, clusters). 
#		  Enclose in ' ' if location name contains spaces.
# Args[5]:VM power state (PoweredOn, PoweredOff, * for all)
#
# Example 1: Snapshot count for single DRS cluster, only powered-on VMs
# 10.23.112.235 https Administrator pass01 'My DRS Cluster' 'PoweredOn'
#
# Example 2: multiple datacenters, all VMs
# 10.23.112.235 https Administrator pass01 'My Data Center 1','My Data Center 2' '*'
# 
#---------------------------------------------------------------------------------------------


Add-PSSnapin VMWare.VIMAutomation.core >$Null

$global:textvar = ""

$server=Connect-VIServer -Server $Args[0] -Protocol $Args[1] -User $Args[2] -Password $Args[3]>$Null
$powerstate = [string]$Args[5]
$snapshot_count = 0

Get-VM -Location $Args[4] -Server $server | Get-Snapshot | `
ForEach-Object {
	$snapshot_count = $snapshot_count+1
}


function get-snaps{
    $vms = get-vm | sort name
    $vmsnaps = @()
    foreach($vm in $vms){
    	$snap = Get-Snapshot $vm
    	if($snap){
		  $vmsnaps += $vm
		  $snapshots = Get-Snapshot $vm
		  foreach ($snapshot in $snapshots){
          $global:textvar += $vm 
		  $global:textvar += "("
          $global:textvar += $snapshot.name
		  $global:textvar += "," 
		  $global:textvar += ([math]::Round($snapshot.sizemb/1024,2))
		  $global:textvar += ")"
		  $global:textvar += " - "

		}
    	}
    }
}
 
get-snaps


$x=[string]$snapshot_count+":"+$global:textvar

#write-host "$snapshot_count"

if($snapshot_count -ne 0){

write-host "<prtg>"
write-host "<error>"
write-host "1"
write-host "</error>"
write-host "<text>"
write-host $global:textvar
write-host "</text>"
write-host "</prtg>"


}

if($snapshot_count -eq 0){

write-host "<prtg>"
write-host "<result>"
write-host "<channel>Snapshots running</channel>"
write-host "<value>"
write-host $snapshot_count
write-host "</value>"
write-host "<LimitMaxError>0</LimitMaxError>"
write-host "<LimitMode>1</LimitMode>"
write-host "</result>"
write-host "</prtg>"


}

Created on Jan 25, 2013 4:35:10 PM by  klask (50) 1

Last change on Jan 28, 2013 1:38:38 PM by  Torsten Lindner [Paessler Support]



12 Replies

Votes:

0

Your Vote:

Up

Down

Hello,

I'm afraid currently there are no plans to have such sensors, sorry.

best regards.

Created on Dec 12, 2011 2:15:27 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Now we're a year further on, I was just wondering if there are any plans to be able to monitor VMware virtual machine snapshots?

It would be really helpful to be able to monitor the number and age of VM snapshots.

Many thanks Paul

Created on Nov 9, 2012 11:28:54 AM by  Paul Huxham (0) 1



Votes:

0

Your Vote:

Up

Down

I'm afraid still only on the wish-list. Sorry.

Created on Nov 9, 2012 4:27:44 PM by  Torsten Lindner [Paessler Support]



Accepted Answer

Votes:

0

Your Vote:

Up

Down

I am doing just that with prtg.

Install the VMware Infrastructure (VI) Toolkit on Your probes.

Enable powershell script on probe.

Create this custom xml powershell script. Place it on Your probes and central server.

Do remember to call it with parameters like in the following decription.

And set timeout higher than 100 sec. it's a slow mofo depending on the size of Your Vmware farm offcourse :)

#---------------------------------------------------------------------------------------------
# Get the number of VM snapshots on ESX host or vCenter
#
# This script requires the installation of the VMware Infrastructure (VI) Toolkit for Windows.
# 
# Args[0]:Server
# Args[1]:Protocol (HTTP/HTTPS)
# Args[2]:User
# Args[3]:Password
# Args[4]:Location (VI container(s), e.g. folders, datacenters, clusters). 
#		  Enclose in ' ' if location name contains spaces.
# Args[5]:VM power state (PoweredOn, PoweredOff, * for all)
#
# Example 1: Snapshot count for single DRS cluster, only powered-on VMs
# 10.23.112.235 https Administrator pass01 'My DRS Cluster' 'PoweredOn'
#
# Example 2: multiple datacenters, all VMs
# 10.23.112.235 https Administrator pass01 'My Data Center 1','My Data Center 2' '*'
# 
#---------------------------------------------------------------------------------------------


Add-PSSnapin VMWare.VIMAutomation.core >$Null

$global:textvar = ""

$server=Connect-VIServer -Server $Args[0] -Protocol $Args[1] -User $Args[2] -Password $Args[3]>$Null
$powerstate = [string]$Args[5]
$snapshot_count = 0

Get-VM -Location $Args[4] -Server $server | Get-Snapshot | `
ForEach-Object {
	$snapshot_count = $snapshot_count+1
}


function get-snaps{
    $vms = get-vm | sort name
    $vmsnaps = @()
    foreach($vm in $vms){
    	$snap = Get-Snapshot $vm
    	if($snap){
		  $vmsnaps += $vm
		  $snapshots = Get-Snapshot $vm
		  foreach ($snapshot in $snapshots){
          $global:textvar += $vm 
		  $global:textvar += "("
          $global:textvar += $snapshot.name
		  $global:textvar += "," 
		  $global:textvar += ([math]::Round($snapshot.sizemb/1024,2))
		  $global:textvar += ")"
		  $global:textvar += " - "

		}
    	}
    }
}
 
get-snaps


$x=[string]$snapshot_count+":"+$global:textvar

#write-host "$snapshot_count"

if($snapshot_count -ne 0){

write-host "<prtg>"
write-host "<error>"
write-host "1"
write-host "</error>"
write-host "<text>"
write-host $global:textvar
write-host "</text>"
write-host "</prtg>"


}

if($snapshot_count -eq 0){

write-host "<prtg>"
write-host "<result>"
write-host "<channel>Snapshots running</channel>"
write-host "<value>"
write-host $snapshot_count
write-host "</value>"
write-host "<LimitMaxError>0</LimitMaxError>"
write-host "<LimitMode>1</LimitMode>"
write-host "</result>"
write-host "</prtg>"


}

Created on Jan 25, 2013 4:35:10 PM by  klask (50) 1

Last change on Jan 28, 2013 1:38:38 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hello

I'm getting following error in prtg with your powershell script:

Error reading response: XML Parser mismatch: Wanted </<<<>, got </prtg>

can you help me?

Many thanks Jussi Lenzi

Created on Jun 21, 2013 9:53:51 AM by  Jussi Lenzi (0)



Votes:

0

Your Vote:

Up

Down

Hi, if the check runs into an error, let the output write to disk and analyze the logfile. Mostly there are powershell errors in this logfile.

Regards SML

Created on Apr 14, 2014 10:51:54 AM by  SMLunchen (0)



Votes:

0

Your Vote:

Up

Down

Any news on this one? We recently had a couple of issues with Orphaned snapshots which cost total server outage.

Would be good to be able to monitor this!

Created on Oct 13, 2015 10:05:14 AM by  YachtCloud (120) 1 2



Votes:

0

Your Vote:

Up

Down

Hi YachtCloud,

Did you try the provided script by klask? Next to this, it's still on the wish list and you will need to write your own Custom Sensor for the moment, sorry.

Best regards, Felix

Created on Oct 14, 2015 9:23:45 AM by  Felix Saure [Paessler Support]

Last change on Jul 24, 2018 7:36:59 AM by  Brandy Greger [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I am using the above script which I note has a parameter $powerstate but this does not appear to be called anywhere and I only want to monitor powered on VMs.

Any help would be appreciated.

Created on May 13, 2020 6:46:34 PM by  ColinS (0)



Votes:

0

Your Vote:

Up

Down

I put this script in the exe folder. I added a sensor and selected it from the drop down. I haleft the credentials as inherited. I loaded all the VMWARE VIBs. This is the error I get.

Any help is appreciated.

Sensor VMWARE SNAPSHOT

Response not well-formed: "(Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5. At E:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\PRTG-VMware_Snapshot.ps1:23 char:1 + Add-PSSnapin VMWare.VIMAutomation.core >$Null + 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo : InvalidArgument: (VMWare.VIMAutomation.core:String) [Add-PSSnapin], PSArgumentException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand WARNING: Please consider joining the VMware Customer Experience Improvement Program, so you can help us make PowerCLI a better product. You can join using the following command: Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true VMware's Customer Experience Improvement Program ("CEIP") provides VMware with information that enables VMware to improve its products and services, to fix problems, and to advise you on how best to deploy and use our products. As part of the CEIP, VMware collects technical information about your organizationâ?Ts use of VMware products and services on a regular basis in association with your organizationâ?Ts VMware license key(s). This information does not personally identify any individual. For more details: type "help about_ceip" to see the related help article. To disable this warning and set your preference use the following command and restart PowerShell: Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true or $false. Connect-VIServer : Cannot validate argument on parameter 'Server'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At E:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\PRTG-VMware_Snapshot.ps1:27 char:34 + $server=Connect-VIServer -Server $Args[0] -Protocol $Args[1] -User $A ... + 
~~~~~~~~
 + CategoryInfo : InvalidData: (:) [Connect-VIServer], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIS erver Get-VM : 9/9/2021 2:23:37 PMGet-VMYou are not currently connected to any servers. Please connect first using a Connect cmdlet. At E:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\PRTG-VMware_Snapshot.ps1:31 char:1 + Get-VM -Location $Args[4] -Server $server | Get-Snapshot | ` + 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo : ResourceUnavailable: (:) [Get-VM], ViServerConnectionException + FullyQualifiedErrorId : Core_BaseCmdlet_NotConnectedError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM get-vm : 9/9/2021 2:23:37 PMGet-VMYou are not currently connected to any servers. Please connect first using a Connect cmdlet. At E:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\PRTG-VMware_Snapshot.ps1:38 char:12 + $vms = get-vm | sort name + 
~~~~~~ 
+ CategoryInfo : ResourceUnavailable: (:) [Get-VM], ViServerConnectionException + FullyQualifiedErrorId : Core_BaseCmdlet_NotConnectedError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM <prtg> <result> <channel>Snapshots running</channel> <value> 0 </value> <LimitMaxError>0</LimitMaxError> <LimitMode>1</LimitMode> </result> </prtg> )" (code: PE132)

Created on Sep 9, 2021 6:27:10 PM by  AGOLDMINTEK (0)

Last change on Sep 10, 2021 12:59:57 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi AGoldMintek,

By default, PRTG runs below the System user account, which might not be allowed to interact with the SnapIn like your user does.

RDP on the machine from which you want to run the script, open services.msc and change the LogOn User for the PRTG Probe Service to a user with sufficient access rights. Restart the PRTG services and see if they can be loaded correctly afterwards.

If not, also ensure that the Plugins are loaded for the x86 PowerShell, since the Probe of PRTG is a 32bit application.


Kind regards,
Felix Saure, Tech Support Team

Created on Sep 13, 2021 5:54:09 AM by  Felix Saure [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Created on Nov 21, 2021 10:56:27 PM by  Jannos (0)



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.