Skip to content

Instantly share code, notes, and snippets.

View JustinAzoff's full-sized avatar

Justin JustinAzoff

View GitHub Profile
def parse_cpu_info():
cpu = {}
for line in open("/proc/cpuinfo"):
if ':' in line:
k, v = line.split(":", 1)
k = k.strip()
v = v.strip()
cpu[k] = v
if not line.strip():
module Notice;
export {
redef enum Action += {
ACTION_TM_QUERY,
};
const tm_query_types: set[Type] = {} &redef;
}
##! Add the peer to the connection logs.
module Conn;
export {
redef record Conn::Info += {
peer: string &optional &log;
};
}
@JustinAzoff
JustinAzoff / pfring.modules
Created September 17, 2014 21:02
pfring.modules for redhat
# /etc/sysconfig/modules/pfring.modules
if [ ! -e /proc/net/pfring ] ; then
exec /sbin/modprobe pf_ring enable_tx_capture=0 min_num_slots=32768 >/dev/null 2>&1
fi
#!/usr/bin/env python
import os
import sys
import time
SIZE_TIMEOUT = 10
def get_size(f):
for x in range(SIZE_TIMEOUT):
try:
module TerminateConnection;
export {
redef enum Notice::Type += {
TerminatingConnection, # connection will be terminated
TerminatingConnectionIgnored, # connection terminated disabled
};
# Whether we're allowed (and/or are capable) to terminate connections
# using "rst".
redef exit_only_after_terminate = T;
event test()
{
local src = 1.2.3.4;
local dst = 8.8.8.8;
local output = "";
if ( T )
{
when ( local src_name = lookup_addr(src) )
@JustinAzoff
JustinAzoff / solr_searcher.py
Created March 24, 2009 02:35
minimal client for the solr REST api
from urllib2 import urlopen
from urllib import urlencode
import simplejson
class SolrSearcher:
def __init__(self, url):
self.url = url
def search(self, q, **kwargs):
args = {'q': q, 'wt': 'json'}
class approx::server {
package {'approx':
ensure => latest;
}
config_file { "/etc/approx/approx.conf":
source => "puppet://$servername/approx/approx.conf",
require => Package['approx'],
}
@JustinAzoff
JustinAzoff / tardiff.py
Last active September 17, 2015 15:16
Diff a tar file with the current contents on the filesystem
#!/usr/bin/env python
import difflib
import sys
import tarfile
def read(fn):
with open(fn) as f:
return f.readlines()