Reporting / Collecting Updated Battery Conditions

JB_ITS
New Contributor II

I have come across several MBPs in our environment where the battery was "failing" although they don't say that anymore. Some time ago Apple changed the battery condition status to things like:

- Replace Soon
- Replace Now
- Service Battery

The question is, how can I try to collect this information in the JSS? The Battery Health Status extension attribute doesn't look nor collect this type of information so it doesn't report correctly.

Is there a new extension attribute that will collect this information from our machines? Can we do this with a script?

In other words, is there a way to collect and report on these new statuses?

http://support.apple.com/kb/ht3782

8 REPLIES 8

sean
Valued Contributor

I don't have any duff batteries around me, but what happens when you type the following on one that does.

printf "get State:/IOKit/PowerSources/InternalBattery-0
d.show" | scutil

or

pmset -g batt

jacob_salmela
Contributor II

sean's method was something I have never seen before. But it seems it would work to make an Extension Attribute that reports the battery health.

#!/bin/bash
batteryHealth=$(printf "get State:/IOKit/PowerSources/InternalBattery-0
d.show" | scutil | awk '/BatteryHealth/ {print $3}')
echo "<result>$batteryHealth</result>"

daviddejong
New Contributor

Not sure if its ok to bump an old thread but the above Extension Attribute did not seem to work for me on 10.10 so I tinkered together this.

#!/bin/sh
batteryHealth=$(/usr/sbin/system_profiler -xml SPPowerDataType -detailLevel mini | grep -A 1 <key>sppower_battery_health</key>  | awk '/string/' | sed 's/.*<string>(.*)</string>.*/1/')
if [ "$batteryHealth" == "" ]; then
echo "<result>Not present</result>"
else
echo "<result>$batteryHealth</result>"
fi

benducklow
Contributor III

@daviddejong - Your script works great. Do you happen to know all the results possible? (or a way I can find that out) I didn't come up with anything out on the inter webs. As far as I know these are the results:

"Not Present", "Good", "Check Battery"

Is "Poor Permanent" one as well or was that replaced by other verbiage? Another other result possibilities?

gskibum
Contributor III

@benducklow I'm looking into this now too. I have found "Fair" can be added to the list.

benducklow
Contributor III

Cool. Thanks @gskibum. I haven't come across that one as a result (yet).

tcam
Contributor

@benducklow

I'm guessing it's the same as Yosemite.

OS X Yosemite: Battery conditions

OS X Yosemite: If your battery’s status is “Not Charging”

Normal
Replace Soon
Replace Now
Service Battery
Not Charging

AndreasRumpl
New Contributor III

This is the attribute that works nicely for us:

#!/bin/sh
#Determine model
model=`system_profiler SPHardwareDataType | grep "Model Name:" | cut -d ' ' -f 9`

if [[ "$model" =~ "Book" ]]; then

#Determine battery condition
result=`system_profiler SPPowerDataType | grep "Condition" | cut -d ':' -f 2 | sed -e 's/^[[:space:]]*//'`
    echo "<result>$result</result>"
else
    echo "<result>Not A MacBook</result>"
fi

Possible Values for Sierra:
Sierra Battery Status