Posted on 02-21-2023 10:29 AM
Hello,
I'd like to show the Data Disk Used in percentage on an EA so that I can extract a report with all my computers and how much percentage of our users are using their disk drive. I just can't find it in EA templates and the boot percentage is not what I want. Thanks
Solved! Go to Solution.
Posted on 02-21-2023 11:33 AM
@Frank_Sonder With APFS "sharing" free space across all partitions in a container the free space on the Boot partition should actually be the same as on the Data partition. Note the data Jamf Pro reports for Storage on one of my test Macs:
Posted on 02-21-2023 11:52 AM
@sdagley's answer above is the correct answer. I was mistaken. Jamf shows the aggregated free space across all partitions in the container disk, so you should just create a report with "Boot Drive Available" as a column, and that should give you what you want, if that's indeed what you're after.
Posted on 02-21-2023 10:52 AM
So.... you only want to know the percentage of space used in the Macintosh HD - Data volume?
02-21-2023 11:07 AM - edited 02-21-2023 11:10 AM
Exactly, I wanna see how much they use on the HDD and what's left in space
Posted on 02-21-2023 11:33 AM
@Frank_Sonder With APFS "sharing" free space across all partitions in a container the free space on the Boot partition should actually be the same as on the Data partition. Note the data Jamf Pro reports for Storage on one of my test Macs:
Posted on 02-21-2023 10:57 AM
If you're trying to spit out a report, can you do this?
1. Computers
2. Search Inventory
3. New
4. Displays tab
5. Storage tab
6. Check off "Boot Drive Percentage Full"
7. Save
8. Download report
Posted on 02-21-2023 11:07 AM
Yes
Posted on 02-21-2023 11:16 AM
But you're saying in your original post that the Boot Percentage Full is not what you want. Because, it doesn't show the same value as the Data volume percentage? I haven't really paid attention to that, but I can believe that since the boot volume is not the one users write their data too anymore. So you'll need a custom EA to capure that. Unless you can use an API call to grab this info that shows in the computer details. I haven't checked that out.
I did whip this together just now. I think it should show you what you want, but you'll have to test it out.
#!/bin/zsh
## Determine Data volume ID
data_volume_id=$(/usr/sbin/diskutil list internal | /usr/bin/awk '/APFS/ && /- Data/{print $NF}')
## Get total and free disk space amount in bytes
data_volume_total=$(/usr/sbin/diskutil info $data_volume_id | /usr/bin/awk -F'[(|B]' '/Total Space/{print $3}')
data_volume_free=$(/usr/sbin/diskutil info $data_volume_id | /usr/bin/awk -F'[(|B]' '/Free Space/{print $3}')
## Calculate % of used space using the above values
data_volume_used=$(/bin/echo "scale=3; 100 - $data_volume_free / $data_volume_total * 100" | /usr/bin/bc)
## Print back result, trimming to one value past the decimal point
/bin/echo "<result>$(printf "%.1f\n" ${data_volume_used})%</result>"
Posted on 02-21-2023 11:26 AM
I think the boot percentage and data give me the wrong numbers... Sorry for the confusion... I think I just need to know what's available in space on the HDD (I'll do the percentage later on a sheet)
Posted on 02-21-2023 11:39 AM
Not sure I understand what you're after. You want the available space on the internal disk as a whole? Is that what you mean by the HDD? I'm not sure how easy that is to gather now with all the partitions the OS creates.
Posted on 02-21-2023 11:52 AM
@sdagley's answer above is the correct answer. I was mistaken. Jamf shows the aggregated free space across all partitions in the container disk, so you should just create a report with "Boot Drive Available" as a column, and that should give you what you want, if that's indeed what you're after.
Posted on 02-21-2023 12:36 PM
Oh my! It was just that! Thank you, guys! Greatly appreciate ! Thanks for the script which can be useful too!
Posted on 02-21-2023 01:05 PM
It's up to you, but I would give @sdagley the "answer" for this. I was just reiterating what he posted above.
Either way, glad that helped get you sorted out on this.
Posted on 02-21-2023 03:37 PM
if you still wan to go the EA route. this is what we use
#!/bin/sh
#https://www.jamf.com/jamf-nation/discussions/12546/boot-volume-free-space-ea
DU=$(df -h / | awk 'END{ print $(NF-4) }')
echo "<result>$DU</result>"
and this to drill down into user home folders
#!/bin/sh
LOGGEDIN=`ls -l /dev/console | awk '/ / { print $3 }'`
LARGEFILE=`sudo find /Users/$LOGGEDIN -type f -size +1G`
echo "<result>$LARGEFILE</result>"
as always test, test ,test before deployng to PROD