-
Download the
client-information
and move it to/usr/local/bin/client-information
:wget https://gist.githubusercontent.com/frdmn/5eeebc05c61c7a00450aee8b81be824c/raw/520d3e9ae9ec80710344119e1780939fa843130b/client-information -O /usr/local/bin/client-information bash +x /usr/local/bin/client-information
-
Configure the scheduler to periodically run the script:
wget https://gist.githubusercontent.com/frdmn/5eeebc05c61c7a00450aee8b81be824c/raw/520d3e9ae9ec80710344119e1780939fa843130b/victor.client-information.plist -O ~/Library/LaunchAgents/victor.client-information.plist
-
Enable the LaunchAgent scheduler:
launchctl load ~/Library/LaunchAgents/victor.client-information.plist
Last active
January 5, 2023 10:51
-
-
Save frdmn/5eeebc05c61c7a00450aee8b81be824c to your computer and use it in GitHub Desktop.
Victor's macOS Client information parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Create temporary file to store XML/Plist into | |
temp_file=$(mktemp) | |
# Write XML to file | |
system_profiler SPSoftwareDataType -xml > ${temp_file} | |
# Simple function to search for a specific key within | |
# the Plist and return it's value | |
function find_and_return_value { | |
/usr/libexec/PlistBuddy -c "Print :0:_items:0:${1}" ${temp_file} | |
} | |
# Function to check if FileVault is enabled or not | |
function get_filevault_status { | |
fdesetup status | grep On > /dev/null 2>&1 && echo "enabled" || echo "disabled" | |
} | |
# Parse information and construct JSON | |
json=""" | |
{ | |
\"os_version\":\"$(find_and_return_value "os_version")\", | |
\"kernel_version\":\"$(find_and_return_value "kernel_version")\", | |
\"boot_volume\":\"$(find_and_return_value "boot_volume")\", | |
\"boot_mode\":\"$(find_and_return_value "boot_mode")\", | |
\"local_host_name\":\"$(find_and_return_value "local_host_name")\", | |
\"user_name\":\"$(find_and_return_value "user_name")\", | |
\"secure_vm\":\"$(find_and_return_value "secure_vm")\", | |
\"system_integrity\":\"$(find_and_return_value "system_integrity")\", | |
\"uptime\":\"$(find_and_return_value "uptime")\", | |
\"filevault\":\"$(get_filevault_status)\" | |
} | |
""" | |
rm ${temp_file} | |
echo ${json} | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>EnableGlobbing</key> | |
<false/> | |
<key>Label</key> | |
<string>victor.client-information</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/bin/bash</string> | |
<string>/usr/local/bin/client-information</string> | |
</array> | |
<key>StandardErrorPath</key> | |
<string>/usr/local/var/log/client-information.log</string> | |
<key>StandardOutPath</key> | |
<string>/usr/local/var/log/client-information.log</string> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>StartCalendarInterval</key> | |
<array> | |
<dict> | |
<key>Hour</key> | |
<integer>10</integer> | |
<key>Minute</key> | |
<integer>0</integer> | |
</dict> | |
<dict> | |
<key>Hour</key> | |
<integer>15</integer> | |
<key>Minute</key> | |
<integer>0</integer> | |
</dict> | |
</array> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment