Skip to main content
Question

Disk Usage Smart Groups


Forum|alt.badge.img+5

With the changes to macOS in the last two versions. I'm wondering how people are monitoring disk utilization.

The Smart Group offering of Criteria "Boot Drive Percentage Full" isn't giving real results.

I show only 3 folks with over 67% full.

However, if I go to a computers: pick a machine and check its storage I see Data 250.68 GB 75% 58.46 GB Encrypted No

Is there a way to change from Boot to Data so I can figure out who is in peril of having a computer seize due to a full disk? or a system update that is going to fail? or a BigSur upgrade that is going to tank?

Right now I feel like without using another app like Kolide (osquery) I have no idea the health of my fleet.

18 replies

DMH2000
Forum|alt.badge.img+7
  • Valued Contributor
  • 76 replies
  • September 10, 2021

I would like to know also..


Forum|alt.badge.img+1
  • New Contributor
  • 2 replies
  • October 20, 2021

I would like this option as well


Forum|alt.badge.img+5

me also, any news on this?


Forum|alt.badge.img+3
  • New Contributor
  • 5 replies
  • April 8, 2022

I created a custom Extension Attribute and then used a smart group with the EA as the criteria to monitor this. Hope this helps. 


Forum|alt.badge.img+1
  • New Contributor
  • 5 replies
  • April 26, 2022
Kivo wrote:

I created a custom Extension Attribute and then used a smart group with the EA as the criteria to monitor this. Hope this helps. 


Would you be able to copy and paste that here? I don't know if I'm typing it wrong or what, but it doesn't seem to be working for me.

 

Thanks so much!


DMH2000
Forum|alt.badge.img+7
  • Valued Contributor
  • 76 replies
  • April 26, 2022
armstrongb wrote:

Would you be able to copy and paste that here? I don't know if I'm typing it wrong or what, but it doesn't seem to be working for me.

 

Thanks so much!


#!/bin/sh

used=`df -h /System/Volumes/Data/ | tail -n +2 | awk '{print $5}'`
echo "<result>"$used"</result>"


DMH2000
Forum|alt.badge.img+7
  • Valued Contributor
  • 76 replies
  • April 26, 2022
DMH2000 wrote:

#!/bin/sh

used=`df -h /System/Volumes/Data/ | tail -n +2 | awk '{print $5}'`
echo "<result>"$used"</result>"


#!/bin/sh

used=`df -h /System/Volumes/Data/ | tail -n +2 | awk '{print $5}'`
echo "<result>"$used"</result>"


Forum|alt.badge.img+1
  • New Contributor
  • 5 replies
  • April 26, 2022
DMH2000 wrote:

#!/bin/sh

used=`df -h /System/Volumes/Data/ | tail -n +2 | awk '{print $5}'`
echo "<result>"$used"</result>"


I'm still getting zero. Am I doing something else wrong here?


DMH2000
Forum|alt.badge.img+7
  • Valued Contributor
  • 76 replies
  • April 26, 2022

Don't forget it is an Extension, not a script... also I used String and not integer in my setup as shown here:


Forum|alt.badge.img+1
  • New Contributor
  • 5 replies
  • April 26, 2022
DMH2000 wrote:

Don't forget it is an Extension, not a script... also I used String and not integer in my setup as shown here:


I do believe I changed everything to the way you have it and it still doesn't seem to work. Please let me know if I'm just blind and not seeing it!


DMH2000
Forum|alt.badge.img+7
  • Valued Contributor
  • 76 replies
  • April 26, 2022
armstrongb wrote:

I do believe I changed everything to the way you have it and it still doesn't seem to work. Please let me know if I'm just blind and not seeing it!


Look under the computer's Inventory, Hardware. At the bottom you should see Extension Attributes, Data Disk Used.

You can also add a column for All Computers Search to show all computers at once.


Forum|alt.badge.img+1
  • New Contributor
  • 5 replies
  • April 26, 2022
DMH2000 wrote:

Look under the computer's Inventory, Hardware. At the bottom you should see Extension Attributes, Data Disk Used.

You can also add a column for All Computers Search to show all computers at once.


I added the column and it is empty. I also went back into the criteria for the smart group and it changed from "less than" or "more than" to "is". How would I get it back to the less and more than?


Forum|alt.badge.img+3
  • New Contributor
  • 5 replies
  • April 26, 2022
armstrongb wrote:

I added the column and it is empty. I also went back into the criteria for the smart group and it changed from "less than" or "more than" to "is". How would I get it back to the less and more than?


If you changed the data type in the Extension Attribute to string from integer that changes how you can interact with it in the smart group, that is why you now have "is" instead of the "less than" and "more than". 

I see that DMH2000 has set their extension attribute a bit differently then mine. If you would like to try mine out I have pasted it here:

#!/bin/sh

free=`df -m /System/Volumes/Data | awk '{getline; print $5}'| sed 's/%//'`

echo "<result>"${free}"</result>"

