Skip to content

Instantly share code, notes, and snippets.

View abdallah's full-sized avatar
🏠
Working from home

Abdallah Deeb abdallah

🏠
Working from home
View GitHub Profile
@abdallah
abdallah / update_newrelic_whitelist.py
Created March 13, 2020 09:58
Lambda function to update whitelist with newrelic IPs
import os
import json
import boto3
import urllib3
# Set the following in the Lambda Environment variables
IP_SET_ID = os.environ.get('IP_SET_ID')
Special_IPs = os.environ.get('SPECIAL_IPS').split(',')
@abdallah
abdallah / create-acm-cert.yml
Created March 11, 2020 07:54
Create an Amazon issued certificate in ACM. Uses Route53 for DNS verification
- hosts: localhost
gather_facts: no
vars:
aws_profile: "aws_account_name"
acm_domain: "example.com"
acm_extra_domains: "*.example.com"
acm_idempotency_token: "examplecomtoken"
dns_zone: "example.com"
environment:
AWS_PROFILE: "{{ aws_profile }}"
@abdallah
abdallah / ses-sns-sqs-to-graylog.py
Created March 8, 2018 14:08
Send SNS notifications to Graylog2
import boto3
import json
import requests
from datetime import datetime
import sys
HOST = 'MY.HOST.ADDRESS'
PORT = 12201 # change if you create graylog input with different port
queue_url = 'https://sqs.ZONE.amazonaws.com/ACCOUNT/QUEUENAME'
@abdallah
abdallah / log_high_cpu.sh
Created February 28, 2018 11:39
Log PID and path of process causing high CPU usage (php-fpm)
#!/bin/bash
# very specific need
top_process=$(ps -eo pid,cmd,%cpu --sort=-%cpu | head -n2 | tail -n1)
if [[ $top_process == *sometest* ]]; then
PATHTOPROCESS=$(echo $top_process| awk '{print $1}' | xargs lsof -p | grep public_html)
logger -it HIGHCPU "Process $top_process in $PATHTOPROCESS"
fi
@abdallah
abdallah / install_nr_infra.yml
Created November 30, 2016 15:53
Install New Relic Infrastructure agent on all my servers using Ansible playbook (Ubuntu)
---
- hosts: all
tasks:
- lineinfile: "dest=/etc/newrelic-infra.yml line='license_key: YOURKEYHERE' create=yes state=present"
- apt_key:
state=present
url=https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg
- apt_repository: "repo='deb [arch=amd64] http://download.newrelic.com/infrastructure_agent/linux/apt {{ansible_distribution_release}} main' state=present update_cache=yes"
- apt: name=newrelic-infra
@abdallah
abdallah / plugin.php
Created February 10, 2016 08:33
WordPress ajax skeleton
<?php
/*
Plugin Name: My Plugin
Plugin URI: https://deeb.me
Description: 10 ways to peel an orange
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@abdallah
abdallah / newdjango.sh
Last active January 22, 2016 15:09
Bash script to initialize new django project
#!/bin/bash
#
# Author: Abdallah Deeb <abdallah@deeb.me>
# Requirements: python, pip, virtualenv, virutalenvwrapper, git
#
# Edit the following 2 lines
PROJECTNAME=proj
APPNAME=myapp
if [ -n "$2" ]
then
@abdallah
abdallah / ntp-ddos-vulnerable-ips.sh
Created January 15, 2014 10:03
Inspect range of IPs for NTP DDOS vulnerability
IPRANGE=10.10.10.0/24
nmap -sU -pU:123 -Pn -n --script=ntp-monlist $IPRANGE | grep -B 4 ntp-monlist | grep report | awk '{ print $5 }'
@abdallah
abdallah / .htaccess
Created November 26, 2013 09:18
email tracking
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(png|css)$
RewriteRule (.*) n.php [L,QSA]
[Definition]
failregex = <HOST>.*] "POST /wp-login.php
ignoreregex =