Skip to main content
Solved

Show Storage Disk Data Used %

  • February 21, 2023
  • 12 replies
  • 134 views

Forum|alt.badge.img+5

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

Best answer by sdagley

Exactly, I wanna see how much they use on the HDD and what's left in space


@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:

12 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • February 21, 2023

So.... you only want to know the percentage of space used in the Macintosh HD - Data volume?


mvu
Forum|alt.badge.img+20
  • Jamf Heroes
  • 963 replies
  • February 21, 2023

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


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 33 replies
  • February 21, 2023

So.... you only want to know the percentage of space used in the Macintosh HD - Data volume?


Exactly, I wanna see how much they use on the HDD and what's left in space


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 33 replies
  • February 21, 2023

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


Yes


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • February 21, 2023

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>"

 

 


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 33 replies
  • February 21, 2023

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>"

 

 


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)


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3567 replies
  • Answer
  • February 21, 2023

Exactly, I wanna see how much they use on the HDD and what's left in space


@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:


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • February 21, 2023

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)


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. 


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • February 21, 2023

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)


@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.


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 33 replies
  • February 21, 2023

@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.


Oh my! It was just that! Thank you, guys! Greatly appreciate ! Thanks for the script which can be useful too!


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • February 21, 2023

Oh my! It was just that! Thank you, guys! Greatly appreciate ! Thanks for the script which can be useful too!


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.


Forum|alt.badge.img+8
  • Valued Contributor
  • 107 replies
  • February 21, 2023

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