Search by

ofirgalcon / mosyle

ofirgalcon

Mosyle Business MDM module for MunkiReport (independent line alongside tuxudo/mosyle).

Package info

github.com/ofirgalcon/mosyle

pkg:composer/ofirgalcon/mosyle

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-12-02 00:40 UTC

This package is auto-updated.

Last update: 2026-12-02 00:40:35 UTC


README

Pulls Mosyle MDM data via the Mosyle Business API for all enabled organisations. Data is fetched from Mosyle, cached on the server, and matched to MunkiReport clients by serial number. Only Mac devices are requested from the API.

Credits

This module and tuxudo/mosyle by tuxudo were developed independently for MunkiReport. Both use the public Mosyle Business API (login + device list as documented by Mosyle) and the same general idea—cache Mosyle data on the server and match clients by serial—but the codebases were not forked from each other. Schema, multi-org / business-unit handling, device groups, sync status, admin UI, and related fields diverged enough that a clean merge was not practical.

tuxudo published a Mosyle MunkiReport module first; this tree is the ofirgalcon line with the extras above. If you only need tuxudo’s module, use tuxudo/mosyle. Please mention both projects when comparing or redistributing.

Requirements

  • Mosyle Business API access for each org you want to sync
  • With multiple orgs in MOSYLE_ENABLED_ORGS, each org name must match a MunkiReport business unit name (used to pick the correct Mosyle tenant)
  • With exactly one enabled org, business unit matching is optional: that sole org is used when a client has no BU, or its BU name is not a Mosyle-enabled org name. If the BU name does match the enabled org, that mapping is still preferred.

Setup

1. Enable the Mosyle API

  1. Log in at mybusiness.mosyle.com.
  2. Go to Integrations → Activate new integration → Mosyle API Integration.
  3. Create a new token. Restrict access by IP and enter your MunkiReport server IP when possible.

2. Configure .env

Add the following to your .env file.

Security

  • Put credentials only in server .env (or the host environment). Never commit .env, tokens, or passwords into git.
  • Restrict each Mosyle API token by IP to your MunkiReport server when Mosyle allows it.
  • Limit filesystem permissions on .env (readable by the web/PHP user only).
  • The placeholders below are examples — replace them with your own values; do not publish real org names, emails, or tokens.

Which orgs to sync (comma-separated list):

MOSYLE_ENABLED_ORGS="ORG1,ORG2"

Substitute ORG1, ORG2 with your org names. For a single org, do not add a comma (single-org setups do not require a matching business unit). With two or more orgs, each name must match a MunkiReport business unit.

For each enabled org, add these three variables. Replace ORG1 with the org key used in MOSYLE_ENABLED_ORGS (and, for multi-org, the matching business unit name):

ORG1_EMAIL="user@org1.com"     # Email used to sign in to this Mosyle org
ORG1_PASS="org1password"       # Password for this Mosyle org
ORG1_API="access-token"       # Access token from step 1 (Mosyle API Integration)

Example for two orgs named Acme and Contoso:

MOSYLE_ENABLED_ORGS="Acme,Contoso"

ACME_EMAIL="admin@acme.com"
ACME_PASS="acmepassword"
ACME_API="your-acme-api-token"

CONTOSO_EMAIL="admin@contoso.com"
CONTOSO_PASS="contosopassword"
CONTOSO_API="your-contoso-api-token"

Variable names use the org name in uppercase; replace spaces or special characters (e.g. My Org → MY_ORG).

3. Fetch and process data

  1. Open /module/mosyle/admin in MunkiReport.
  2. Click Fetch new Mosyle data for enabled orgs. If Last Update Status shows an error, check .env (credentials and org names).
  3. Click Process devices in enabled orgs to match cached Mosyle data to clients and update the Mosyle listing.

The module paginates through all Mac devices (100 per page) so every device in each org is included.

Cache refresh cadence

Data When it refreshes
Devices (Mac inventory) About every 30 minutes (1 hour while Mosyle rate-limited), triggered by client check-in / process when the org cache is stale
Business device groups About every 6 hours on the same background path, or immediately via Admin Fetch
Admin Fetch On demand: full devices + groups for each enabled org

On check-in, if the org already has cached data, MunkiReport serves that cache immediately and refreshes Mosyle in the background after the report finishes (so the client does not wait on the Mosyle API). The first check-in for an org with no cache still fetches devices synchronously so the serial can be matched.

The admin table shows Devices updated and Groups updated separately so a devices-only background run is not confused with a full org refresh.

