Check Ninja Service Monitoring [Macintosh]
Overview
This script serves as the health check for the NinjaRMM self-healing solution on macOS. Its primary function is to verify that the background monitoring system (the LaunchDaemon and the watchdog script) is fully intact and operational.
When to use: This script is not designed to be run as a standalone automation. Instead, it is deployed as the Condition (evaluation script) within your NinjaRMM Agent Policies. If this script detects that the monitoring setup is missing or broken, it triggers the corresponding remediation script to fix it.
How it Works
When the script runs, it performs four quick validation checks:
- Script Presence: It verifies that the background monitoring script exists in the expected directory (
/Library/Application Support/NinjaSelfHeal/). - File Integrity: It checks the SHA-256 file hash of the monitoring script to ensure it hasn't been corrupted, altered, or deleted.
- Plist Registration: It verifies that the LaunchDaemon configuration file (
.plist) is present in/Library/LaunchDaemons/. - Daemon Status: It confirms that the watchdog daemon (
com.ninjarmm.EnsureNinjaServiceRunning) is actively loaded and managed bylaunchd.
If all four checks pass, the script exits successfully (Exit Code 0). If any check fails, it exits with a failure code (Exit Code 1), which tells NinjaRMM to run the "Ensure Ninja Service is Running" remediation script.
Sample Run
Note: This script is specifically engineered to operate as the detection condition within the Ensure Ninja Service is Running [Macintosh] policy. Manual execution is not recommended, as the script's output is intended to trigger automated remediation actions rather than provide direct feedback.
Dependencies
Automation Setup/Import
Output
- Activity Details: Text output indicating which specific checks passed or failed (e.g.,
[PASS] Script file exists and hash validates.or[FAIL] LaunchDaemon com.ninjarmm.EnsureNinjaServiceRunning is not loaded.). - Final Result: A clear text output indicating overall success (
Success: Monitoring configuration is fully intact.) or failure (Failure: Monitoring configuration is missing or invalid.). - Exit Code: Returns
0if the monitoring setup is healthy, or1if remediation is required.
Changelog
2026-07-07
- Initial version of the document.