I am working on creating a good way to track Macs that are not communicating over MDM properly. I have several Macs that are not getting profiles installed, profile changes, and are generally not working properly with MDM communications. One way I have tracked them down in the past is to create a profile, scope it to all computers and then wait to see which Macs don't get the profile. This works, but I wanted to dig a bit deeper. I have been trying to use this command to find out if Macs are reliably working with MDM:
log show --info --debug --predicate 'subsystem == "com.apple.ManagedClient"' --last 1h
The time can be changed to what ever I want. It seems that this command is only gathering activity from the Mac, not incoming MDM activity. That's what I need. Running the command above will result in a lot of information so I have used grep to make the output more focused. So far, I haven't been able to identify communication coming from APNS. Just running the command from a Mac that is offline will show a lot of activity. It's the logging from incoming activity that I need. I just don't know how to identify what is incoming activity. I see that the output of this command does show a PID so that is likely not incoming activity. Maybe there's another subsystem I should be checking? My goal with this is to create an extension attribute that would tell me if the Mac is communicating or not. I figure if there is incoming activity being logged, it means that the Mac is communicating. No incoming activity would mean that it's not. The EA could look like this:
#!/bin/zsh
mdmCOM=$(/usr/bin/log show --info --debug --predicate 'subsystem == "com.apple.ManagedClient"' --last 30m | grep "OUTSIDE MDM ACIVITY")
if [ -n "$mdmCOM" ]; then
echo "MDM communication is current"
MDMComs="MDM Good"
elif [ -z "$mdmCOM" ]; then
echo "MDM communication is NOT current"
MDMComs="MDM Bad"
fi
echo "<result>$MDMComs</result>"
Does anyone have a better idea for tracking incoming MDM activity?