Code42 EA
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-20-2022 05:49 AM
Thought I would share this.
#!/bin/bash
appFile="/Library/Application Support/Code42-AAT/Data/logs/app.log"
if [[ -f "$appFile" ]]; then
#Parse JSON for username and feature pack version
JSON=$(cat "/Library/Application Support/Code42-AAT/Data/logs/app.log")
featurePackVersion=$(plutil -extract featurePackVersion raw -o - - <<< "$JSON")
username=$(plutil -extract username raw -o - - <<< "$JSON")
#Setting string for feature pack
if [[ "$featurePackVersion" == *"No value at that key path"* ]]; then
featurePackVersionResult="No feature pack version present"
alert=$alert+1
else
featurePackVersionResult="Feature Pack Version: $featurePackVersion"
fi
#Setting string for username
if [[ "$username" == *"No value at that key path"* ]]; then
usernameResult="No username detected"
alert=$alert+1
else
usernameResult="Username: $username"
fi
#Setting prefix
if [[ $alert -gt 0 ]]; then
prefix="[ALERT]"
else
prefix="[OK]"
fi
#Building output string
/bin/echo "<result> $prefix $featurePackVersionResult | $usernameResult</result>"
else
/bin/echo "<result>[ALERT] Code42 app.log is missing</result>"
fi
0 REPLIES 0