After devices are fetched, the admin Fetch flow also reverse-indexes Mosyle Business device groups (os: mac, non-security groups only — Fuse Hardening & Compliance security groups are skipped). Membership is stored per device for the listing and client tab. A live tab pull refreshes device fields but keeps group membership from the last groups scan (Admin Fetch or the 6-hour background pass).

Hide groups from the listing and tab

Edit local/module_configs/mosyle_exclude_groups.yml. Matching is case-insensitive; * and ? wildcards are allowed. Groups are still fetched and stored.

exclude:
  - Active*

Optional override: MOSYLE_EXCLUDE_GROUPS_PATH in .env (full path to a different YAML file).

Table Schema

Server-side Mosyle cache matched to MunkiReport clients by serial number (one row per Mac).

  • in_mosyle - BOOLEAN - Registered in Mosyle for an enabled org
  • sync_status - VARCHAR(255) - Sync status
  • device_name - VARCHAR(255) - Mosyle device name
  • deviceudid - VARCHAR(255) - Device UDID
  • asset_tag - VARCHAR(255) - Asset tag
  • school_name - VARCHAR(100) - Org / school name
  • mosyle_user - VARCHAR(255) - Assigned user
  • mosyle_user_type - VARCHAR(255) - User type
  • useremail - VARCHAR(255) - User email
  • mosyle_enrollment_type - VARCHAR(255) - Enrollment type
  • EnrolledViaDEP - BOOLEAN - DEP / ADE enrollment
  • IsUserEnrollment - BOOLEAN - User Enrollment
  • UserApprovedEnrollment - BOOLEAN - User-approved enrollment
  • user_approval_dismissed - BOOLEAN - User approval dismissed
  • is_supervised - BOOLEAN - Supervised
  • isActivationLockEnabled - BOOLEAN - Activation Lock enabled
  • IsActivationLockManageable - BOOLEAN - Activation Lock manageable
  • activation_bypass - VARCHAR(255) - Activation bypass code
  • AutoSetupAdminAccounts - VARCHAR(255) - ADE/DEP admin accounts
  • DeviceAttestationStatus - VARCHAR(255) - Device attestation status
  • lostmode_status - VARCHAR(255) - Lost Mode status
  • location_enabled - BOOLEAN - Location enabled
  • is_muted - BOOLEAN - Muted in Mosyle
  • is_deleted - BOOLEAN - Deleted in Mosyle
  • device_is_invalid - BOOLEAN - Device marked invalid
  • needosupdate - VARCHAR(255) - Needs OS update
  • OSUpdateStatus - MEDIUMTEXT - OS update status JSON/text
  • AvailableOSUpdates - MEDIUMTEXT - Available OS updates
  • hasvpn - BOOLEAN - Has VPN
  • vpn_status - VARCHAR(255) - VPN status
  • device_groups - MEDIUMTEXT - Device group membership
  • open_direct_device_link - VARCHAR(255) - Direct Mosyle device link
  • appVer - VARCHAR(255) - Self Service version
  • mdm_agent_ver - VARCHAR(255) - MDM agent version
  • mdm_agent_app_ver - VARCHAR(255) - MDM Agent.app version
  • security_app_ver - VARCHAR(255) - Mosyle Security version
  • av_app_ver - VARCHAR(255) - Mosyle AV version
  • agent_status - VARCHAR(255) - Agent status
  • last_beat - INTEGER - Last agent beat
  • date_checkin - BIGINT - Last MDM check-in
  • date_info - INTEGER - Last info update
  • date_last_push - INTEGER - Last push
  • date_lastlogin - INTEGER - Last login
  • date_profiles_info - INTEGER - Last profiles info
  • registered_date - INTEGER - Registered date
  • client_last_updated - BIGINT - Mosyle data last updated
  • munkireport_checkin_timestamp - BIGINT - Last MunkiReport check-in
  • DeviceInfoAttemptDate - INTEGER - Device info attempt
  • DeviceInfoSuccessDate - INTEGER - Device info success
  • device_info_last_sync - INTEGER - Device info last sync
  • device_info_sync_count - INTEGER - Device info sync count
  • LastDeviceTokenDate - INTEGER - Last device token
  • LastRemoteNotificationDate - INTEGER - Last remote notification
  • MacCommandsAttemptDate - INTEGER - Commands attempt
  • MacCommandsSuccessDate - INTEGER - Commands success
  • MacCommandsReplyAckAttemptDate - INTEGER - Commands reply ack attempt
  • MacCommandsReplyAckSuccessDate - INTEGER - Commands reply ack success
  • MacCommandsReplyResultsAttemptDate - INTEGER - Commands reply results attempt
  • MacCommandsReplyResultsSuccessDate - INTEGER - Commands reply results success