Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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@[email protected]............(.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@[email protected]............(.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
@candlerb
candlerb / missing_device_type_components.py
Last active January 10, 2023 19:26
Netbox report to identify devices which are missing items from device type
# Identify devices which are missing components from the device type definition
from extras.reports import Report
from dcim.models import Device
class MissingDeviceTypeComponents(Report):
name = "Missing Device Type Components"
description = "Find devices which are missing components that are in the device type template"
def test_add_ports(self):
@candlerb
candlerb / add_device_type_components.py
Last active February 27, 2024 23:14
Custom script to backfill missing components from device type template
"""
This script adds missing components from the device type to selected device(s)
"""
from dcim.models import Device, ConsolePort, ConsoleServerPort, PowerPort, PowerOutlet, Interface, RearPort, FrontPort, DeviceBay
from extras.scripts import Script, MultiObjectVar
class AddDeviceTypeComponents(Script):
class Meta:
name = "Add Device Type Components"
@candlerb
candlerb / gist:6e001695eb634af344a834026d508789
Created March 6, 2020 17:27
Errors installing netbox 2.7.9 into virtualenv under Ubuntu 16.04
root@netbox:/opt/netbox# ./upgrade.sh
Removing old virtual environment...
Creating a new virtual environment at /opt/netbox/venv...
Installing Python packages (pip3 install -r requirements.txt)...
Collecting pip>=19.0.0 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 487kB/s
Collecting wheel==0.34.2 (from -r requirements.txt (line 2))
Using cached https://files.pythonhosted.org/packages/8c/23/848298cccf8e40f5bbb59009b32848a4c38f4e7f3364297ab3c3e2e2cd14/wheel-0.34.2-py2.py3-none-any.whl
Collecting Django<2.3,>=2.2 (from -r requirements.txt (line 3))