Monday, March 29, 2010

Monitoring Battery Status through the Terminal

We all monitor our batteries in laptops. Usually by watching a percentage symbol or fancy bar in the Menu Bar. Well, unless your on a desktop. These percentages or bar graphs give us some idea on how much time we have till we loose our digital friend. For most users, this is fine and dandy. For me, and I'm assuming some other geeks out there, it's not quite enough. I manage a few hundred laptops and finding out that someone's battery is on the fritz is never fun. If it's in warranty, no problem, just a free replacement. However, if it's "consumed" (the Apple approved term for "your battery is dead") we need to have funds allocated and parts ordered.

So how can we help manage or clients batteries more effective? Well, keep track of course! For batteries approaching a 300+ cycle count, I know to be aware that they are at the end of their life. If the Max Capacity of a battery is only 50% of its Designed Capacity, I know someone isn't happy with their battery life.

Introducing Battery Capacity Terminal Commands! Take these babies and make your own scripts, GUIs, reporting tools. Whatever you want, but please share what you can!

#Cycle Count
ioreg -l | grep Capacity | grep "Cycle Count"| cut -d, -f6 |sed -e s/\"//g | sed -e s/}//g
#Cycle Count Number Only
ioreg -l | grep Capacity | grep "Cycle Count"| cut -d, -f6 |sed -e s/\"Cycle\ Count\"=//g | sed -e s/}//g
#Max Capacity
ioreg -l | grep MaxCapacity | sed s/\"//g| awk '{print $3,$4,$5}'
#Max Capacity Number Only
ioreg -l | grep MaxCapacity | sed s/\"//g | awk '{print $5}'
#Current Capacity
ioreg -l | grep CurrentCapacity | sed s/\"//g| awk '{print $3,$4,$5}'
#Current Capacity Number Only
ioreg -l | grep CurrentCapacity | sed s/\"//g | awk '{print $5}'
##Design Capacity
ioreg -l | grep DesignCapacity | sed s/\"//g | awk '{print $3,$4,$5}'
#Design Capacity Number Only
ioreg -l | grep DesignCapacity | sed s/\"//g | awk '{print $5}'

Questions, Questions? I should buy a boat!
Rusty

No comments: