Skip to content

Instantly share code, notes, and snippets.

@reyjrar
reyjrar / logstash.conf
Created July 5, 2012 12:48
LogStash Configuration
input {
tcp {
type => "syslog"
port => 8514
}
}
filter {
## DISCARD IMPROPERLY FORMATTED MESSAGES
@reyjrar
reyjrar / New-iTerm-Window.scpt
Created February 8, 2012 13:14
AppleScript to Open a New iTerm Window and bring it to the front
(*
* New-iTerm-Window.scpt
*
* Intended for use with QuickSilver
* I mapped option-y to running this script to create
* a new iTerm window on the current workspace
*
* Based on much Googling - very little "original" code here
* Comments/Suggestions to brad.lhotsky@gmail.com
*)
@reyjrar
reyjrar / syslog-archive.sh
Created November 19, 2011 04:11
Manage /var/log/remote/ syslog storage, compressing and pruning older files.
#!/bin/sh
#
# Script to manage syslog storage capacity
# Remove anything older than 1 year
find /var/log/remote/ -mindepth 2 -mtime +365 -type f -exec rm '{}' \;
# Remove empty directories
find /var/log/remote/ -type d -empty -exec rmdir '{}' \;
@reyjrar
reyjrar / syslog-hosts-carbon.sh
Created November 19, 2011 01:51
log the number of distinct hosts communicating with syslog in the past 60 minutes
#!/bin/sh
# Assumes /var/log/remote/%HOSTNAME/ configuration for central logger
#
# collect data
time=`date +%s`;
distinct=`find /var/log/remote -mmin -60 | cut -d/ -f5| sort -u |wc -l`
# send it!
echo "syslog.distinct_hosts $distinct $time" | nc graphite 2003
@reyjrar
reyjrar / local-cpan-mirror.txt
Created November 17, 2011 03:14
Local CPAN Mirror Setup, Simply
#=======================================
# Part 1 is Setting up the Mirror Server
# Install CPAN::Mini
$ curl -L http://cpanmin.us | perl - --sudo CPAN::Mini
# Select a CPAN Mirror URL from http://mirrors.cpan.org/
# - We'll use http://cpan.pair.com
# Pick a directory to mirror to, I'll use /var/www/cpan
@reyjrar
reyjrar / dns-monitor-deploy.sh
Created October 8, 2011 16:50
Script using svnutils
#!/bin/bash
BINDIR="/usr/local/sbin"
SVNURL="file:///repo/projects/dns-monitor"
TARGET="/opt/www/dns-monitor"
$BINDIR/svncheckrel $SVNURL $TARGET
rc=$?;
if [ "$rc" -eq "0" ]; then
@reyjrar
reyjrar / stdout.pm
Created October 5, 2011 20:54
MooseX::POE Simple STDOUT Plugin
package dns::monitor::plugin::sniffer::log::dest::stdout;
use Moose;
extends 'dns::monitor::plugin::sniffer::log';
sub write {
my ($self,$line) = @_;
print $line,"\n";
@reyjrar
reyjrar / moosex-poe-test.pl
Created September 29, 2011 21:45
MooseX::POE Testing
#------------------------------------------------------------------------#
package base;
use MooseX::POE;
with qw( MooseX::POE::Aliased );
event process => sub {
my ($self,$thing) = @_[OBJECT,ARG0];
print "base::process called with $thing\n";
};
@reyjrar
reyjrar / request-to-rule.pl
Created August 4, 2011 17:54
Generate Snort Signature from a HTTP Request
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Status;
use URI;
use Snort::Rule;
@reyjrar
reyjrar / DNS-Query-NX.r
Created July 8, 2011 02:09
Query vs NX Relationships
# Library Loading
library("RPostgreSQL");
library("car");
# Connect to Database
pgDrv <- dbDriver("PostgreSQL")
dbh <- dbConnect(pgDrv, host="localhost", dbname="dnsmonitor", user="dnsmon", password="tooEasy")
# Retrieve Statistics from DB
stats <- dbGetQuery(dbh, "select client.id, client.ip, sum(queries) as queries, sum(nx) as nx, sum(answers) as answers, sum(errors) as errors, count(distinct day) as days_active