Posted on 12-05-2013 07:54 AM
Reaching out to see if anyone has any experience or success generating a report that tells what computers have successfully performed Home Syncing. In addition to knowing when a computer has checked in, we would like to know the last time it has successfully performed a Home Sync. I would love to be able to create a smart group but I am not sure how to go about it. I am thinking an Extension Attribute would need to be created but I am not sure where to start. Thought I would ask!
Posted on 12-05-2013 12:30 PM
That would be a very cool thing. Or an extension attribute that just says when the last sync occurred.
Posted on 01-20-2014 06:00 PM
I whipped up an extension attribute for it tonight. It shows the last successful home sync date/time of the most recently logged on user. The data type is date.
#!/bin/bash
# Get the last user to log on
lastUser=$(defaults read /Library/Preferences/com.apple.loginwindow lastUserName)
# Set file sync directory
fileSyncDir="/Users/$lastUser/.FileSync/"
# Return nothing if the .FileSync directory does not exist
if [ ! -d $fileSyncDir ]
then
echo "<result></result>"
exit
fi
# Change to the hidden home sync directory
cd $fileSyncDir
# Get the name of the home sync history file.
filename=$(ls | grep History)
# Return nothing if sync history file does not exist
if [ -z $filename ]
then
echo "<result></result>"
exit
fi
# Get the name of the history file without the extension. This is the latest plist entry.
baseName=$(echo $filename | perl -pe 's/..*$//;s{^.*/}{}')
# Get the last successful sync time from the history plist file.
lastsyncdateraw=$(/usr/libexec/PlistBuddy $filename -c "print $baseName:lastSuccessfulSyncTime")
# Format the date to Casper’s liking
casperHomeSyncDate=$(date -j -f "%a %b %d %T %Z %Y" "$lastsyncdateraw" "+%Y-%m-%d %H:%M:%S")
# Return the last successful home sync date in proper date form!
echo "<result>$casperHomeSyncDate</result>"
This could also be adapted to retrieve other info from that file: lastSuccessfulSyncTime = Fri Dec 20 09:52:05 EST 2013 initialSyncTime = Fri Nov 22 18:55:56 EST 2013 initialSyncInitiatorMACAddress = aaabbbccceee initialSyncSuccessful = false initialBytesSynced = 1311 initialSyncInitiatorHostname = hostname.local totalSyncDuration = 283168.656250 lastSyncInitiatorHostname = hostname.local totalSyncs = 2796 totalItemsSynced = 5450 initialItemsSynced = 3 initalSyncDuration = 833.722900 lastSyncTime = Mon Jan 20 08:53:41 EST 2014 lastSyncInitiatorMACAddress = aaabbbccceee totalBytesSynced = 60908607839