Health Analyzer ModuleΒΆ
Comprehensive health analysis for computers managed by Jamf Pro.
Grading and ScoringΒΆ
Basic Python enumeration classes for health grade and health status.
Health GradeΒΆ
Health StatusΒΆ
Health Analyzer Data ModelsΒΆ
Pydantic data model configurations for Health Analyzer functionality.
Health ScoreΒΆ
Individual category score with details.
- class HealthScore(*, category: str, score: ~typing.Annotated[float, ~annotated_types.Ge(ge=0), ~annotated_types.Le(le=100)], max_score: ~typing.Annotated[float, ~annotated_types.Ge(ge=0), ~annotated_types.Le(le=100)], weight: ~typing.Annotated[float, ~annotated_types.Ge(ge=0), ~annotated_types.Le(le=1)], factors: list[str] = <factory>, recommendations: list[str] = <factory>)[source]ΒΆ
Bases:
BaseModelIndividual health metric score with details.
- Parameters:
- model_config: ClassVar[ConfigDict] = {}ΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Health ScorecardΒΆ
The complete health assessment result.
- class HealthScorecard(*, overall_score: ~typing.Annotated[float, ~annotated_types.Ge(ge=0), ~annotated_types.Le(le=100)], grade: ~jamfmcp.health_analyzer.HealthGrade, status: ~jamfmcp.health_analyzer.HealthStatus, security_score: ~jamfmcp.health_analyzer.HealthScore, system_health_score: ~jamfmcp.health_analyzer.HealthScore, compliance_score: ~jamfmcp.health_analyzer.HealthScore, maintenance_score: ~jamfmcp.health_analyzer.HealthScore, device_info: dict[str, ~typing.Any] = <factory>, assessment_timestamp: ~datetime.datetime = <factory>, critical_issues: list[str] = <factory>, recommendations: list[str] = <factory>)[source]ΒΆ
Bases:
BaseModelComplete computer health scorecard.
- Parameters:
overall_score (float)
grade (HealthGrade)
status (HealthStatus)
security_score (HealthScore)
system_health_score (HealthScore)
compliance_score (HealthScore)
maintenance_score (HealthScore)
assessment_timestamp (datetime)
- field grade: HealthGrade [Required]ΒΆ
Letter grade (A, B, C, D, F)
- field status: HealthStatus [Required]ΒΆ
Health status description
- field security_score: HealthScore [Required]ΒΆ
- field system_health_score: HealthScore [Required]ΒΆ
- field compliance_score: HealthScore [Required]ΒΆ
- field maintenance_score: HealthScore [Required]ΒΆ
- field assessment_timestamp: datetime [Optional]ΒΆ
- model_config: ClassVar[ConfigDict] = {}ΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Core ClassesΒΆ
HealthAnalyzerΒΆ
The main analyzer class that processes computer data and generates health scorecards.
- class HealthAnalyzer(diagnostic_data: dict[str, Any] | None = None, computer_history: dict[str, Any] | None = None, computer_inventory: dict[str, Any] | None = None, sofa_feed: SOFAFeed | None = None)[source]ΒΆ
Bases:
objectAnalyzes computer health from Jamf Pro diagnostic data.
This class processes comprehensive diagnostic information from Jamf Pro to generate detailed health scorecards with actionable recommendations.
- Parameters:
- Example:
>>> analyzer = HealthAnalyzer(diag_data, history_data, inventory_data) >>> scorecard = analyzer.generate_health_scorecard() >>> print(f"Overall Health: {scorecard.overall_score}%")
- __init__(diagnostic_data: dict[str, Any] | None = None, computer_history: dict[str, Any] | None = None, computer_inventory: dict[str, Any] | None = None, sofa_feed: SOFAFeed | None = None) None[source]ΒΆ
Initialize the health analyzer with optional diagnostic data and SOFA feed.
If diagnostic_data is not provided but computer_inventory is available, the diagnostic data will be automatically parsed from the inventory.
- Parameters:
diagnostic_data (dict[str, Any] | None) β Parsed diagnostic data from Jamf Pro (optional)
computer_history (dict[str, Any] | None) β Computer history data containing usage and policy logs
computer_inventory (dict[str, Any] | None) β Full computer inventory data
sofa_feed (SOFAFeed | None) β SOFA feed for CVE and OS currency analysis (optional)
- Return type:
None
- generate_health_scorecard() HealthScorecard[source]ΒΆ
Generate comprehensive health scorecard.
Analyzes all health categories and produces a detailed scorecard with overall health percentage, individual category scores, and actionable recommendations.
- Returns:
Complete HealthScorecard with scores and recommendations
- Return type:
- parse_diags(payload: dict[str, Any]) dict[str, str][source]ΒΆ
Parse comprehensive device diagnostics information from Jamf Pro payload.
Leverages the Computer model for structured data parsing and validation. Compiles a complete diagnostic report including general device information, hardware details, security status, user assignment, and security tool status.
- CATEGORY_WEIGHTS = {'compliance': 0.25, 'maintenance': 0.15, 'security': 0.35, 'system_health': 0.25}ΒΆ
- RECENT_CHECKIN_THRESHOLD = 24ΒΆ
- RECENT_ACTIVITY_THRESHOLD = 72ΒΆ
- ACCEPTABLE_UPTIME_MAX = 336ΒΆ
- async static load_sofa_feed() SOFAFeed | None[source]ΒΆ
Load the latest SOFA feed data for CVE and OS analysis.
- Returns:
Parsed SOFA feed or None if loading fails
- Return type:
SOFAFeed | None
- get_cve_analysis(include_detailed_cves: bool = False) dict[str, Any] | None[source]ΒΆ
Analyze CVE vulnerabilities affecting the current OS version.
- generate_health_scorecard() HealthScorecard[source]ΒΆ
Generate comprehensive health scorecard.
Analyzes all health categories and produces a detailed scorecard with overall health percentage, individual category scores, and actionable recommendations.
- Returns:
Complete HealthScorecard with scores and recommendations
- Return type:
- parse_diags(payload: dict[str, Any]) dict[str, str][source]ΒΆ
Parse comprehensive device diagnostics information from Jamf Pro payload.
Leverages the Computer model for structured data parsing and validation. Compiles a complete diagnostic report including general device information, hardware details, security status, user assignment, and security tool status.
Helper FunctionsΒΆ
Health Scoring SystemΒΆ
Category WeightsΒΆ
The analyzer evaluates computers across four weighted categories:
CATEGORY_WEIGHTS = {
"security": 0.35, # 35% - Security is critical
"system_health": 0.25, # 25% - System performance and hardware
"compliance": 0.25, # 25% - Policy and management compliance
"maintenance": 0.15, # 15% - Regular maintenance and updates
}
Security Score ComponentsΒΆ
Component |
Weight |
Description |
|---|---|---|
FileVault |
25% |
Disk encryption status |
SIP |
20% |
System Integrity Protection |
Gatekeeper |
15% |
App security verification |
Firewall |
15% |
Network protection |
CVEs |
25% |
Known vulnerabilities |
System Health ComponentsΒΆ
Component |
Weight |
Description |
|---|---|---|
Storage |
30% |
Available disk space |
Battery |
25% |
Battery health (laptops) |
Uptime |
20% |
System stability |
Hardware |
25% |
Component status |
Compliance ComponentsΒΆ
Component |
Weight |
Description |
|---|---|---|
Check-in |
40% |
Recent communication |
Policies |
30% |
Policy execution status |
Profiles |
30% |
Configuration compliance |
Maintenance ComponentsΒΆ
Component |
Weight |
Description |
|---|---|---|
OS Updates |
50% |
Operating system currency |
App Updates |
30% |
Application versions |
Certificates |
20% |
Certificate validity |
Recommendation EngineΒΆ
The analyzer generates actionable recommendations based on findings:
Security RecommendationsΒΆ
Enable FileVault encryption
Enable System Integrity Protection
Turn on Firewall
Update to patch CVEs
System Health RecommendationsΒΆ
Free up disk space
Replace aging battery
Restart to clear uptime
Address hardware issues
Compliance RecommendationsΒΆ
Configure regular check-ins
Fix failing policies
Deploy missing profiles
Maintenance RecommendationsΒΆ
Install OS updates
Update applications
Renew certificates