My Mac OS X clients have different errors that I see through the email notifications that are sent to me. Rather than manually resolve each computer, I wanted to have the JSS place the computers with particular errors in specific smart groups so I can use those smart groups to scope specific solutions, e.g., run QuickAdd or jamf enroll at computers with "device signature errors".
I would appreciate JAMF Nation's feedback in either tightening the EA's script (I am sure it can be written more efficiently) and/or improving the script's logic. For example, the current iteration of the EA only checks the last 100 lines of the jamf.log for a particular error. My intent with the tail is to try to examine the few days or week's worth of entries so that the error is relatively fresh; I did not want to try to resolve an error that occurred once a few months ago.
Thanks in advance.
#!/bin/bash
$ERROR="" #examples: "connection failure", "device signature error", etc.
MATCH=`tail -n 100 /var/log/jamf.log | grep '$ERROR' | awk 'NR==2{print $0}'`
if [[ "$MATCH" == "$ERROR" ]]; then
RESULT="PROBLEM EXISTS"
else
RESULT="NO PROBLEM EXISTS"
fi
echo "<result>$RESULT</result>"
exit 0