Skip to content

Instantly share code, notes, and snippets.

View martinrusev's full-sized avatar
🌱
01010110

Martin Rusev martinrusev

🌱
01010110
  • Berlin, Germany
View GitHub Profile
@martinrusev
martinrusev / postgres_pg_stat_statements
Created April 21, 2015 05:39
Enable Postgres Stats
# Install
sudo apt-get install postgres-contrib
# In postgres.conf
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 10000
pg_stat_statements.track = all
# In any database
create extension pg_stat_statements;
@martinrusev
martinrusev / apache-amon-ssl.conf
Last active August 29, 2015 14:17
Amon - Apache HTTPS Config
<VirtualHost *:80>
ServerName amon.cx
RewriteEngine on
RewriteCond %{SERVER_PORT} !=443
RewriteCond %{REQUEST_URI} !^/
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [NC,R=301,L]
@martinrusev
martinrusev / amon.conf
Last active August 29, 2015 14:17
Amon HTTPS - Nginx config
{
"host": "https://subdomain.amon:9001"
}
from datetime import datetime
from boto.ec2.cloudwatch import CloudWatchConnection
# Create the connection to Cloud Watch
cw = CloudWatchConnection(
aws_access_key_id=<aws_access_key>,
aws_secret_access_key=<aws_secret_key>
)
metrics = ["CPUUtilization",
#! /usr/bin/env bash
set -xe
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export DEBIAN_FRONTEND=noninteractive
export ITERATION=`date +%s`
export PACKAGE=circus
export DESCRIPTION='circus, A Process & Socket Manager built with zmq'
export VERSION=0.9.2
export WEB_VERSION=0.4.1
"""
Django's SMTP EmailBackend doesn't support an SMTP_SSL connection necessary to interact with Amazon SES's newly announced SMTP server. We need to write a custom EmailBackend overriding the default EMailBackend's open(). Thanks to https://github.com/bancek/django-smtp-ssl for the example.
"""
--- settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'email-smtp.us-east-1.amazonaws.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'username'
"""
Django's SMTP EmailBackend doesn't support an SMTP_SSL connection necessary to interact with Amazon SES's newly announced SMTP server. We need to write a custom EmailBackend overriding the default EMailBackend's open(). Thanks to https://github.com/bancek/django-smtp-ssl for the example.
"""
--- settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'email-smtp.us-east-1.amazonaws.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'username'
@martinrusev
martinrusev / gist:530d84101fb709da68b7
Created January 29, 2015 13:54
Custom Amon Plugin
from amonagent.modules.plugins import AmonPlugin
class AmonPlugin(AmonPlugin):
def collect(self):
self.gauge('requests.per.second', requests_per_second)
self.counter('purchases', purchases)
@martinrusev
martinrusev / cron_supervisord.ini
Last active May 6, 2025 09:49
Cron supervisord
[supervisord]
nodaemon=true
loglevel=debug
[program:amon]
command=gunicorn -c gunicorn.conf.py wsgi
directory=/amon
autostart=true
autorestart=true
redirect_stderr=true
FROM martinrusev/amon:latest
COPY requirements.txt /var/requirements.txt
RUN pip install -r /var/requirements.txt
COPY crontab.txt /var/crontab.txt
RUN crontab /var/crontab.txt
RUN chmod 600 /etc/crontab
COPY supervisord.conf /etc/supervisord.conf