Skip to content

Instantly share code, notes, and snippets.

@candlerb
candlerb / natural-sort-2.py
Last active May 10, 2019 13:39
Natural sorting with option of priority to line card
import re
import unittest
def parse_natural(name, line_card_first=False):
res = re.split("(\d+)", name)
if line_card_first and len(res) > 3:
res = ["", res[1]] + res
# first and last element is always a string; alternate values are numbers
for i in range(1, len(res), 2):
res[i] = int(res[i])
#!/bin/sh
host="$1"
REALM="LOCAL.EXAMPLE.NET"
LCREALM="local.example.net"
TESTUSER="nagiostest"
BASENAME="cn=users,dc=local,dc=example,dc=net"
if [ "$host" = "" ]; then
echo "Missing hostname"
exit 2
@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):
@candlerb
candlerb / gns3-shellinabox.py
Created October 14, 2019 15:10
shellinabox wrapper to get access to GNS3 consoles via web
#!/usr/bin/python3
# Usage:
# shellinaboxd -t -s '/:ubuntu:ubuntu:/home/ubuntu:/home/ubuntu/gns3-shellinabox.py'
#
# Browse to http://<yourhost>:4200/ to get a list of consoles;
# click on one of the URLs to connect to the console
import os, sys
import urllib.parse as parse
@candlerb
candlerb / journal.out
Created November 9, 2019 12:05
Another reproduction of lxd issue #6426
-- Logs begin at Sat 2019-11-09 11:16:34 UTC, end at Sat 2019-11-09 12:01:02 UTC. --
Nov 09 11:16:34 srv1 systemd-journald[354]: Runtime journal (/run/log/journal/) is 3.1M, max 25.0M, 21.9M free.
Nov 09 11:16:34 srv1 kernel: Initializing cgroup subsys cpuset
Nov 09 11:16:34 srv1 kernel: Initializing cgroup subsys cpu
Nov 09 11:16:34 srv1 kernel: Initializing cgroup subsys cpuacct
Nov 09 11:16:34 srv1 kernel: Linux version 4.4.0-166-generic (buildd@lcy01-amd64-020) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #195-Ubuntu SMP Tue Oct 1 09:35:25 UTC 2019 (Ubuntu 4.4.0-166.195-generic 4.4.194)
Nov 09 11:16:34 srv1 kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-166-generic root=UUID=edfada70-3677-4ca5-b8d9-666cb1ce991f ro console=tty1 console=ttyS0
Nov 09 11:16:34 srv1 kernel: KERNEL supported cpus:
Nov 09 11:16:34 srv1 kernel: Intel GenuineIntel
Nov 09 11:16:34 srv1 kernel: AMD AuthenticAMD
@candlerb
candlerb / status.out
Last active November 9, 2019 12:11
"systemctl status --all" output with lxd issue #6426
● srv1
State: degraded
Jobs: 0 queued
Failed: 1 units
Since: Sat 2019-11-09 09:51:11 UTC; 10min ago
CGroup: /
├─lxc
│ ├─host1
│ │ ├─init.scope
│ │ │ └─2422 /sbin/init
@candlerb
candlerb / journal.out1
Last active November 9, 2019 12:11
"journalctl -n10000" output with lxd issue #6426
-- Logs begin at Sat 2019-11-09 09:51:12 UTC, end at Sat 2019-11-09 10:01:46 UTC. --
Nov 09 09:51:12 srv1 systemd-journald[343]: Runtime journal (/run/log/journal/) is 3.1M, max 25.0M, 21.9M free.
Nov 09 09:51:12 srv1 kernel: Initializing cgroup subsys cpuset
Nov 09 09:51:12 srv1 kernel: Initializing cgroup subsys cpu
Nov 09 09:51:12 srv1 kernel: Initializing cgroup subsys cpuacct
Nov 09 09:51:12 srv1 kernel: Linux version 4.4.0-166-generic (buildd@lcy01-amd64-020) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #195-Ubuntu SMP Tue Oct 1 09:35:25 UTC 2019 (Ubuntu 4.4.0-166.195-generic 4.4.194)
Nov 09 09:51:12 srv1 kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-166-generic root=UUID=edfada70-3677-4ca5-b8d9-666cb1ce991f ro console=tty1 console=ttyS0
Nov 09 09:51:12 srv1 kernel: KERNEL supported cpus:
Nov 09 09:51:12 srv1 kernel: Intel GenuineIntel
Nov 09 09:51:12 srv1 kernel: AMD AuthenticAMD
@candlerb
candlerb / gist:e0d926ce3488f762fff91c8f1ddd8a4f
Created November 13, 2019 10:39
"tcpdump -i lo -nn -s0 -A tcp port 8080" when attempting to deploy pulsar function
10:08:15.839630 IP 127.0.0.1.46040 > 127.0.0.1.8080: Flags [S], seq 683951199, win 43690, options [mss 65495,sackOK,TS val 1486321600 ecr 0,nop,wscale 7], length 0
E..<"y@.@..A............(.D_.........0.........
X.w.........
10:08:15.839649 IP 127.0.0.1.8080 > 127.0.0.1.46040: Flags [S.], seq 1637026495, ack 683951200, win 43690, options [mss 65495,sackOK,TS val 1486321600 ecr 1486321600,nop,wscale 7], length 0
E..<..@.@.<.............a.
.(.D`.....0.........
X.w.X.w.....
10:08:15.839666 IP 127.0.0.1.46040 > 127.0.0.1.8080: Flags [.], ack 1, win 342, options [nop,nop,TS val 1486321600 ecr 1486321600], length 0
E..4"z@.@..H............(.D`a.
....V.(.....
10:44:30.754 [pulsar-web-57-6] INFO org.eclipse.jetty.server.RequestLog - 10.85.179.103 - - [13/Nov/2019:10:44:30 +0000] "GET /admin/v2/persistent/public/functions/coordinate/stats HTTP/1.1" 200 851 "-" "Pulsar-Java-v2.4.1" 2
10:44:37.358 [io-write-scheduler-OrderedScheduler-1-0] INFO org.apache.bookkeeper.statelib.impl.kv.RocksdbKVStore - Checkpoint local state store 000000000000000001/000000000000001025/000000000000001024 at revision -1
10:44:37.358 [io-checkpoint-scheduler-OrderedScheduler-1-0] INFO org.apache.bookkeeper.statelib.impl.rocksdb.checkpoint.RocksdbCheckpointTask - Create a local checkpoint of state store 000000000000000001/000000000000001025/000000000000001024 at /home/ubuntu/apache-pulsar-2.4.1/data/bookkeeper/ranges/ranges/000000000000000001/000000000000001025/000000000000001024/checkpoints/588b3bdb-a0f1-4248-b525-050b39aac65a
10:44:37.516 [main-EventThread] INFO org.apache.distributedlog.bk.SimpleLedgerAllocator - Ledger allocator for /stream/storage/000000000000000001/00000000000000102
@candlerb
candlerb / gist:688db64659d5b248e3fa1e0874a2d8dd
Created November 13, 2019 10:53
pulsar error output hitting ^C
10:50:00.756 [pulsar-web-57-7] INFO org.eclipse.jetty.server.RequestLog - 10.85.179.103 - - [13/Nov/2019:10:50:00 +0000] "GET /admin/v2/persistent/public/functions/coordinate/stats HTTP/1.1" 200 851 "-" "Pulsar-Java-v2.4.1" 2
10:50:30.755 [pulsar-web-57-6] INFO org.eclipse.jetty.server.RequestLog - 10.85.179.103 - - [13/Nov/2019:10:50:30 +0000] "GET /admin/v2/persistent/public/functions/coordinate/stats HTTP/1.1" 200 851 "-" "Pulsar-Java-v2.4.1" 3
^CException in thread "Thread-5" java.lang.NullPointerException
at org.apache.pulsar.functions.runtime.ProcessRuntime.lambda$start$0(ProcessRuntime.java:138)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "Thread-11" java.lang.NullPointerException
at org.apache.pulsar.functions.runtime.ProcessRuntime.lambda$start$0(ProcessRuntime.java:138)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "Thread-7" java.lang.NullPointerException
at org.apache.pulsar.functions.runtime.ProcessRuntime.lambda$start$0(Pr