Skip to content

Instantly share code, notes, and snippets.

View jriguera's full-sized avatar

José Riguera Lopez jriguera

View GitHub Profile
@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 / 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 / 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 / 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 / 00_openstack_vmware.md
Last active February 5, 2019 13:52
OpenStack and VMware integration
@jriguera
jriguera / bosh_release.md
Last active March 8, 2016 12:29
Creating bosh releases

Start here: http://mariash.github.io/learn-bosh/, then goto: http://bosh.io/docs/create-release.html

  1. Prepare the environment with bosh lite.
  2. Create the workspace for the new release: bosh init release <release_name>
  3. Create the source packages to compile: bosh generate package <package_name>
  4. After defining the compilation steps, add the source packages bosh add blob <package.tgz> <package_name>
  5. Create the job (or jobs) to run: bosh generate job <job_name> and write the monit, spec and startup files
  6. Create a manifest for the new project: http://bosh.io/docs/deployment-manifest.html, using cd templates && make_manifest warden. Option: copy from another simple release like: https://github.com/cloudfoundry-community/carbon-c-relay-boshrelease
  7. bosh status has to be pointing to the deployment manifest created before.
@jriguera
jriguera / external_net.sh
Created November 17, 2015 16:02
Defining external networks on OpenStack
# Load the admin credentials
. /root/openrc
# Creating the external network type VLAN with VLAND ID == 300 (Online_dev).
# The name of the provider physical_network "ext" is mapped to a physical
# device on the ML2 configuration file of each network node
neutron net-create \
--provider:network_type vlan \
--provider:physical_network ext \
--router:external \
@jriguera
jriguera / new_tenant.sh
Created November 17, 2015 15:23
Openstack CLI commands to create a new Project/Tenant and networks using identity V3 (with groups)
# Now we are managing the users on a project by using groups. So everything
# is about creating users and add they to the groups.
# A special user is created always with the same name of the project,
# just to reserve the name and avoid confusion and have an email.
############## Define those variables for the tenant (this is just an example)
TENANT=test
PASSWORD=test
TENANT_DESC="Test"
@jriguera
jriguera / ksm.sh
Created November 14, 2015 16:14
KSM
#!/usr/bin/env bash
cat <<EOF
http://www.kernel.org/doc/Documentation/vm/ksm.txt :
The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
pages_shared - how many shared pages are being used
pages_sharing - how many more sites are sharing them i.e. how much saved
pages_unshared - how many pages unique but repeatedly checked for merging
pages_volatile - how many pages changing too fast to be placed in a tree
@jriguera
jriguera / opensource.txt
Created August 23, 2015 23:07
Howto opensource a project ... or howto keep your configuration not public
GITHUB_URL = Public repo on GitHub.
BITBUCKET_URL = Private repo on Bitbucket.
Given a upstream repo on GitHub in order to clone it to Bitbucket to keep
the configuration non public (for example, to create specific ansible playbooks
with a set of roles), do this (only once!).
1. Create a new repo on Bitbucket. (BITBUCKET_URL)
2. Clone the upstream repo from Github to your local machine: git clone GITHUB_URL
3. git remote rename origin upstream BITBUCKET_URL