Skip to content

Instantly share code, notes, and snippets.

View danilochilene's full-sized avatar

Danilo Chilene danilochilene

View GitHub Profile
@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 / 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 / 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 / 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
### 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
mail from: [email protected]
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: [email protected]
250 2.1.0 [email protected]... Sender ok
rcpt to: [email protected]
250 2.1.5 [email protected]... Recipient ok