Skip to content

Instantly share code, notes, and snippets.

@mikegreen
mikegreen / sendTempHumidStathat.py
Created July 6, 2020 18:27
Send dht22 temp and humidity to Stathat
import time
import adafruit_dht
import board
from datetime import datetime
from stathat import StatHat
stathat = StatHat()
stathatKey = "foo@foo.com"
@mikegreen
mikegreen / sendVoltsStathat.py
Created July 6, 2020 18:12
Send ardunio voltage sensor to Stathat
import RPi.GPIO as gpio
import smbus
import time
import sys
import struct
from datetime import datetime
from stathat import StatHat
stathat = StatHat()
import "sockaddr"
import "strings"
# todo - need to change logic to not `return false` on any hit of non-matching cidr
# as if multiple CIDRs here it will fail Sentinel rule any non-matching
allowed_cidrs = ["192.168.1.1/24","10.10.10.10/30"]
# First IP 192.168.1.0
# Last IP 192.168.1.255
# First IP 10.10.10.8
# Last IP 10.10.10.11
# this goes with https://gist.github.com/mikegreen/74d98e87224508c242eac10d024426b9
# cat dht22_test.py
import time
import adafruit_dht
import board
from datetime import datetime
# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT22(board.D17)
# this goes with https://gist.github.com/mikegreen/8a0860901c57e3b02277c82561754a1c
import RPi.GPIO as gpio
import smbus
import time
import sys
import struct
from datetime import datetime
bus = smbus.SMBus(1)
#include <Wire.h>
#define SLAVE_ADDRESS 0x04
#define LED 6
int number = 0;
// Pin that input voltage and resistors are connected
// doc here resistor setup
int inputPin = A0 ;
@mikegreen
mikegreen / packets.sh
Created June 24, 2020 22:41
packets per second
#!/bin/bash
time="1" # one second
int="ens3" # network interface
while true
do
txpkts_old="`cat /sys/class/net/$int/statistics/tx_packets`" # sent packets
rxpkts_old="`cat /sys/class/net/$int/statistics/rx_packets`" # recv packets
sleep $time
@mikegreen
mikegreen / vault_config.hcl
Last active June 23, 2020 19:45
Raft sample config
# vault_config.hcl
# to start: $ vault server -config=vault_raft.hcl
ui=true
disable_mlock = true
storage "raft" {
path = "/opt/vault/"
node_id = "raft_01"
}
listener "tcp" {
address = "127.0.0.1:8200"
#!/bin/bash
#Count TFE Metrics
#Requires TFE_TOKEN environment variable to be set to site admin api token
#Check for TFE_TOKEN
if [ -n "$TFE_TOKEN" ]; then
echo "----------------------------------"
echo "TFE Token detected!"
echo "----------------------------------"
else
@mikegreen
mikegreen / raft_migration.sh
Created May 13, 2020 15:05
Test Consul Vault to Raft/Integrated Storage Vault
#!/bin/bash
# this was shared by Nick on the Vault gg, all credit to him
# https://groups.google.com/d/msg/vault-tool/hmejXvIFuOU/M3bKDKFBBwAJ
# Test Vault migration from consul to raft.
# Dependencies: vault, consul, nc (netcat)
# Writes to (and blows away) ~/migrate_consul_to_raft.
# Kills any running vault or consul processes.
# Tested on MacOS and Linux.