Posted on 02-14-2014 07:35 AM
Does anyone have an extension attribute or some way to report the size of a cached package on all machines?
One of our larger packages is reporting as cached successfully on all our machine but when manually checking the size of the file it's way too small on a couple of the machines I've checked but ok on a few others. I would like to be able to create a smart group for all the computers that don't have the full cached file and resend the package out to those machines.
Any thoughts?
Solved! Go to Solution.
Posted on 02-14-2014 08:06 AM
Something like this should list all pkg or dmg files in the Waiting Room directory by dropping them into an array along with their human readable sizes.
You could then build a Smart Group with a Like operator and put in the term you expect as one of the results.
#!/bin/bash
pkgDir="/Library/Application Support/JAMF/Waiting Room"
while read item; do
size=$( du -hs "$pkgDir/$item" | awk '{print $1}' )
cachedSizes+=("$item $size
")
done < <(ls "$pkgDir/" | egrep ".pkg$|.dmg$")
echo -e "${cachedSizes[@]}"
I think there may be a feature request already to make the caching process more reliable in terms of realizing when a package has not actually successfully cached completely to a system. As it is right now, it is possible for it to think it completes, but in fact it hasn't. Partial cached packages still show up as valid files unfortunately, so the Smart Group looking for the cached package will still populate with systems that only have a partial download.
Posted on 02-14-2014 08:37 AM
Change this line:
echo -e "${cachedSizes[@]}"
To this:
echo -e "<result>${cachedSizes[@]}</result>"
Posted on 02-14-2014 08:06 AM
Something like this should list all pkg or dmg files in the Waiting Room directory by dropping them into an array along with their human readable sizes.
You could then build a Smart Group with a Like operator and put in the term you expect as one of the results.
#!/bin/bash
pkgDir="/Library/Application Support/JAMF/Waiting Room"
while read item; do
size=$( du -hs "$pkgDir/$item" | awk '{print $1}' )
cachedSizes+=("$item $size
")
done < <(ls "$pkgDir/" | egrep ".pkg$|.dmg$")
echo -e "${cachedSizes[@]}"
I think there may be a feature request already to make the caching process more reliable in terms of realizing when a package has not actually successfully cached completely to a system. As it is right now, it is possible for it to think it completes, but in fact it hasn't. Partial cached packages still show up as valid files unfortunately, so the Smart Group looking for the cached package will still populate with systems that only have a partial download.
Posted on 02-14-2014 08:19 AM
I think on version 9, the files are downloaded to "Downloads" in the JAMF directory and are not moved to the "Waiting Room" directory until it is finished downloading and matches the checksum.
Posted on 02-14-2014 08:21 AM
@denmoff - If that's true, that's a welcome change. I'll have to check on that on our dev version 9 setup. Thanks for mentioning that.
Posted on 02-14-2014 08:25 AM
I don't think that is the case (unless it changed with 9.23). With version 9 our files are caching directly to the waiting room.
Posted on 02-14-2014 08:35 AM
Mike if I run that script with sudo it works. I set it up as an extension attribute but it doesn't report anything. Any idea what I am doing wrong with the extension attribute? Does something need changed to make it run as sudo?
Posted on 02-14-2014 08:37 AM
Change this line:
echo -e "${cachedSizes[@]}"
To this:
echo -e "<result>${cachedSizes[@]}</result>"
Posted on 02-14-2014 08:40 AM
Are you adding the results to the end line?
Posted on 02-14-2014 08:45 AM
Yep, I forgot to add the <results> tags around the echo. Thanks for correcting that @stevewood
Posted on 02-14-2014 08:51 AM
Thanks for your help that is perfect.
Posted on 02-15-2014 04:39 PM
First, I have never seen cached .pkg policies in the downloads folder.
In my testing, what we should expect:
In the /Library/Application Support/JAMF/Waiting Room directory, upon completion of a .pkg cached upload, a pkg.cache.xml file is generated containing the pertinent information of the package. During my internal testing, this was true. That .xml was generated post receiving the package receipt and policy log stating that the .pkg was successfully DEPLOYED... not necessarily fully uploaded and cached. This corroberates the behavior I observed of the cached package not successfully being able to install/run right away, but after some time, it was able to successfully install and thus, run.
It is my interpretation that once the package receipt is received, the JSS is prompted to do an inventory submission for cached packages based on the content within that directory. The inherent issue here, is that the inventory submission is directed at the actual .pkg, NOT the .pkg.cache.xml which seems to accurately signify completion. It appears that the JSS (at least in this case) is recognizing the package as being cached prior to the pkg.cache.xml being generated.
We can visualize this if we replicate the environment / test (begin to cache a large .pkg) and do an inventory (sudo jamf recon) on the client machine in the middle of the .pkg download. The JSS will report the package as being cached as it sees the .pkg in the directory location, however, if we time this correctly, the .xml which signifies completeness will not have been generated yet.
So, full summary if I wasn't clear. In my testing, what I can tell you is that if I submit inventory upon receiving the package receipt and the policy log stating the package has been deployed successfully, that client falls into the smart group (criteria = having cached .pkg) but the installation of the cached package will fail. If you attempt the installation literally 20 ? 30 minutes later… it is successful.
Sounds like the logic is looking for the package (.pkg) and not necessarily the pkg.cache.xml.
Posted on 06-28-2016 06:32 PM
@mm2270 and @stevewood is there a way to return "NoCachedPackages" if the folder exists but is empty?
I added an if/else statement but not sure how to show NoCachedPackages
if /Library/Application Support/JAMF/Waiting Room
exists but is empty. Currently EA comes back empty.
#!/bin/bash
pkgDir="/Library/Application Support/JAMF/Waiting Room"
if [ -e "/Library/Application Support/JAMF/Waiting Room" ]; then
while read item; do
size=$( du -hs "$pkgDir/$item" | awk '{print $1}' )
cachedSizes+=("$item $size
")
done < <(ls "$pkgDir/" | egrep ".pkg$|.dmg$")
echo -e "<result>${cachedSizes[@]}</result>"
else
echo "<result>NoCachedPackages</result>"
fi
Posted on 06-28-2016 07:12 PM
@donmontalvo might be a cleaner way that @mm2270 knows of, or someone else, but here's what I hacked together real quick:
#!/bin/bash
pkgDir="/Library/Application Support/JAMF/Waiting Room"
if [[ -e ${pkgDir} ]]; then
folderSize=`du "${pkgDir}" | awk {'print $1'}`
if [[ $folderSize == 0 ]]; then
echo -e "<result>NoCachedPackages</result>"
else
while read item; do
size=$( du -hs "$pkgDir/$item" | awk '{print $1}' )
cachedSizes+=("$item $size
")
done < <(ls "$pkgDir/" | egrep ".pkg$|.dmg$")
echo -e "<result>${cachedSizes[@]}</result>"
fi
else
echo "<result>NoCachedPackages</result>"
fi
Posted on 06-28-2016 09:07 PM
@mm2270 and @stevewood I should start a beer company, I owe you guys so many!!! Works like a charm!
Tweaked to put sizes in parentheses.
#!/bin/bash
pkgDir="/Library/Application Support/JAMF/Waiting Room"
if [[ -e ${pkgDir} ]] ; then
folderSize=$( du "${pkgDir}" | awk '{print $1}' )
if [[ $folderSize == 0 ]]; then
echo -e "<result>NoCachedPackages</result>"
else
while read item; do
size=$( du -hs "$pkgDir/$item" | awk '{print $1}' )
cachedSizes+=("$item ($size)
")
done < <( ls "$pkgDir/" | egrep ".pkg$|.dmg$" )
echo -e "<result>${cachedSizes[@]}</result>"
fi
else
echo "<result>NoCachedPackages</result>"
fi