Skip to content

Instantly share code, notes, and snippets.

View danilochilene's full-sized avatar

Danilo Chilene danilochilene

View GitHub Profile
mail from: danilo@idev.com.br
503 5.0.0 Polite people say HELO first
helo
501 5.0.0 helo requires domain address
helo idev.com.br
250 localhost6.localdomain6 Hello localhost.localdomain [127.0.0.1], pleased to meet you
mail from: danilo@idev.com.br
250 2.1.0 danilo@idev.com.br... Sender ok
rcpt to: danilo@idev.com.br
250 2.1.5 danilo@idev.com.br... Recipient ok
### Testing MongoDB mass insert with pymongo
import pymongo
mongo = pymongo.Connection('localhost')
mongo_db = mongo['test']
mongo_collection = mongo_db['masstest']
n = 1
limit = 100000
@danilochilene
danilochilene / gist:c8571b23b2caa0df70c7
Last active August 29, 2015 14:06
Kernel 3.x on CentOS 6.5
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
yum update
yum --enablerepo=elrepo-kernel install -y kernel-lt
sed -i 's/default=1/default=0/' /etc/grub.conf
reboot
@danilochilene
danilochilene / bulk-statsd.py
Created April 17, 2015 15:29
Python script to load statsd to InfluxDB
import random
import statsd
n = 1
limit = 100000
while n <= limit:
c = statsd.StatsClient('localhost', 8125)
c.incr('foo') # Increment the 'foo' counter.
c.gauge('foo', random.randint(1, 100000000))
n = n +1
@danilochilene
danilochilene / get_total_vms.py
Created May 16, 2015 18:24
Get total vms from Vmware and send to InfluxDB
from vpoller.client import VPollerClient
import json
from influxdb.influxdb08 import InfluxDBClient
client = VPollerClient(endpoint='tcp://localhost:10123')
def get_total_vms():
msg = {'method': 'vm.discover', 'hostname': '1.1.1.1'}
r = json.loads(client.run(msg))
data = [
{
@danilochilene
danilochilene / gist:0a5ec3424208d59cfb88
Created October 21, 2015 13:09
Export Zabbix triggers from MySQL
use zabbix
select DISTINCT h.host,g.name,t.description,h.hostid,t.triggerid,i.itemid,t.expression,t.value,t.comments,i.units,i.valuemapid,d.triggerdepid from hosts as h join items as i on (h.hostid = i.hostid) join functions as f on (i.itemid = f.itemid) join triggers as t on (f.triggerid = t.triggerid) left join trigger_depends as d on (d.triggerid_down = t.triggerid) INNER JOIN hosts_groups hg ON ( hg.hostid = h.hostid ) LEFT JOIN groups g ON ( g.groupid = hg.groupid ) where h.status = 0 and t.value = 0 and t.status = 0 and i.status = 0 ORDER BY h.host INTO OUTFILE '/tmp/triggers.txt';
@danilochilene
danilochilene / write_metrics.py
Created December 1, 2015 20:31
Write data to InfluxDB
from influxdb import InfluxDBClient
import random
from time import sleep
import sys
client = InfluxDBClient('localhost', 8086, 'root', 'root', 'metrics')
x = 0
while True:
Warnings: 'data' is an invalid keyword argument for 'event.wait'. If you
were trying to pass additional data to be used in a template
context, please populate 'context' with 'key: value' pairs. Your
approach will work until Salt Carbon is out. Please update your
state files.
INFO:kolla.image.build:Found the docker image folder at /usr/local/share/kolla/docker
INFO:kolla.image.build:Added image base to queue
INFO:kolla.image.build:Attempting to run task BuildTask(base) for the first time
INFO:kolla.image.build.base:Building
INFO:kolla.image.build.base:Step 1 : FROM centos:7
INFO:kolla.image.build.base: ---> 0584b3d2cf6d
INFO:kolla.image.build.base:Step 2 : MAINTAINER Kolla Project (https://launchpad.net/kolla)
INFO:kolla.image.build.base: ---> Using cache
INFO:kolla.image.build.base: ---> db501f862216
INFO:kolla.image.build.base:Step 3 : LABEL kolla_version "3.0.1"
@danilochilene
danilochilene / config.go
Created March 24, 2017 16:12 — forked from abraithwaite/config.go
Awesome way to do configuration in go. Taken from https://github.com/influxdata/telegraf
package main
import (
"io/ioutil"
"log"
"github.com/naoina/toml"
"github.com/naoina/toml/ast"
)