-
Notifications
You must be signed in to change notification settings - Fork 47
/
CrashPlan - Number of Files to Backup.xml
97 lines (88 loc) · 3.63 KB
/
CrashPlan - Number of Files to Backup.xml
1
<?xml version="1.0" encoding="UTF-8"?><extensionAttribute> <displayName>CrashPlan - Number of Files to Backup</displayName> <displayInCategory>Backup</displayInCategory> <description>This attribute displays the number of files CrashPlan is waiting to back up. This attribute applies to both Mac and Windows.</description> <dataType>integer</dataType> <scriptContentsMac>#!/bin/shCP_ServerAddress="EditFromTemplate_CrashPlan_Server_Name"CP_ServerPort="4285"CP_AdminUsername="EditFromTemplate_CrashPlan_Service_Account_Username"CP_AdminPassword="EditFromTemplate_CrashPlan_Service_Account_Password"if [ "$CP_ServerAddress" == "" ] || [ "$CP_ServerPort" == "" ] || [ "$CP_AdminUsername" == "" ] || [ "$CP_AdminPassword" == "" ];thenecho "<result>Please ensure all variables are set in the extension attribute script.</result>"elseif [ -f /Library/Application\ Support/CrashPlan/.identity ];then GUID=`/bin/cat /Library/Application\ Support/CrashPlan/.identity | grep guid | sed s/guid\=//g` echo "<result>`/usr/bin/curl -u "$CP_AdminUsername":"$CP_AdminPassword" -k https://"$CP_ServerAddress":"$CP_ServerPort"/rest/computerUsage?sourceGuid="$GUID" | grep -w todoFiles | awk '{print $2}' | sed s/,//g`</result>"else echo "<result>Not installed</result>"fifi </scriptContentsMac> <scriptTypeWindows>VBScript</scriptTypeWindows> <scriptContentsWindows>On Error Resume Next'Declaration of Objects, Constants, VariablesDim objFSODim objTextFileDim strTextFileDim objHTTPDim arrResultsDim strResultDim GUIDDim CP_ServerAddressDim CP_ServerPortDim CP_AdminUsernameDim CP_AdminPassword'Set VariablesCP_ServerAddress = "EditFromTemplate_CrashPlan_Server_Name"CP_ServerPort = "4285"CP_AdminUsername = "EditFromTemplate_CrashPlan_Service_Account_Username"CP_AdminPassword = "EditFromTemplate_CrashPlan_Service_Account_Password"'Validate Variables Have Been SetIf CP_ServerAddress = "" Or CP_ServerPort = "" Or CP_AdminUsername = "" Or CP_AdminPassword = "" ThenWScript.Echo "<result>Please ensure all variables are set in the extension attribute script.</result>"Else'Set ObjectsSet objFSO = CreateObject("Scripting.FileSystemObject")Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")'Set ConstantsConst WinHttpRequestOption_SslErrorIgnoreFlags = 4'Read in CrashPlan GUIDSet objTextFile = objFSO.OpenTextFile("C:\ProgramData\CrashPlan\.identity")strTextFile = objTextFile.ReadAllobjTextFile.ClosearrResults=Split(strTextFile, Chr(13))For i = 0 to ubound(arrResults) If inStr(arrResults(i), "guid") > 0 Then strResult = Replace(arrResults(i), "guid=", "") GUID = strResult strResult = "" Exit for End ifNextIf GUID = "" Then WScript.Echo "<result>Not installed</result>"Else 'Connect to the CrashPlan Pro Server Rest API objHTTP.open "GET", "https://" & CP_ServerAddress & ":" & CP_ServerPort & "/rest/computerUsage?sourceGuid=" & GUID & "", False objHTTP.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = &H3300 objHTTP.SetCredentials CP_AdminUsername, CP_AdminPassword, 0 objHTTP.send 'Parse the JSON Output arrResults=Split(objHTTP.ResponseText, ",") For i = 0 to ubound(arrResults) If inStr(arrResults(i), "todoFiles") > 0 Then strResult = Replace (arrResults(i), "todoFiles", "") strResult = Replace (strResult, ":", "") strResult = Replace (strResult, chr(10), "") strResult = Replace (strResult, chr(32), "") strResult = Replace (strResult, chr(34), "") Exit for End if Next WScript.Echo "<result>" & strResult & "</result>"End IfEnd If </scriptContentsWindows></extensionAttribute>