Additionally, Im not sure why you have the "less than" 80 in your smart group. I may just not understand what your aim for the smart group is but just setting the "more than" to 49 would be sufficient in showing the data drive being over full. I would suggest just for testing reasons set it up the same why that I have mine to see if it works then add additional criteria to the smart group. 

If you have any question about this please let me know, hope this is helpful for you. 

 


Forum|alt.badge.img+1
  • New Contributor
  • 5 replies
  • April 26, 2022
Kivo wrote:

If you changed the data type in the Extension Attribute to string from integer that changes how you can interact with it in the smart group, that is why you now have "is" instead of the "less than" and "more than". 

I see that DMH2000 has set their extension attribute a bit differently then mine. If you would like to try mine out I have pasted it here:

#!/bin/sh

free=`df -m /System/Volumes/Data | awk '{getline; print $5}'| sed 's/%//'`

echo "<result>"${free}"</result>"

Additionally, Im not sure why you have the "less than" 80 in your smart group. I may just not understand what your aim for the smart group is but just setting the "more than" to 49 would be sufficient in showing the data drive being over full. I would suggest just for testing reasons set it up the same why that I have mine to see if it works then add additional criteria to the smart group. 

If you have any question about this please let me know, hope this is helpful for you. 

 


The reason I have that is that I also have a smart group that is "Over 80% Capacity". We use that one for a couple of other specific things that need our attention.

 

I now updated this with your parameters and it is still coming back as zero.


Forum|alt.badge.img+3
  • New Contributor
  • 5 replies
  • April 26, 2022
armstrongb wrote:

The reason I have that is that I also have a smart group that is "Over 80% Capacity". We use that one for a couple of other specific things that need our attention.

 

I now updated this with your parameters and it is still coming back as zero.


You could test out the command in your terminal and change the smart group to reflect the output. So if you run the command and it says "17" then change the smart group to if "more than" 16. May be a good way to see if it's working.


Forum|alt.badge.img
  • New Contributor
  • 1 reply
  • November 30, 2022
armstrongb wrote:

The reason I have that is that I also have a smart group that is "Over 80% Capacity". We use that one for a couple of other specific things that need our attention.

 

I now updated this with your parameters and it is still coming back as zero.


I had this same issue. 
I was able to get the used percentage "67%" to display under the Hardware inventory of the laptop but the Smart Group was not populating. 

In my case, I had to drop the "%" from the script output since the Extension attribute is configured as an integer (number WITHOUT the % sign). 

I modified the script DMH2000  provided to the below.

 

#!/bin/sh used=`df -h /System/Volumes/Data/ | tail -n +2 | awk '{print $5}' | cut -c 1-2` echo "<result>"$used"</result>"

 

This is not perfect but works for me. 
If the drive gets to 100% then it will be detected as 10 but then again we would have bigger problems. 


Forum|alt.badge.img+8
  • Valued Contributor
  • 122 replies
  • March 15, 2023

Based on the previous code (thanx to everyone) we created an EA showing the actual free GBs

 

#!/bin/sh cap=`df -h /System/Volumes/Data/ | tail -n +2 | awk '{print $4}'` unit=$(echo "$cap" | awk '{print substr($0, length($0)-1, length($0))}') mod_cap=$(echo "$cap" | awk '{print substr($0, 1, length($0)-2)}') if [ "$unit" == "Ti" ] then mod_cap=$(echo "1000 * $mod_cap" | bc) fi echo "<result>"$mod_cap"</result>"

 

 


 


rstasel
Forum|alt.badge.img+13
  • Valued Contributor
  • 338 replies
  • November 14, 2023
michaelhusar wrote:

Based on the previous code (thanx to everyone) we created an EA showing the actual free GBs

 

#!/bin/sh cap=`df -h /System/Volumes/Data/ | tail -n +2 | awk '{print $4}'` unit=$(echo "$cap" | awk '{print substr($0, length($0)-1, length($0))}') mod_cap=$(echo "$cap" | awk '{print substr($0, 1, length($0)-2)}') if [ "$unit" == "Ti" ] then mod_cap=$(echo "1000 * $mod_cap" | bc) fi echo "<result>"$mod_cap"</result>"

 

 


 


@michaelhusar sadly this doesn't work as expected when free space is below 1GB, as you then start seeing larger numbers because it doesn't handle MB. =/ Not sure if just adding:

if [ "$unit" == "Mi" ]
then
mod_cap=$(echo "$mod_cap / 1000" | bc)
fi

Would resolve... 

 

Yes, altered to:

#!/bin/sh

cap=$(df -h /System/Volumes/Data/ | tail -n +2 | awk '{print $4}')
unit=$(echo "$cap" | awk '{print substr($0, length($0)-1, length($0))}')
mod_cap=$(echo "$cap" | awk '{print substr($0, 1, length($0)-2)}')
if [ "$unit" == "Ti" ]
then
mod_cap=$(echo "1000 * $mod_cap" | bc)
fi

if [ "$unit" == "Mi" ]
then
mod_cap=$(echo "scale=2; $mod_cap / 1000" | bc)
fi

echo "<result>"$mod_cap"</result>"

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings