Skip to content

Instantly share code, notes, and snippets.

View mzupan's full-sized avatar

Mike Zupan mzupan

View GitHub Profile
@mzupan
mzupan / mimir s3 policy
Last active April 25, 2022 11:45
helm install for grafana mimir with s3 and IAM instance role
Grafana url for mimir datasource
http://mimir-nginx.mimir.svc.cluster.local./prometheus
locals {
tags = "${merge(
var.env_tags,
map(
"Name", "${var.name}",
"environment", "${var.name}",
"terraform", "true",
)
)}"
@mzupan
mzupan / services.go
Created February 8, 2018 21:43
Pulling out kubernetes services with the first port in Go
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/kubernetes"
#!/bin/bash
if [ "$(id -u)" = "0" ]; then
echo
echo "Do not run as root. Run as your user"
exit 2
fi
usage() { echo "Usage: $0 -t <time needed> <salt-feature-branch>" 1>&2; exit 1; }
@mzupan
mzupan / module_sensu.py
Created February 5, 2016 14:51
sensu salt module and state. Not 100% but it creates/deletes
# -*- coding: utf-8 -*-
'''
Support for Sensu
.. note::
The functions in here are generic functions designed to work with
all sensu.
'''
import logging
import os
#!/usr/bin/env python
import os
import sys
import glob
import argparse
from subprocess import Popen, PIPE, STDOUT
try:
@mzupan
mzupan / lambda.py
Last active June 8, 2021 05:19
AWS Lambda job to backup RDS instances
import boto3
import datetime
def lambda_handler(event, context):
print("Connecting to RDS")
client = boto3.client('rds')
print("RDS snapshot backups stated at %s...\n" % datetime.datetime.now())
client.create_db_snapshot(
DBInstanceIdentifier='web-platform-slave',
@mzupan
mzupan / json_tail.py
Last active August 29, 2015 14:25
A simple python script to format json logs getting pipped in from stdin
#!/usr/bin/env python
import sys
import json
def print_json(l):
try:
j = json.loads(l)
print json.dumps(j, indent=4, sort_keys=True)
{
"mailer": {
"admin_gui": "http://monitor.domain.com/",
"mail_from": "sensu@domain.com",
"mail_to": "tech@domain.com",
"smtp_domain": "domain.com"
}
}
@mzupan
mzupan / README
Created November 9, 2014 11:44
Sensu extension for bigpanda.io
Install
--------------------
1) Put the bigpanda.rb file in /etc/sensu/extensions
2) Edit the bigpanda.json file for your API token and place it in /etc/sensu/conf.d
3) restart sensu