Skip to content

Instantly share code, notes, and snippets.

@rfdrake
rfdrake / onms_template.py
Created October 24, 2022 14:19
Netbox device export template for OpenNMS
<?xml version="1.0" encoding="UTF-8"?>
<model-import xmlns="http://xmlns.opennms.org/xsd/config/model-import"
date-stamp="2009-01-11T19:25:03.851-05:00"
foreign-source="netbox-2022">
{% for device in queryset %}
{% if device.status == 'active' and device.primary_ip4 and ( 'No Monitoring' not in device.tags.names() ) %}
{% set netbox_url = 'https://YOURNETBOXHOST/dcim/devices/' %}
{% set id = device.cf.bbsites_id or 'nb'~device.id %}
{% set url = '<a href=' ~ netbox_url ~ device.id ~ ' target="_blank">' ~ netbox_url ~ device.id ~ '</a>' %}
@rfdrake
rfdrake / qnap_conn_types
Created January 9, 2019 21:14
qnap conn_serv and conn_action
conn_action name
10, Login OK
11, Logout
9, Login Fail
3, Write
2, Read
8, Rename
14, Move
5, MakeDir
1, Delete
@rfdrake
rfdrake / dhcp_lease_parse.pl
Created March 28, 2018 15:14
Proof of concept Marpa::R2 parser for ISC dhcpd.leases
#!/usr/bin/perl
use strict;
use warnings;
use Marpa::R2;
my $DSL = <<'END_DSL';
lexeme default = latm => 1
:discard ~ Whitespace
:discard ~ Comment
@rfdrake
rfdrake / copy-module-to-perlbrew
Last active May 14, 2019 14:42
This copies a module from the main system into the local ~/perl5 directories
# this is an absolute hack used to workaround the fact we can't add build-deps
# to travis-ci containers. It's better than some alternatives, but most
# people might want to stick with "sudo: true" instead of doing this.
# Ok, this is worthless because system perls are built with threading and perlbrew isn't.
# Error: Can't load '/home/travis/perl5/perlbrew/perls/5.20/lib/5.20.0/x86_64-linux/auto/GD/GD.so' for module GD: /home/travis/perl5/perlbrew/perls/5.20/lib/5.20.0/x86_64-linux/auto/GD/GD.so: undefined symbol: PL_thr_key at /home/travis/perl5/perlbrew/perls/5.20/lib/5.20.0/x86_64-linux/DynaLoader.pm line 193.
# need system perl to get the include path right
# curl https://....githubstuff.com | /usr/bin/perl - | sh -x
@rfdrake
rfdrake / repl.rc
Created September 10, 2015 00:14
A nice default re.pl rc file
use feature 'say'; # to don't write \n all the time
use Data::Dumper;
use Term::ANSIColor;
# pretty print data structures
sub pp { print Data::Dumper->Dump([@_]) }
load_plugin qw(
FancyPrompt
ReadLineHistory Colors
@rfdrake
rfdrake / apache::vhost.pp
Created August 24, 2015 15:25
apache_vhost attempt at handling default values for apache::vhost
class apache_vhosts (
$vhosts = hiera('apache::vhosts', {}),
$options = [ "-Indexes", "+FollowSymLinks", "+MultiViews" ],
$override = [ "All" ],
)
{
# why all this trouble when create_resources supports default? Because we need to know the $name
validate_hash($vhosts)
@rfdrake
rfdrake / rancid-fe
Created November 18, 2014 22:47
a version of rancid-fe that monitors child processes and kills them after 300 seconds
#! /usr/bin/perl5
##
## $Id: rancid-fe.in 2296 2011-04-27 18:18:56Z heas $
##
## rancid 2.3.8
## Copyright (c) 1997-2008 by Terrapin Communications, Inc.
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Terrapin Communications, Inc. by Henry Kilmer, John Heasley, Andrew Partan,
@rfdrake
rfdrake / rtrcolor.pl
Created September 17, 2014 22:01
rtrcolor - cisco "sh interface" colorizer
#!/usr/bin/perl -w
# Copyright (C) 2007 Robert Drake
# This module is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@rfdrake
rfdrake / ifs.html
Created November 6, 2013 22:28
IFS Fern in javascript. We made one of these on TI calculators when I was in school. I remember it not instantaneously rendering, and I remember the resolution being very low.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<html>
<body bgcolor="#000000">
<center>
<canvas id="canvas" width="800" height="600"/>
</center>
@rfdrake
rfdrake / raid1.cfg
Last active April 21, 2024 23:08
Debian Wheezy raid1 preseed configuration
# This puts all files in one partition. You'll need to change proxy settings
# (USERNAME, PASSWORD, PROXYSERVER) and crypted passwords, as well as the
# get_domain string to your dns domain.
# This is not quite fully automatic. It will prompt you for hostname. If you
# want to automatically fill in the hostname you'll need to provide it in the
# kernel APPEND line by saying netcfg/get_hostname=hostname
# If you've never setup preseeding, the first step is going to be getting PXE
# netinstall working. You don't need a full CD, you just need netboot/debian-installer/amd64/linux