Skip to main content
Question

EA for CrashPlan PROe (the 'e' matters...)

  • November 13, 2012
  • 36 replies
  • 110 views

Show first post

36 replies

Forum|alt.badge.img+13
  • Valued Contributor
  • December 4, 2013

Yeah that's not how it's supposed to look...
Have you tried a different GUID? Maybe that one has never backed up.
Otherwise maybe have codefortytwo look into it?


Forum|alt.badge.img+11
  • Contributor
  • December 4, 2013

Mystery solved: turns out that CrashPlan can store a computer's .identity file in two different places, with our custom installer defaulting not to /Library/Application Support/CrashPlan/.identity, but rather ~/Library/Application Support/CrashPlan/.identity.

Reference:
http://support.code42.com/CrashPlan/Latest/Configuring/Computer_Identities_How_They_Work

Making matters worse, my test machine (having gone through multiple installs over our beta rollout) actually had .identity files in both places - so while the EA was reporting on the one in the /Library, the correct Computer ID file was resting in ~/Library. Nice!

So here's an updated EA script I put together that looks first in the /Library location, then falls back to ~/Library if there's nothing found there:

if [ "$CP_ServerAddress" == "" ] || [ "$CP_AdminUsername" == "" ] || [ "$CP_AdminPassword" == "" ];then
        echo "<result>Please ensure all variables are set in the extension attribute script.</result>"
elif [ -f /Library/Application Support/CrashPlan/.identity ] || [ -f ~/Library/Application Support/CrashPlan/.identity ];then
        SERVER=`echo $CP_ServerAddress | sed 's|/$||'`
        GUID=`cat /Library/Application Support/CrashPlan/.identity | sed -n  's/guid=//p'`
        if [ "$GUID" == "" ];then
            GUID=`cat ~/Library/Application Support/CrashPlan/.identity | sed -n 's/guid=//p'`
        fi        
        DATA=`curl -q -u "$CP_AdminUsername:$CP_AdminPassword" -k "$SERVER/api/Computer?guid=$GUID&incBackupUsage=1" | sed -n 's/.*percentComplete":([^,]*).*/1/p'`

        echo "<result>$DATA</result>" 
else
        echo "<result>Not installed</result>"
fi

Forum|alt.badge.img
  • New Contributor
  • July 28, 2015

Has anyone made any further discoveries?


Forum|alt.badge.img+14
  • Valued Contributor
  • May 10, 2016

I discovered that http://server.address.goes.here/api/computer?guid=$guid is deprecated, it is now: http://server.address.goes.here/api/Computer/$GUID?idType=guid

What I don't understand at all is the sed awk part or processing the json that it spits out.


Forum|alt.badge.img+14
  • Valued Contributor
  • May 10, 2016

curl -q -s -u user:pass -k "http://my.crashplan.server:port/api/Computer/$GUID?idType=guid" | python -m json.tool | grep -w status

returns

"status": "Active",

getting closer. Not sure where I got the flags from but one of them was to get rid of the status bar thingy. The API Doc viewer recommends curl -X GET, haven't tried that yet.


stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • May 10, 2016

@djdavetrouble I'm still able to get these EAs to complete with the deprecated method you mentioned, and even switching over to the new method, they still work. I'm using the following for each one:

Last Connected

#!/bin/sh
# Modified 1/24/13
# Third-Part Product page for CrashPlan PROe - https://jamfnation.jamfsoftware.com/viewProduct.html?id=217

CP_ServerAddress="https://yourcppeserver:4285"
CP_AdminUsername="cppadmin"
CP_AdminPassword='cpppassword'

if [ "$CP_ServerAddress" == "" ] || [ "$CP_AdminUsername" == "" ] || [ "$CP_AdminPassword" == "" ];then
        echo "<result>Please ensure all variables are set in the extension attribute script.</result>"
