<ProbeActionModuleType ID="HP.DataProtector.PA.ClientGroup.Status.Provider" Accessibility="Public" Batching="false" PassThrough="false">
<Configuration>
<xsd:element minOccurs="1" name="ComputerName" type="xsd:string"/>
<xsd:element minOccurs="1" name="WarningThreshold" type="xsd:integer"/>
<xsd:element minOccurs="1" name="ErrorThreshold" type="xsd:integer"/>
<xsd:element minOccurs="0" name="AcceptFaultyBackups" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="WarningThreshold" Selector="$Config/WarningThreshold$" ParameterType="int"/>
<OverrideableParameter ID="ErrorThreshold" Selector="$Config/ErrorThreshold$" ParameterType="int"/>
<OverrideableParameter ID="AcceptFaultyBackups" Selector="$Config/AcceptFaultyBackups$" ParameterType="bool"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>MPDPClientGroupStatusProvider.js</ScriptName>
<Arguments>$Config/ComputerName$ $Config/WarningThreshold$ $Config/ErrorThreshold$ $Config/AcceptFaultyBackups$</Arguments>
<ScriptBody><Script>/* ============================================================================
|
| Copyright (c) 2013 ComTrade d.o.o. All rights reserved.
|
| Possession of this software does not grant any rights to use, reproduce,
| modify or distribute it or to use any concept it may contain.
|
| Licensed under ComTrade d.o.o. license ("the License"); you may not use
| this software unless in compliance with the License. Any use of the software
| without such license is a violation of copyright laws and may be subject to
| legal actions (remedies and/or criminal prosecution).
|
| NOTE:
| If you receive this content in error, please let us know by contacting
| ComTrade d.o.o. legal department ([email protected]) and destroy any
| copy you may have.
|
+=============================================================================*/
// Debug info.
oAPI.LogScriptEvent("MPDPClientGroupStatusProvider.js", 201, 0, "Running health check on target " + TargetComputer);
var dataFound = false;
var utility = new MPDPUtility();
//check if MPDP agent is installed on node!
var MPDPInstalled = false;
agtPath = utility.readFromRegistry(utility.agentPathRegistryKey, "");
if (agtPath.length > 0) {
MPDPInstalled = true;
}
try {
var currentDT = new Date();
var discoveryTag = xmlDoc.getElementsByTagName("discovery")[0];
var validDiscoveryDate = parseDate(discoveryTag.getAttribute("valid"));
// TODO Enable time validity check !!
/*
if(currentDT.getTime() > validDiscoveryDate.getTime()) // old xml, service not running
{
returnDummyPB();
WScript.Quit(0);
}
*/
} catch (e) { }
var cell_node, cellserver_node, bLicensed;
bLicensed = false;
var vFaultyClients = 0;
var vOKClients = 0;
var vTotalClients = 0;
var vFolderStatus = "Good";
// Prep the search array
var aAcceptableBackupStates = new Array();
aAcceptableBackupStates.push("Completed");
if (sAcceptFaultyBackups) {
aAcceptableBackupStates.push("Completed/Errors");
}
cell_node = xmlDoc.getElementsByTagName("cell")[0];
if (typeof (cell_node) != "undefined" && cell_node != null) {
cellserver_node = cell_node.getElementsByTagName("cellserver")[0];
if (typeof (cellserver_node) != "undefined" && cellserver_node != null) {
var v_cellName = cellserver_node.getAttribute("hostname");
var clients_node, cf_nodes, cf_node;
clients_node = cell_node.getElementsByTagName("clients")[0];
if (typeof (clients_node) != "undefined" && clients_node != null) {
cf_nodes = clients_node.childNodes;
while (cf_node = cf_nodes.nextNode()){
if (cf_node.nodeName == "client") {
for (var i = 0; i < aAcceptableBackupStates.length; i++) {
if (aAcceptableBackupStates[i] === cf_node.getAttribute("status")) {
vOKClients++;
break;
}
}
vTotalClients++;
}
}
}
}
vFaultyClients = vTotalClients - vOKClients;
if (vTotalClients > 0) {
var vFaultyPerc = 100 * vFaultyClients / vTotalClients;
// lock data file and load the content
var fs = WScript.CreateObject("Scripting.FileSystemObject");
var fileLock,
lockFileName;
var repeatCount = 100; // the number of tries for retreiving the lock
lockFileName = agtPath + "\\" + this.dataFileLock;
do {
try {
fileLock = fs.OpenTextFile(lockFileName, 2, true);
break;
} catch (e) {
repeatCount--;
WScript.Sleep(100);
}
} while (repeatCount > 0);
if (repeatCount == 0) {
throw new Error("Could not acquire lock for reading MPDP MP data file '" + lockFileName + "'.");
}
if (!xmlDoc.load(datFilePath)) {
// before throwing exception close the lock
fileLock.Close();
throw new Error("Error loading MPDP MP data file '" + datFilePath + "'. Error code: " + xmlDoc.parseError.reason);
}
// afther we read the data file contnent we can unlock it
fileLock.Close();
// return the xml doc object
return xmlDoc;
}
this.getAgentPath = function () {
if (this.agentPath.length == 0) {
agtPath = this.readFromRegistry(this.agentPathRegistryKey, "");
if (agtPath.length <= 0) {
throw new Error("Cannot resolve MPDP Agent path. No registry key '" + this.agentPathRegistryKey + "'.");
}
this.agentPath = agtPath;
}