Veeam Hyper-V VM Checkpoint Age and Size Probe Action Module

Veeam.Virt.Extensions.HyperV.Module.VMSnapshot.ScriptProbe (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
ScriptProbe ProbeAction Veeam.Virt.Extensions.ScriptProbe.PropertyBag Default

Source Code:

<ProbeActionModuleType ID="Veeam.Virt.Extensions.HyperV.Module.VMSnapshot.ScriptProbe" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="snapshotAge" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="snapshotSize" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="snapshotAgeThreshold" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="snapshotSizeThreshold" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="vmName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="hostName" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="ScriptProbe" TypeID="VVEVB!Veeam.Virt.Extensions.ScriptProbe.PropertyBag">
<ScriptName>VMSnapshotAgeSizeProbe.js</ScriptName>
<Arguments>$Config/snapshotAge$ $Config/snapshotSize$ $Config/snapshotAgeThreshold$ $Config/snapshotSizeThreshold$ "$Config/vmName$" $Config/hostName$</Arguments>
<ScriptBody><Script>//VMSnapshotAgeSizeProbe.js
var ARGUMENT_COUNT = 6;

if (WScript.Arguments.length != ARGUMENT_COUNT) {
WScript.Quit(0);
}

var snapshotAge = convertArg(WScript.Arguments(0));
var snapshotSize = convertArg(WScript.Arguments(1));
var snapshotAgeThreshold = convertArg(WScript.Arguments(2));
var snapshotSizeThreshold = convertArg(WScript.Arguments(3));
var vmName = WScript.Arguments(4);
var hostName = WScript.Arguments(5);

var momApi = new ActiveXObject("MOM.ScriptAPI");
var bag = momApi.CreatePropertyBag();


var msgTxt = "The virtual machine " + vmName + " running on host " + hostName + " is using Checkpoints.\r\n";
if (snapshotAge &gt;= snapshotAgeThreshold) {
msgTxt += "\r\nThe oldest checkpoint was taken " + snapshotAge + " hours ago. Possibly this checkpoint was left by an interrupted or failed image-level backup, or other process.\r\n";
}
if (snapshotSize &gt;= snapshotSizeThreshold) {
msgTxt += "\r\nThe total size (of all checkpoints) is " + snapshotSize + " GB. Large checkpoint files can rapidly fill up storage space. Large checkpoints also take a long time to commit when finally deleted.\r\n";
}

bag.AddValue("AlertDescription", msgTxt);
momApi.Return(bag);


function isNumber(n) {
return !isNaN(parseFloat(n)) &amp;&amp; isFinite(n);
}

function isInt(n) {
return n % 1 === 0;
}

function convertArg(a) {
var replaced = false;
if (a.indexOf(',') &gt; 0) {
var b = a.replace(',', '.');
replaced = true;
} else {
b = a;
}

if (isNumber(b)) {
if (!isInt(b)) {
b = Math.round(b * 100) / 100;
} else {
b = parseInt(b);
}
}

if (replaced) {
b = (b + "").replace('.', ',');
}

return b;
}</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="ScriptProbe"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>