Skip to content

Instantly share code, notes, and snippets.

View maatthc's full-sized avatar

Alexandre Andrade maatthc

  • MaaT Tech
  • Melbourne
View GitHub Profile
@maatthc
maatthc / datadog-nginx
Last active August 29, 2015 14:24 — forked from gane5h/datadog-nginx
"""
Custom parser for nginx log suitable for use by Datadog 'dogstreams'.
To use, add to datadog.conf as follows:
dogstreams: [path to ngnix log (e.g: "/var/log/nginx/access.log"]:[path to this python script (e.g "/usr/share/datadog/agent/dogstream/nginx.py")]:[name of parsing method of this file ("parse")]
so, an example line would be:
dogstreams: /var/log/nginx/access.log:/usr/share/datadog/agent/dogstream/nginx.py:parse
Log of nginx should be defined like that:
log_format time_log '$time_local "$request" S=$status $bytes_sent T=$request_time R=$http_x_forwarded_for';
when starting dd-agent, you can find the collector.log and check if the dogstream initialized successfully
"""
//
// Find out which process is accessing Memcached on localhost.
// It uses SystemTap : https://sourceware.org/systemtap
// You will need the kernel-debuginfo-common, kernel-headers and kernel-debuginfo
// Packages installed.
//
probe begin {
printf("%5s (%s) %15s %5s %15s %5s %s %s %s %s %s %s\n",
"PID", "CMD", "saddr", "SPORT", "daddr", "DPORT", "urg","ack","psh","rst","syn","fin")
}
@maatthc
maatthc / main.py
Created March 3, 2016 00:22
Testing on run time how many parameters a function is expecting.
from inspect import getargspec;
import sys
class Consumer(object):
def __init__(self, path, callback):
print("Creating class..")
self._path = path
self._callback = callback
@maatthc
maatthc / import_from_dd_to_nr.py
Last active May 23, 2016 01:34
Generate Server list for mRemote3G from Datadog mRemote3G : https://github.com/kmscode/mRemote3G Datadog: app.datadoghq.com
"""
Generate Server list for mRemote3G (former mRemoteNG) from Datadog Infrastructure List
mRemote3G : https://github.com/kmscode/mRemote3G
Datadog: app.datadoghq.com
Author: Alexandre Andrade
"""
import json
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
@maatthc
maatthc / softlayer_cancel_servers.py
Last active May 6, 2016 03:54
It cancels Baremetal servers running at SoftLayer.It also power off the server and muted the monitoring at Datadog.
"""
Cancel the server with SoftLayer, turn it off and mute the Datadog alerts for it.
The host will be available until the next 16th day of the month.
"""
import SoftLayer
import sys
from CC_SoftLayer import get_credentials as sl_get_cred
from CC_Datadog import dd_init
@maatthc
maatthc / CC_Datadog.py
Created May 5, 2016 07:14
Helper for Datadog API
from datadog import initialize, api
import sys
def dd_init():
dd_options = {
'api_key': '',
'app_key': ''
}
initialize(**dd_options)
return api
@maatthc
maatthc / CC_SoftLayer.py
Created May 5, 2016 07:16
Helper to the SoftLayer API - Helps protectig the API Key
import getpass
from cryptography.fernet import Fernet
import sys
def get_credentials():
# SoftLayer Username/ Api Key encrypted
encrypted_credentials = b''
secret_key = getpass.getpass("Please enter your secret key: ")
@maatthc
maatthc / Dockerfile_Python_Mysql_Django
Created June 12, 2016 16:16
Dockerfile to build Python / Django / Mysql small container images . Based on Linux Alpine.
############################################################
# Dockerfile to build Python / Django / Mysql small container images
# Based on Linux Alpine
############################################################
# Set the base image
FROM alpine
# File Author / Maintainer
MAINTAINER Alexandre Andrade aleandrade@gmail.com
# Ruby 2.3.3
# puts print
# Simbols are simpler String objs
# Constants are Capitalized variables
# Methods name finishing with a question mark returns booleans
# You can chain methods: job.get().askRaise()
# Global vars starts with a Dollar sign: $
# Instance vars starts with an At sign: @
puts "The Mick "
puts "Gap Year "
puts "Stan Lees Lucky Man "
puts "The Worst Witch "
puts "The Middle "
puts "Master of None "
puts "Sense8 "
puts "Da Vincis Demons "
puts "Scorpion "
puts "Citizen Khan "