Skip to content

Instantly share code, notes, and snippets.

import queue
import threading
import time
import random
NUM_WORKERS = 20
class Worker(threading.Thread):
"""A worker thread."""
def __init__(self, input, output=None):
@candlerb
candlerb / fix-device-ports.py
Last active January 16, 2022 15:00
Standalone script to create all the missing device components which exist in DeviceType template but not in Device instances
import django
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'netbox.settings')
django.setup()
from dcim.models import Device, ConsolePort, ConsoleServerPort, PowerPort, PowerOutlet, Interface, RearPort, FrontPort, DeviceBay
for device in Device.objects.all():
# Based on Device.save()
ConsolePort.objects.bulk_create(
@candlerb
candlerb / missing-device-ports.py
Last active September 4, 2019 08:18
Report to highlight devices which are missing ports that are in the DeviceType template
# Install as reports/missing-device-ports.py
# Run as: python3 manage.py runreport missing-device-ports
from extras.reports import Report
from dcim.models import Device
class MissingDevicePorts(Report):
description = "Find devices which are missing ports that are in the device type template"
def test_add_ports(self):
@robcowart
robcowart / nprobe.conf
Created May 20, 2018 10:04
Improved nProbe Configuration File
# This configuration for nProbe exposes many more options than is available in the file provided
# when downloading nProbe.
#
# Most likely you will only need to change the -n and -i options for your environment. However, a
# number of other options are documented in case you need them.
#
# The provided template works very well with ElastiFlow - A solution to collect and analyze network
# flow data using the Elastic Stack. ElastiFlow is available from:
# https://github.com/robcowart/elastiflow
@candlerb
candlerb / addresses.py
Last active April 2, 2024 00:07
Netbox report to check for missing Primary IP Addresses
from extras.reports import Report
from dcim.models import Device
from virtualization.models import VirtualMachine
from ipam.constants import *
from ipam.models import IPAddress, Prefix
LOOPBACK_ROLES = [
IPADDRESS_ROLE_LOOPBACK,
IPADDRESS_ROLE_ANYCAST,
IPADDRESS_ROLE_VIP,
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="""
I never freaking remember argparse syntax and the docs are so all over the place
that I need this for an example.
class PeekIter:
""" Create an iterator which allows you to peek() at the
next item to be yielded. It also stores the exception
and re-raises it on the next next() call.
"""
def __init__(self, iterable):
self._exn = None
self._it = iter(iterable)
self._peek = next(self._it)
@brockpalen
brockpalen / json-stats-wrapper.py
Last active March 29, 2017 20:40
Lustre Logstash Files
#!/usr/bin/python
#Brock Palen
# brockp@umich.edu
#
'''
Takes data in the form of:
metric number
@joshuar
joshuar / Three-Node-LustreFS-Cluster-Quickstart.md
Last active July 22, 2020 09:52
Quick three-node Lustre set-up on CentOS 6
#!/usr/share/foreman/script/rails runner -e production
Host.all.each do |host|
next unless host.dhcp?
print "#{host}..."
dhcp_record = host.dhcp_record
print "#{dhcp_record}..."