Skip to content

Instantly share code, notes, and snippets.

View jriguera's full-sized avatar

José Riguera Lopez jriguera

View GitHub Profile
@jriguera
jriguera / 00_openstack_vmware.md
Last active February 5, 2019 13:52
OpenStack and VMware integration
@jriguera
jriguera / iptables_redirect.txt
Created December 17, 2015 12:52
Iptables redirect port
# All incoming trafic (mainly via eth2) will be redirected to 2005 (old graphite relay)
iptables -t nat -A PREROUTING -p tcp --dport 2003 -j REDIRECT --to-port 2005
iptables -t nat -A PREROUTING -p udp --dport 2003 -j REDIRECT --to-port 2005
# Another example using ips
#iptables -t nat -A PREROUTING -i eth2 -p udp -d 10.9.2.197 --dport 2003 -j REDIRECT --to-port 2005
# loopback traffic do not go via PREROUTING chain
iptables -t nat -A OUTPUT -o lo -p tcp --dport 2003 -j REDIRECT --to-port 2005
# just the same but using ips instead of interfaces (for udp)
iptables -t nat -A OUTPUT --src 0/0 --dst 127.0.0.1 -p udp --dport 2003 -j REDIRECT --to-port 2005
@jriguera
jriguera / compile_ncid.sh
Last active May 30, 2020 22:36
NCID on raspberry pi (arch linux)
# Install compile requirements
pacman -S gcc make
# Install lib requirements for ncid
pacman -S libpcap
# Download
curl http://heanet.dl.sourceforge.net/project/ncid/ncid/1.2/ncid-1.2-src.tar.gz -o ncid-1.2-src.tar.gz
# Compile
@jriguera
jriguera / notify_slack_hipchat.sh
Created January 6, 2016 13:59
how to notify slack and hipchat
# Define those variables according to hipchar of slack (in this case is for slack)
ROOM_ID="XXXXX"
ROOM_TOKEN="XXXXXX/XXXXXXX/XXXXXXXXXXXXXXXXXXXX"
notify_hipchat() {
local msg="[$(hostname)] microBOSH/CF $ENVIRONMET $BKPLEVEL backup $BKPSTATUS"
local notify="0"
[ "$STATUS" != "1" ] && notify="1"
curl -H "Content-type: application/json" \
@jriguera
jriguera / interfaces.cfg
Created February 3, 2016 15:02
Debian/Ubuntu interfaces with routing tables
auto bond0.502
# Static interface with an address, will be brought up directly on boot.
iface bond0.502 inet static
address 10.10.11.10
netmask 255.255.248.0
#gateway 10.10.8.1
vlan-raw-device bond0
post-up grep -q " live" /etc/iproute2/rt_tables || echo "202 live" >> /etc/iproute2/rt_tables
post-up ip rule add from 10.10.11.10 table live
post-up ip route add table live default via 10.10.8.1
@jriguera
jriguera / email_notify.py
Last active August 7, 2025 20:15
Email from Python with Jinja2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Python 3 and compatibility with Python 2
from __future__ import unicode_literals, print_function
import os
import sys
import re
import logging
@jriguera
jriguera / segurity_group_rules.sh
Created February 24, 2016 22:52
Neutron cmd to add security group rules
# Add Neutron security groups for ping and ssh
neutron security-group-rule-create \
--protocol icmp \
--direction ingress \
--remote-ip-prefix 0.0.0.0/0 \
default
neutron security-group-rule-create \
--protocol tcp \
@jriguera
jriguera / haproxy.cfg
Created October 10, 2016 13:24
Haproxy for Multimaster MySQL cluster
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
@jriguera
jriguera / cf_org.py
Created October 14, 2016 09:31
Ansibe cf organizations
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Program to create an ansible inventory from all the deployments, jobs and
instances managed by a BOSH Director.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@jriguera
jriguera / list-dockerhub-images.sh
Last active April 12, 2017 11:53
Listing Docker images in DockerHub
#!/bin/bash
# Based on kizbitz/dockerhub-v2-api-organization.sh at https://gist.github.com/kizbitz/175be06d0fbbb39bc9bfa6c0cb0d4721
# Example for the Docker Hub V2 API
# Returns all images and tags associated with a Docker Hub organization account.
# Requires 'jq': https://stedolan.github.io/jq/
# set username, password, and organization
UNAME=""
UPASS=""