Skip to content

Instantly share code, notes, and snippets.

@wbollock
wbollock / label_pair.py
Created January 19, 2024 18:28
label_pair.py
#!/usr/bin/python3
# calculate average bytes per label pair for a given metric
def calculate_average_bytes_per_label_pair(metric_string):
# Splitting the metric string into label pairs
label_pairs = metric_string.split(", ")
# Calculating the total bytes
total_bytes = sum(len(pair) for pair in label_pairs)
@wbollock
wbollock / dashboard.json
Last active December 14, 2022 23:10
nagios_exporter dashboard without instance
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@wbollock
wbollock / kraken-btc.sh
Created February 11, 2021 00:40
Crpyto (Kraken) Polybar
#!/bin/sh
API="https://api.kraken.com/0/public/Ticker"
quote=$(curl -sf $API?pair=BTCUSD | jq -r ".result.XXBTZUSD.c[0]")
quote=$(LANG=C printf "%.2f" "$quote")
echo " \$$quote "
@wbollock
wbollock / coinbash-btc.sh
Created February 10, 2021 16:59
coinbash ETH and BTC for polybar
#!/bin/bash
btcprice=$(/home/<your user>/.config/polybar/scripts/coinbash.sh -l btc | grep "BTC" | cut -c 24-32)
echo " \$$btcprice"
# NOTE: credit for coinbash.sh here
# https://github.com/8go/coinbash
# MUST get coinmarketcap API key - free
@wbollock
wbollock / classweb_login.sh
Created September 2, 2020 16:35
bash script that checks for new /home/folders, creates mysql account with random password + salt, and emails to students and a service desk email
#!/bin/bash
# made by Will Bollock, CCI HelpDesk
# mysql root user/pass for account creation
rootuser=
rootpasswd=
informationFile=Torch_Account_Information.txt
# master file that is copied to $user's home
# make an HTML template here
# html email template here