Posted on 02-08-2019 03:59 AM
I am trying to find a working extension attribute for space. Most interested in space left on drive in Megabytes - or maybe also the total capacity
Have found the following that I put into a EA - but don´t seem to work as nothing is rapported
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE extensionAttribute PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<extensionAttribute>
<displayName>Boot Volume Free Space</displayName>
<displayInCategory/>
<dataType>integer</dataType>
<description>Returns the free space on the current boot volume in GB, rounded down to the nearest integer.</description>
<scriptContentsMac>#!/bin/bash
free=`diskutil info /|grep "Free Space"|awk '{print $4}'`
echo "<result>"${free%.*}"</result>"</scriptContentsMac>
</extensionAttribute>
Do any has some working on this on Mojave?
Posted on 02-08-2019 04:11 AM
There is already a native Jamf inventory for “Boot Drive Available MB” and “Boot Drive Pecentage Full”. Would those work for you?
Posted on 02-08-2019 04:46 AM
Arh yes . I actually looked on the extension but looked at harddrive/volume where there was nothing
Posted on 02-08-2019 07:06 AM
Try this for the EA:
#!/bin/bash
echo "<result>$(diskutil info / | awk '/Free Space|Available Space/{print $4}')</result>"
The reason you're not getting any results is because, I think around 10.12, it changed from "Volume Free Space to "Volume Available Space"
The EA above should work on older OSes and current ones as it looks for either term.
I suggest saving it as an integer style EA, then you can use it to create Smart Groups using a greater than or less than modifier.
Posted on 03-22-2021 02:03 PM
I was able to get the following script to work for me but, I haven't been able to modify the script to make the unit(GB) show up after the free space amount is listed. Any help/ideal would be greatly appreciated!
echo "<result>$(diskutil info / | awk '/Free Space|Available Space/{print $4}')</result>"
Posted on 04-11-2021 04:27 PM
add the 5th column, it would be diskutil info / | awk '/Free Space|Available Space/{print $4,$5}'
07-25-2021 08:48 PM - edited 07-25-2021 08:49 PM
Going to give this a try and report back. Running Catalina and Big Sur. Curious about this... Specifically:
#!/bin/bash echo "<result>$(diskutil info / | awk '/Free Space|Available Space/{print $4,$5}')</result>"
Posted on 07-26-2021 03:57 PM
Hey @rcole
I ended up going with
#!/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>"
the following which works in Catalina and Big Sur. As always ..test,test,test