Skip to content

Instantly share code, notes, and snippets.

View eduherraiz's full-sized avatar

Edu Herraiz eduherraiz

View GitHub Profile
@eduherraiz
eduherraiz / mongodb_seg
Created December 16, 2013 14:01
MongoDB segmentation fault
Mon Dec 16 03:16:48.782 [conn297772] command neventum.$cmd command: { count: "images", query: { status: { $gte: 0 }, references.brand: 32751 } } ntoreturn:1 keyUpdates:0 locks(micros) r:203
856 reslen:48 203ms
Mon Dec 16 03:16:48.920 [conn297769] end connection 88.198.63.92:57761 (34 connections now open)
Mon Dec 16 03:16:48.985 [conn297772] command neventum.$cmd command: { count: "images", query: { status: { $gte: 0 }, references.brand: 32751 } } ntoreturn:1 keyUpdates:0 locks(micros) r:176
061 reslen:48 176ms
Mon Dec 16 03:16:49.224 [conn297772] query neventum.images query: { $query: { status: { $gte: 0 }, references.brand: 32751 }, $orderby: { position: 1 } } ntoreturn:48 ntoskip:0 nscanned:122
982 scanAndOrder:1 keyUpdates:0 locks(micros) r:238867 nreturned:8 reslen:37686 238ms
Mon Dec 16 03:16:50.327 [initandlisten] connection accepted from 88.198.63.92:59764 #297791 (35 connections now open)
Mon Dec 16 03:16:52.818 Invalid access at address: 0 from thread: conn297791
@eduherraiz
eduherraiz / gist:7989573
Created December 16, 2013 16:10
Bash script to get web screenshots using phantomjs
#!/bin/bash
URLS_FILE="/var/www/eduherraiz.com/www/snapshots/urls.txt"
IMGS_DIR="/var/www/eduherraiz.com/www/snapshots/imgs"
for URL in `cat $URLS_FILE`
do
FILE=`echo ${URL//[\/]/}`
#echo $FILE
# Create de screenshot with phantomjs
@eduherraiz
eduherraiz / pizza_calling
Created January 10, 2014 13:07
Script para sortear a quién le toca llamar para pedir las pizzas
#!/bin/python
from random import choice
players = ['Fran', 'Marc', 'Luis','Alvaro','Cristian', 'Edu']
p1 = choice(players)
print "Le toca llamar a : %s" % (p1)
#!/bin/sh
BKPDIR="/var/backups/pgsql/"
TODAY=$(date +%F)
DAY=$(date +%A |tr 'A-Z' 'a-z')
MONTH=$(date +%B |tr 'A-Z' 'a-z')
TMPDIR=$(mktemp -d -p $BKPDIR) || exit 1
export PGOPTIONS='-c statement_timeout=0'
pg_dumpall -U postgres --globals-only |bzip2 > $TMPDIR/ACCOUNT-OBJECTS.$TODAY.dump.bz
import psycopg2
import time
def query(select):
try:
conn = psycopg2.connect("dbname=test user=test password=12345678")
cur = conn.cursor()
cur.execute(select)
conn.commit()
conn.close()
2014-07-03 17:57:11 CEST LOG: database system was interrupted; last known up at 2014-07-03 16:15:27 CEST
2014-07-03 17:57:11 CEST LOG: starting point-in-time recovery to 2014-07-03 17:00:00+02
wal_e.operator.backup INFO MSG: begin wal restore
STRUCTURED: time=2014-07-03T15:57:11.798960-00 pid=11678 action=wal-fetch key=s3://apsl-wale/lohap1/wal_005/00000007.history.lzo prefix=lohap1/ seg=00000007.history state=begin
2014-07-03 17:57:12 CEST LOG: incomplete startup packet
wal_e.blobstore.s3.s3_util INFO MSG: completed download and decompression
DETAIL: Downloaded and decompressed "s3://apsl-wale/lohap1/wal_005/00000007.history.lzo" to "pg_xlog/RECOVERYHISTORY"
STRUCTURED: time=2014-07-03T15:57:12.225174-00 pid=11678
wal_e.operator.backup INFO MSG: complete wal restore
STRUCTURED: time=2014-07-03T15:57:12.227431-00 pid=11678 action=wal-fetch key=s3://apsl-wale/lohap1/wal_005/00000007.history.lzo prefix=lohap1/ seg=00000007.history state=complete
restore_command = '/usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e wal-fetch "%f" "%p"'
# Escoge, descomentando,que punto en el tiempo quieres recuperar
#recovery_target_time = '2014-07-01 09:07:00'
#recovery_target_time = 'latest'
#pause_at_recovery_target = false ## Descomentar esta linea si no queremos que se quede pausado el postgres despues de recuperar
#recovery_end_command = ''
############################
POSTGRESQL LOGS WAL-E
############################
## SUBIDA CORRECTA
wal_e.worker.upload INFO MSG: begin archiving a file
DETAIL: Uploading "pg_xlog/00000001000000000000000C" to "s3://cursopostgres-wale/test-edu/wal_005/00000001000000000000000C.lzo".
STRUCTURED: time=2014-10-28T08:33:49.736120-00 pid=11210 action=push-wal key=s3://cursopostgres-wale/test-edu/wal_005/00000001000000000000000C.lzo prefix=test-edu/ seg=00000001000000000000000C state=begin
2014-10-28 10:56:17 CET LOG: database system was interrupted; last known up at 2014-10-28 10:33:22 CET
2014-10-28 10:56:17 CET LOG: starting archive recovery
wal_e.operator.backup INFO MSG: begin wal restore
STRUCTURED: time=2014-10-28T09:56:17.253425-00 pid=22302 action=wal-fetch key=s3://cursopostgres-wale/test-edu/wal_005/000000010000000000000020.lzo prefix=test-edu/ seg=000000010000000000000020 state=begin
2014-10-28 10:56:17 CET LOG: incomplete startup packet
wal_e.blobstore.s3.s3_util INFO MSG: completed download and decompression
DETAIL: Downloaded and decompressed "s3://cursopostgres-wale/test-edu/wal_005/000000010000000000000020.lzo" to "pg_xlog/RECOVERYXLOG"
STRUCTURED: time=2014-10-28T09:56:18.061708-00 pid=22302
wal_e.operator.backup INFO MSG: complete wal restore
STRUCTURED: time=2014-10-28T09:56:18.064113-00 pid=22302 action=wal-fetch key=s3://cursopostgres-wale/test-edu/wal_005/000000010000000000000020.lzo prefix=test-edu/ seg=000000010000000000000
#!/bin/bash
# $Id: check_slave_replication.sh 3421 2013-08-09 07:52:44Z jmorano $
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
## Master (p_) and Slave (s_) DB Server Information