Skip to content

Instantly share code, notes, and snippets.

@viktorbenei
Created August 10, 2014 06:10
Show Gist options
  • Save viktorbenei/35541c42b9d4f5f213aa to your computer and use it in GitHub Desktop.
Save viktorbenei/35541c42b9d4f5f213aa to your computer and use it in GitHub Desktop.
Install Logentries agent on OS X
#!/bin/bash
function print_and_do_command {
echo "-> $ $@"
$@
}
function print_and_do_command_exit_on_error {
print_and_do_command $@
if [ $? -ne 0 ]; then
echo " [!] Failed!"
exit 1
fi
}
#
# Quickfix, because Logentries tries to use python2 instead of python (python2 is not available on OS X - python is actually python 2)
#
print_and_do_command_exit_on_error sudo ln -s /usr/bin/python /usr/bin/python2
# this is the official Logentries install command
curl -O https://raw.githubusercontent.com/logentries/le/master/install/mac/install.sh && sudo sh install.sh
if [ $? -ne 0 ]; then
echo " [!] Failed to install Logentries agent"
fi
# for test just unload and re-load -> this should start to send data from the system log
print_and_do_command_exit_on_error sudo launchctl unload /Library/LaunchDaemons/com.logentries.agent.plist
print_and_do_command_exit_on_error sudo launchctl load /Library/LaunchDaemons/com.logentries.agent.plist
#
# you can register your additional log files with:
# $ sudo le follow path/to/the/file
# sudo is important, by the default logentries agent is started with sudo
# and if you try to add new log files without sudo it'll handle it as a separate,
# non-sudo logentries agent (meaning: will start a new agent and you have to start it as well as the sudo one)
#
# after the 'follow' of new log files you have to call:
# sudo launchctl unload /Library/LaunchDaemons/com.logentries.agent.plist && sudo launchctl load /Library/LaunchDaemons/com.logentries.agent.plist
# to start the monitoring
# you can add a quick test entry to the syslog with:
logger "logentries quick test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment