Skip to content

Professional battery health monitoring for macOS via Jamf Pro Self Service

License

Notifications You must be signed in to change notification settings

SudoSunshine/battery-health-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Battery Health Check for Jamf Pro

Battery monitoring tool for macOS deployed via Jamf Pro Self Service.

Shell License Version Jamf Pro macOS


Features

  • Battery failure detection
  • Health condition (Normal/Replace Soon/Service Battery)
  • Cycle count vs. design limit
  • Battery age calculation (when available)
  • Current charge and power source
  • Optional inventory update
  • AppleCare coverage link on failure

Requirements

  • macOS 13.0+
  • Jamf Pro agent
  • MacBook/MacBook Air/MacBook Pro only

Installation

1. Upload Script

SettingsComputer ManagementScriptsNew

  • Name: Battery Health Check
  • Script: Paste contents of battery_health_check_v2.1.sh
  • Save

2. Create Policy

ComputersPoliciesNew

General:

  • Name: Check Battery Health
  • Trigger: None (Self Service only)
  • Frequency: Ongoing

Scripts:

  • Add: Battery Health Check
  • Priority: After

Self Service:

  • Make available in Self Service
  • Display Name: Check Battery Health
  • Description: View battery health including cycle count, charge status, and battery age
  • Category: Utilities

Configuration

Optional parameters for localization:

Parameter Purpose Example
$5 Coverage URL locale https://checkcoverage.apple.com/?locale=es_ES
$6 Battery icon path /path/to/icon.icns
$7 Coverage icon path /path/to/icon.icns

Performance

  • Execution: ~2 seconds
  • Data collection: 0.3 seconds (75% faster via single ioreg call)
  • Memory: <20MB

Troubleshooting

No battery detected
Expected on desktop Macs (iMac, Mac mini, Mac Pro)

Inventory update fails
Check internet connection and verify Jamf agent: /usr/local/bin/jamf

Data collection error
Restart Mac or reset SMC (Intel only)


Development

Testing:

bash -n battery_health_check_v2.1.sh  # Syntax check
sudo ./battery_health_check_v2.1.sh   # Run locally

Version history:
See CHANGELOG.md

Contributing:
Test on macOS 13+ before submitting PRs


Technical Details

Battery age calculation

Apple encodes manufacture date as: (year - 1980) × 512 + month × 32 + day

Example: June 15, 2020 = 20,687

Note: May not be available on some M-series Macs.

Exit codes
Code Meaning
0 Success
1 jamfHelper not found
2 No battery detected
3 Data collection failed

License

MIT - see LICENSE


Author

Ellie Romero
ellie@theecr.com


Support