Skip to content

Instantly share code, notes, and snippets.

@mattpascoe
mattpascoe / Vagrantfile
Last active March 3, 2016 23:20 — forked from opennetadmin/Vagrantfile
Simple Vagrant config file. It will get you a precise64 box and start up a puppet run using bridged networking
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise64"
# Set a hostname
config.vm.host_name = "ona-vm"
@mattpascoe
mattpascoe / baseiptemplate
Created October 3, 2012 16:24 — forked from opennetadmin/baseiptemplate
Puppet template to calculate the base subnet IP from an IP/MASK input
<%
# This portion simply calculates the baseip from the ip/mask
baseip=""
addr_parts = scope.lookupvar("ipaddress").split('.')
mask_parts = scope.lookupvar("netmask").split('.')
addr_parts.zip((0..addr_parts.size).to_a).map do |n,i|
baseip += (n.to_i & mask_parts[i].to_i).to_s + "."
end
baseip = baseip[0..-2]
-%>
@mattpascoe
mattpascoe / gist:3842920
Created October 5, 2012 22:53
Simple script to build deb packages from graphite master on github
#! /bin/bash
# Requires fpm v0.4.20 at least
#
# rm -rf carbon-latest* ceres-latest* graphite-web-latest* whisper-latest* *.deb;rm -rf /opt/graphite/;dpkg -r python-whisper python-graphite-web python-carbon python-ceres python-txamqp
#
# This script needs "fpm". If you dont have it,
# run "gem install fpm"
# Then simply execute this script and it will create packages and install them on your system.
#
@mattpascoe
mattpascoe / dcm.pp
Created October 12, 2012 16:39
OpenNetAdmin puppet module stuffs
class opennetadmin::dcm inherits opennetadmin {
case $operatingsystem {
Debian,Ubuntu: {
package {
'libio-socket-ssl-perl':
ensure => present,
before => File['dcm.pl'],
}
}
@mattpascoe
mattpascoe / leasquery.php
Last active September 2, 2022 00:53
DHCP Leasequery via php -- initial attempts
<?php
/**
* Main class can be found here:
* https://www.phpclasses.org/package/6621-PHP-Send-queries-to-a-DHCP-server.html
*
* A simple test script to demonstrate how to use the dhcpLeaseQuery class.
* Please read the note below first then edit the variables below as appropriate.
* Then simply run: php LeaseQuery.php
*
@mattpascoe
mattpascoe / tinydnsparse.awk
Created November 6, 2012 18:02
An AWK script to parse a tinydns data file into a CSV for later use by a dcm.pl script to load into opennetadmin
#!/usr/bin/awk -f
#
# Author: Matt Pascoe - matt@opennetadmin.com
#
# This awk script is used to extract relevant information from a tinydns data
# config file and build a csv with appropriate fields for passing into
# a dcm.pl module. This can be used to bootstrap a new database from existing
# site data.
#
# This script assumes the data to be reasonably correct as it is expected that
@mattpascoe
mattpascoe / parseshowroute.sh
Created November 6, 2012 20:07
Generate DCM.PL commands from the output of a 'show ip route' to load into ONA
#!/bin/bash
#
# Author: Matt Pascoe - matt@opennetadmin.com
#
# usage: ./parseshowroute.sh <filename>
#
# Takes the output of a "show ip route" command from an IOS device
# and processes it. Simply get the output and save it to a file
# and then run this script against that file.
#
@mattpascoe
mattpascoe / dhcpparse.awk
Last active April 2, 2024 08:18
An AWK script to parse ISC dhcpd configuration files into dcm.pl output to load into OpenNetAdmin
#!/usr/bin/awk -f
#
# Author: Matt Pascoe - matt@opennetadmin.com
#
# This awk script is used to extract relavant information from a dhcpd.conf
# config file and build dcm.pl output with appropriate fields. This can be
# used to bootstrap a new database from existing site data.
# As usual, inspect the output for accuracy.
# Also you will get three types of output, subnet,pool,host. You must
# add the subnet information first, then pool, then host.
@mattpascoe
mattpascoe / conf-archive-diff.png
Created November 28, 2012 03:48
OpenNetAdmin official image gist.
conf-archive-diff.png
@mattpascoe
mattpascoe / leasecheck.pl
Last active September 17, 2018 16:30
Perl script to parse ISC DHCP lease file and display basic info. I dont recall if I wrote this or if I found it on the interwebs somewhere!?!?.. a quick goog search did not find it but hey its useful so have at it.
#!/usr/bin/perl
#
# Update the path to your lease file below
use strict;
use File::Copy;
#use DateTime;
#always parse a copy not the live file
#my $leasefile = '/var/lib/dhcpd/dhcpd.leases';
my $leasefile = '/var/lib/dhcp/db/dhcpd.leases';