Skip to content

Instantly share code, notes, and snippets.

View linuxkidd's full-sized avatar

Michael J. Kidd linuxkidd

View GitHub Profile
@linuxkidd
linuxkidd / findsqmle.py
Created July 13, 2023 22:03
Python 3 SQM-LE Finder
#!/usr/bin/python
import socket, time, signal, sys
def signal_handler(signal, frame):
print('\nCtrl-C received from keyboard - script exiting')
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
@linuxkidd
linuxkidd / nginx-speedify
Last active December 23, 2022 16:25
Speedify GUI on the LAN
#############################################################################
#############################################################################
## Safe this file as:
## /etc/nginx/sites-enabled/nginx-speedify
##
## Assumptions:
## - You have Speedify and Speedify GUI packages installed
##
## Notes:
## 1. You may wish to change the 'listen' ports to prevent conflicts with
@linuxkidd
linuxkidd / update_rbd_directory.py
Last active March 16, 2022 16:22
Recreate entries in rbd_directory omap which were destroyed.
#!/usr/bin/env python
"""
Filename: update_rbd_directory.py
Written by: Michael J. Kidd aka linuxkidd
Version: 2.0
Last modified: 2022-03-16
Usage help:
./update_rbd_directory.py --help
@linuxkidd
linuxkidd / order.awk
Created January 31, 2022 16:53 — forked from ronen-fr/order.awk
gawk -v PGID=21.37a7 -f order.awk < log
#!/bin/gawk
# call with the "pg of interest" as parameter, as in:
# gawk -v PGID=21.37a7 -f this-file < log
func logtm(tst)
{
gsub(/[:.]/," ",tst); split(tst,x);
return x[1]*3600 + x[2]*60 + x[3] + x[4]/1000.0
}
@linuxkidd
linuxkidd / proc_sar_disk_util_histo.awk
Last active October 1, 2020 16:13
Process sar disk %util into a histogram
#!/usr/bin/awk -f
/^[0-9].*dev[0-9]*-[0-9]*/{
diskpos=2
if ( $2 ~ /(A|P)M/ )
diskpos=3
dev[$diskpos]=1
histo[$diskpos][int($NF)]++
}
@linuxkidd
linuxkidd / proc_sar_disk_await_histo.awk
Created October 1, 2020 16:09
Process sar disk await into a histogram
#!/usr/bin/awk -f
/^[0-9].*dev[0-9]*-[0-9]*/{
diskpos=2
awaitpos=8
if ( $2 ~ /(A|P)M/ ) {
diskpos=3
awaitpos=9
}
dev[$diskpos]=1
@linuxkidd
linuxkidd / proc_sar_disk.awk
Last active October 1, 2020 16:08
Process disk data from sar data collection
#!/usr/bin/awk -f
function mydtstamp(mydt) {
split($1,tparts,":")
switch($2){
case "AM":
if(tparts[1]==12)
tparts[1]="00"
break
case "PM":
@linuxkidd
linuxkidd / populate_coachproxy.py
Created September 30, 2020 01:32
cat features.json | ./populate_coachproxy.py
#!/usr/bin/python3
import array,json,paho.mqtt.client as mqtt,re,sys,time
mqttc=mqtt.Client("cpimporter")
mqttc.connect("172.16.22.2", port=1883)
debugout=0
cleartopic=0
publishtopic=1
@linuxkidd
linuxkidd / GPSd_2_HomeAssistant.md
Created July 5, 2020 23:41
Pipe GPSd into Home-Assistant, and update position automatically

I used 'gpsd' running on linux, along with node-red (with the node-red-contrib-gpsd node to make a GPS to MQTT bridge.

Node Flow:

#!/usr/bin/env python
import argparse,json,math,re,signal,sys
from subprocess import Popen, PIPE
from StringIO import StringIO
from pprint import pprint
parser = argparse.ArgumentParser(description='Custom script inconsistent PG cleanup')
parser.add_argument("--id",dest="pgid",required=True,help="Provide the PG id for this list-inconstent-obj output.")