Skip to content

Instantly share code, notes, and snippets.

View coxley's full-sized avatar

Codey Oxley coxley

View GitHub Profile
@coxley
coxley / cisco_functions.py
Last active August 29, 2015 14:11
various helper functions
import sys
import time
import logging
import socket
import Exscript.protocols as protocols
from Exscript.util.interact import read_login
from Exscript.util.file import get_hosts_from_file
from Exscript.protocols.Exception import LoginFailure, TimeoutException
@coxley
coxley / nfsen-nginx.conf
Created December 21, 2014 07:51
nginx php-fpm config
server {
listen 80;
root /data/www/nfsen;
index nfsen.php;
server_name nfsen;
error_log /data/www/nfsen/log/error.log error;
access_log /data/www/nfsen/log/access.log main;
@coxley
coxley / keybase.md
Created December 22, 2014 04:44
keybase verification

Keybase proof

I hereby claim:

  • I am coxley on github.
  • I am codey (https://keybase.io/codey) on keybase.
  • I have a public key whose fingerprint is F713 8278 72ED 5CB6 87F0 766C F46E 22A9 01D7 66AA

To claim this, I am signing this object:

@coxley
coxley / interface-monitor
Created March 31, 2015 17:51
Monitor interface input and output bps/pps
#!/bin/env python2.7
"""
interface-rate
Usage:
interface-rate -c <host> -i <interface> [options]
Options:
-h --help Show this screen.
"""
Description: Attempts to login as root with each password in the provided
password list. If successful, runs ``uname -a`` and prints to
stdout
Usage:
waruname.py <hosts_file> <password_list>
Options:
@coxley
coxley / pathviz.js
Created August 11, 2015 21:48
Takes raw ASPATH data and creates coordinate pairs
// The file being loaded by this program looks like:
// ---
// 3356 174 32780
// 6461 174 32780
// 6461 6453 12
// 209 2914 9268 131088
// 209 3257 8495 196624
// 6461 2914 9268 131088
// 6461 3320 8495 196624
// 6461 6939 293 16
'''
Convert nsot csv to commands
'''
PATH = 'update.csv'
def create_net_cmd(resource):
'''pynsot bulk csv (colon) -> cli commands'''
cidr, attrs = resource.rsplit(':', 1)
return 'nsot networks add -c %s -a \'%s\'' % (cidr, attrs)
from __future__ import unicode_literals
"""
Loader for Trigger NetDevices using NSoT API.
Right now this loads ALL devices ALL the time, which scales very poorly with
the number of devices and attributes in NSoT.
To use this:
import copy
from pynsot.client import get_api_client()
api = get_api_client()
site = api.sites(api.default_site)
objects = site.networks.get(network_address='192.168.0.0')['data']['networks']
to_update = copy.deepcopy(objects)
[t['attributes'] = {} for t in to_update] # Strip the attributes
@coxley
coxley / main.yml
Created November 17, 2015 21:22
-d tasks/main.yml
---
- include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- "main.yml"
- name: packages | Install system packages
become: true