elif [ -f /Library/Application Support/CrashPlan/.identity ];then
        SERVER=`echo $CP_ServerAddress | sed 's|/$||'`
        GUID=`cat /Library/Application Support/CrashPlan/.identity | sed -n 's/guid=//p'`

        DATA=`curl -q -u ${CP_AdminUsername}:${CP_AdminPassword} -k "$SERVER/api/Computer/$GUID?idType=guid&incBackupUsage=1" | sed -n 's/.*lastConnected":"([^"]*).*/1/p'`        

        FORMATTED=`date -j -f "%Y-%m-%dT%H:%M:%S" "$DATA" "+%Y-%m-%d %H:%M:%S"`
        echo "<result>$FORMATTED</result>"
else
        echo "<result>Not installed</result>"
fi

Last Backup

#!/bin/sh
# Modified 1/24/13
# Third-Part Product page for CrashPlan PROe - https://jamfnation.jamfsoftware.com/viewProduct.html?id=217

CP_ServerAddress="https://yourcppeserver:4285"
CP_AdminUsername="cppadmin"
CP_AdminPassword='cpppassword'

if [ "$CP_ServerAddress" == "" ] || [ "$CP_AdminUsername" == "" ] || [ "$CP_AdminPassword" == "" ];then
        echo "<result>Please ensure all variables are set in the extension attribute script.</result>"
elif [ -f /Library/Application Support/CrashPlan/.identity ];then
        SERVER=`echo $CP_ServerAddress | sed 's|/$||'`
        GUID=`cat /Library/Application Support/CrashPlan/.identity | sed -n 's/guid=//p'`

        DATA=`curl -q -u ${CP_AdminUsername}:${CP_AdminPassword} -k "$SERVER/api/Computer/$GUID?idType=guid&incBackupUsage=1" | sed -n 's/.*lastBackup":"([^"]*).*/1/p'`        

        FORMATTED=`date -j -f "%Y-%m-%dT%H:%M:%S" "$DATA" "+%Y-%m-%d %H:%M:%S"`
        echo "<result>$FORMATTED</result>"
else
        echo "<result>Not installed</result>"
fi

Status

#!/bin/sh
# Modified 1/24/13
# Third-Part Product page for CrashPlan PROe - https://jamfnation.jamfsoftware.com/viewProduct.html?id=217
CP_ServerAddress="https://yourcppeserver:4285"
CP_AdminUsername="cppadmin"
CP_AdminPassword='cpppassword'

if [ "$CP_ServerAddress" == "" ] || [ "$CP_AdminUsername" == "" ] || [ "$CP_AdminPassword" == "" ];then
        echo "<result>Please ensure all variables are set in the extension attribute script.</result>"
elif [ -f /Library/Application Support/CrashPlan/.identity ];then
        SERVER=`echo $CP_ServerAddress | sed 's|/$||'`
        GUID=`cat /Library/Application Support/CrashPlan/.identity | sed -n 's/guid=//p'`

        DATA=`curl -q -u ${CP_AdminUsername}:${CP_AdminPassword} -k "$SERVER/api/Computer/$GUID?idType=guid" | sed -n 's/.*status":"([^"]*).*/1/p'`

        echo "<result>$DATA</result>"
else
        echo "<result>Not installed</result>"
fi

I just tested all three of these and they appear to be working correctly.


Forum|alt.badge.img+14
  • Valued Contributor
  • May 11, 2016

Thanks Steve, are you running the latest server version? I inherited the EAs, and figured I'd poke into the API and see what changed. I have a working curl that uses the new syntax, and am going to work it into an EA tomorrow.


stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • May 11, 2016

@djdavetrouble We are running version 5.1.2.


Forum|alt.badge.img+14
  • Valued Contributor
  • May 11, 2016

here is the working curl with the new API syntax

sudo curl -X GET -s -u api_user:password -k "http://my.crashplan.server:port/api/Computer/$GUID?idType=guid" | python -m json.tool | grep -w status | awk '{print $2}' | sed -e 's/^"//g' | sed -e 's/",$//g'

I tried using the less frowned upon python -c json.load but kept getting errors so gave up and did this instead.

This returns the string "Active"


Forum|alt.badge.img+14
  • Valued Contributor
  • May 11, 2016

We are using 5.2.0 and the old ones are not working for me, in particular, the Computer call does not have information on last connected or percentage complete.


Forum|alt.badge.img+14
  • Valued Contributor
  • May 23, 2016