Disk Usage Smart Groups

robertliebsch
Contributor

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 18

DMH2000
Contributor

I would like to know also..

TAMU_MarComm
New Contributor

I would like this option as well

ccsshelpdesk
New Contributor III

me also, any news on this?

Kivo
New Contributor II

I created a custom Extension Attribute and then used a smart group with the EA as the criteria to monitor this. Hope this helps. Data_Drive___Used___and_dovik_—_-zsh_—_117×40_and_Notes.pngData_Drive___85__Full__.png

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

#!/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?

Screen Shot 2022-04-26 at 9.11.07 AM.pngScreen Shot 2022-04-26 at 9.11.28 AM.png

DMH2000
Contributor

Don't forget it is an Extension, not a script... also I used String and not integer in my setup as shown here:2022-04-26_10-15-13.png

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!

Screen Shot 2022-04-26 at 9.21.15 AM.png

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?Screen Shot 2022-04-26 at 9.36.59 AM.png

Screen Shot 2022-04-26 at 9.34.50 AM.png

Kivo
New Contributor II

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.

Kivo
New Contributor II

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.

dovik_—_-zsh_—_127×38.png

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. 

michaelhusar
Contributor II

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