Skip to content

Instantly share code, notes, and snippets.

View javierwilson's full-sized avatar

javier wilson javierwilson

  • Managua, Nicaragua
View GitHub Profile
@javierwilson
javierwilson / report.py
Last active May 17, 2017 12:59
Generates CSV for last week cpu, mem and disk utilization
#!/usr/bin/env python
import datetime
import os
from datadog import initialize, api
options = {
'api_key': os.getenv('DD_API_KEY'),
@javierwilson
javierwilson / common.py
Created April 4, 2017 10:52
linux tools for commcarehq
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Server layout:
~/www/
This folder contains the code, python environment, and logs
for each environment (staging, production, etc) running on the server.
Each environment has its own subfolder named for its evironment
(i.e. ~/www/staging/log and ~/www/production/log).
@javierwilson
javierwilson / check_puppet
Created January 12, 2017 08:19
Nagios plugin for puppet
#! /bin/sh
#
# 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 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@javierwilson
javierwilson / check_supervisorctl
Last active January 12, 2017 08:19
Nagios plugin for supervisor
#!/bin/sh
# --
# Checks supervisorctl for programs that are not in the state of RUNNING.
# That is to say STOPPED, STARTING, BACKOFF, STOPPING, EXITED, FATAL, UNKNOWN
#
#
# @author: Steve Lippert | [email protected] | Management Research Services, Inc.
# @version: 0.1
# @date: 2011/03/03 (YMD)
# --
@javierwilson
javierwilson / snmpd.conf
Created January 12, 2017 05:15
SNMP config
#
# /etc/snmp/snmpd.conf
#
# gives read-only access to nagios_server using secname, secgroup
#
# sec.name source community
com2sec localhost 127.0.0.1 public
com2sec nagios MONITOR public
# groupName securityModel securityName
@javierwilson
javierwilson / nrpe.local.cfg
Last active January 12, 2017 05:13
NRPE config
#
# /etc/nrpe.d/nrpe.local.cfg
#
# allows nagios_server to connect to NRPE and adds additional commands
#
#
allowed_hosts=MONITOR
command[check_yum]=/usr/lib64/nagios/plugins/check_yum
command[check_pgsql]=/usr/lib64/nagios/plugins/check_pgsql
command[check_mysql]=/usr/lib64/nagios/plugins/check_mysql -u nrpe
@javierwilson
javierwilson / authorized_keys
Last active May 22, 2018 20:35
.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDwlFsn4l+h26J91IU/SChCsy9leDAnQxCuOQ5ezxzPLb31YA/wGp9k/HUnK6phYseH0Gutm+pW+EApAmojjUWARV0GQW18I6VbS03a4/r71R0ZqT9a1Fj0ABmdX1KG9vwF+WK5beP/xR4iDcA8zULWILwIkKfwonB+xzdZGiQr6UqylU/163MDuva8Q9PkqcPI7wP0IogZ0mDPC6xHYh9ZVtDsyDcZfgbIMZjRuA6h6gcldGvt362Y4/qoy91MFUL/T19f+cJA14d/qjdPmyIJsDhUc0qpZ9h9IaIuj5nibKUWBAEU/4AFzylSAoiibr5WMwdvbpVOZujewQROgUkL javier
@javierwilson
javierwilson / deploy.sh
Last active December 11, 2016 06:58
deploy matos
#!/bin/bash
USER=matos
APP=$USER
DIR=/var/www/$APP
REPO=https://github.com/javierwilson/$APP
mkdir $DIR
find $DIR -name "*.pyc"|xargs rm
git clone $REPO $DIR
from askbot.models import User
users = User.objects.filter(askbot_profile__reputation=1)
for u in users:
print u
profile = u.askbot_profile
profile.reputation = 100
profile.save()
@javierwilson
javierwilson / polls.py
Created August 26, 2016 04:24
parse html election results
import glob
from lxml.html import parse
poll_files = glob.glob("*.html")
for poll_file in poll_files:
poll = poll_file[0:poll_file.index('.')]
names = poll.split(',',2)
page = parse(poll_file)
trs = page.xpath("body/div/div//div/table")[0].findall("tr")