Skip to main content
Question

Reporting / Collecting Updated Battery Conditions

  • March 20, 2014
  • 8 replies
  • 45 views

Forum|alt.badge.img+3

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

Forum|alt.badge.img+12
  • Contributor
  • March 21, 2014

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

Forum|alt.badge.img+13

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

Forum|alt.badge.img+1
  • New Contributor
  • April 2, 2015

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

Forum|alt.badge.img+17
  • Valued Contributor
  • February 5, 2016

@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
Forum|alt.badge.img+13
  • Valued Contributor
  • February 11, 2016

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


Forum|alt.badge.img+17
  • Valued Contributor
  • February 11, 2016

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


tcam
Forum|alt.badge.img+7
  • Contributor
  • March 15, 2016

@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


Forum|alt.badge.img+9
  • Contributor
  • August 24, 2017

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