Skip to content

Instantly share code, notes, and snippets.

@reidstidolph
reidstidolph / getNodeStatus.js
Created December 21, 2019 00:47
Promise-based sample fetching node status from the 128T REST API.
/*******************************************************************************
* *
* Promise-based sample fetching node status from the 128T REST API. *
* *
*******************************************************************************/
const https = require('https')
const host128t = 'my.128t.host.com' // Address or FQDN of 128T host
const tokenString = 'myLongTokenString' // API JWT
const routerName = 'my-router-name' // Router name to retrieve node status for
@reidstidolph
reidstidolph / getActiveAlarms.js
Created October 11, 2019 03:31
Promise-based sample fetching active alarms from the 128T REST API.
/*******************************************************************************
* *
* Promise-based sample fetching active alarms from the 128T REST API. *
* *
*******************************************************************************/
const https = require('https')
const host128t = 'my.128t.host.com' // Address or FQDN of 128T host
const tokenString = 'myLongTokenString' // API JWT
const routerName = 'my-router-name' // Router name to retrieve alarms for
@reidstidolph
reidstidolph / get128tToken.js
Created October 11, 2019 03:10
Promise-based sample fetching a JWT from the 128T REST API.
/*******************************************************************************
* *
* Promise-based sample fetching a JWT from the 128T REST API. *
* *
*******************************************************************************/
const https = require('https')
const host128t = 'my.128t.host.com' // Address or FQDN of 128T host
const apiUser = 'admin' // Authorized API user
const apiSecret = 'mySup3rS3cr3t' // API user secret
@reidstidolph
reidstidolph / 128t-event-listener
Created August 24, 2019 23:16
Print events from 128T to your console. To install, copy the script to your system, make it executable, and run it. Script is fully self-contained, just needs to be run from a system with NodeJS installed.
#!/usr/bin/env node
/*******************************************************************************
* *
* Eventsource Module *
* *
*******************************************************************************/
var parse = require('url').parse
var events = require('events')
@reidstidolph
reidstidolph / init.sh
Created May 28, 2019 15:32
128T network plugin scrips for interfacing Docker containers.
#!/usr/bin/env bash
###################################################################
# #
# This plugin init script is used to network containers built #
# with Docker. #
# #
# It expects a container to have been created in advance #
# (e.g. with '--network="none"'). The name of the container #
# ('--name') is expected to be passed in as the #
@reidstidolph
reidstidolph / 128T-config-template-builder.html
Last active April 1, 2019 12:44
Single page HTML app provides a means of creating a bit of 128T config with template-ized variables, which are bound to simple user inputs. See code comments for instructions.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>128T Template Builder</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.js"></script>
@reidstidolph
reidstidolph / init.sh
Created December 18, 2018 16:33
128T network plugin scripts for moving a specified interface ($INTNAME) to a specified bridge ($BRNAME). Logging of these scripts is to systemd journal, and can be view with `journalctl -t kni-attach`.
#!/usr/bin/env bash
########################################################
# #
# This script attaches a network interface a network #
# bridge. Output is logged to system journal, and can #
# be viewed with the following: #
# #
# $ journalctl -t kni-attach #
# #
@reidstidolph
reidstidolph / 128t-arp-grabber.js
Last active December 10, 2018 03:39
Grabs arp entries from a 128T host, along with a published device OUI listing. It then records MAC addresses and vendors to a CSV file.
#!/usr/bin/env node
"use strict";
/*
Grabs text file containing registered OUI listing, along with all entries from
ARP caches available to a 128T host. It then records MAC addresses and vendors
to a csv file.
*/
const fs = require('fs')
@reidstidolph
reidstidolph / dhcpd-client-gen.js
Last active November 24, 2018 18:30
Looks for a tenant-devices.json file in it's current directory, and uses it to produce a bit of config for dhcpd. See code comment block for expected json object.
#!/usr/bin/env node
'use strict';
/*
Parses tenant-devices.json file. For each tenant and client named in the array
in the form of:
[
"tenantName": "my-tenant",
"clients": [
@reidstidolph
reidstidolph / get-128t-token.sh
Last active September 22, 2018 00:05
Simple bash script for retrieving a 128T API token.
#!/bin/bash
read -p '128T host address (press enter for localhost): ' ADDRESS
if [[ -z "$ADDRESS" ]]; then
ADDRESS="127.0.0.1"
fi
read -p 'Username: ' USER
read -s -p 'Password (hidden): ' PASS
echo