When applications are running in production, they become black boxes that need to be traced and monitored. One of the simplest, yet main, ways to do so is logging. Logging allows us - at the time we develop our software - to instruct the program to emit information while the system is running that will be useful for us and our sysadmins.
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
# REF: https://github.com/pyenv/pyenv/blob/master/README.md | |
# ... building Python 3.6.2 on Bastion, "locally" | |
# yum install [Python3 build pre-reqs, on CentOS 6.7] | |
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash | |
tee -a $HOME/.bash_profile <<EOF | |
export PATH="\$HOME/.pyenv/bin:\$PATH" | |
eval "\$(pyenv init -)" |
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
import logging | |
import sys | |
from logging import config | |
# REF, modified from: | |
# https://stackoverflow.com/a/19367225 | |
if sys.platform == "darwin": | |
address = '/var/run/syslog' | |
facility = 'local1' |
There are two examples...
- Simple
- Advanced
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
import logging | |
import os | |
import uuid | |
from tornado import gen | |
from tornado.httpserver import HTTPServer | |
from tornado.ioloop import IOLoop | |
from tornado.options import define, options | |
from tornado.web import Application, StaticFileHandler, url |
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
# NetworkManager should manage wired interfaces! | |
# Linux Mint 18.x (Ubuntu 16.04) | |
# REF: "fixing VPN problem in Ubuntu", | |
# http://blog.wensheng.org/search?updated-min=2015-01-01T00:00:00-06:00&updated-max=2016-01-01T00:00:00-06:00&max-results=5 | |
aptitude install etckeeper | |
git log | |
nmcli c # NOTE: no wired-interface controlled | |
emacs -nw /etc/NetworkManager/NetworkManager.conf |
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
#!/bin/bash | |
usage="$(basename "$0") [-h] mountpoint nfs_server:directory" | |
while getopts ":h" opt; do | |
case $opt in | |
h) | |
echo $usage >&2 | |
exit 1 | |
;; |
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
import os | |
import re | |
import sys | |
import requests | |
filename_matcher = re.compile(r'http://www.oreilly.com/(.*)/free/(.*).csp') | |
def main(): | |
categories = sys.argv[1:] | |
urls = map(lambda x: 'http://www.oreilly.com/{}/free/'.format(x), categories) |
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
#!/bin/sh | |
VNC_SERVER=/usr/bin/x11vnc | |
VNC_DISPLAY=:0 | |
LOG_FILE=/tmp/x11vnc-run.log | |
case "$1" in | |
start|restart) | |
killall ${VNC_SERVER} |
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
## better, working "shell-recipe" for installing a tagged | |
## Ansible release, from Git source | |
## https://github.com/ansible/ansible/tags | |
sudo aptitude install python-yaml python-jinja2 python-paramiko | |
cd ~/git/Python | |
tag_name='v1.9.4-1' | |
git clone git://github.com/ansible/ansible.git --recursive |