Skip to content

Instantly share code, notes, and snippets.

View Ziaunys's full-sized avatar

Eric Zounes Ziaunys

  • Perforce
  • Portland, OR
View GitHub Profile
@Ziaunys
Ziaunys / migration-prep.sh
Last active July 14, 2020 19:14
A small script to generate the request object needed to trigger a migration
TOKEN_NAME=$(kubectl -n cd4pe get secrets | grep ^cd4pe-migration | cut -f1 -d ' ')
SERVICE_ACCOUNT_TOKEN=$(kubectl -n cd4pe get secret $TOKEN_NAME -o jsonpath="{['data']['token']}")
K8S_API_URL=$(kubectl config view --minify -o jsonpath='{.clusters[*].cluster.server}')
K8S_CA_CERT=$(kubectl config view --raw --minify -o jsonpath='{.clusters[*].cluster.certificate-authority-data}')
cat <<EOF > migrate-to-replicated-request-local-generated.json
{
"op": "MigrateToReplicated",
"content": {
"k8sApiserverUrl": "$K8S_API_URL",
"k8sServiceAccountTokenBase64": "$SERVICE_ACCOUNT_TOKEN",
@Ziaunys
Ziaunys / icinga_notifier.py
Created October 25, 2017 20:44
Icinga Notifier Code
#!/usr/bin/python
import datetime
import os
import re
class Notifier(object):
def _get_icinga_macros(self):
@Ziaunys
Ziaunys / load_partitioned_files.sh
Last active July 20, 2017 20:45
BigQuery Load Script
#!/usr/bin/env bash
STAGING_DIR="./bq_staging"
FILE_PREFIX="runs"
FS="_"
START_DATE="2017-04-18"
END_DATE="2017-07-10"
CURRENT_DATE=$START_DATE
while [ $CURRENT_DATE != $END_DATE ]
do
@Ziaunys
Ziaunys / gist:22fcce4a90d1fd002eab
Created January 25, 2016 19:45
Icinga2 openssl exception
[2016-01-22 15:53:22 -0800] warning/JsonRpcConnection: Error while reading JSON-RPC message for identity 'icinga-master01-prod.ops.puppetlabs.net': Error: std::exception
(0) libbase.so: void boost::throw_exception<icinga::openssl_error>(icinga::openssl_error const&) (+0x4a) [0x7f679b2be5ca]
(1) libbase.so: void boost::exception_detail::throw_exception_<icinga::openssl_error>(icinga::openssl_error const&, char const*, char const*, int) (+0x3c) [0x7f679b2be62c]
(2) libbase.so: icinga::TlsStream::HandleError() const (+0xb8) [0x7f679b256f78]
(3) libbase.so: icinga::TlsStream::Read(void*, unsigned long, bool) (+0x80) [0x7f679b257010]
(4) libbase.so: icinga::StreamReadContext::FillFromStream(boost::intrusive_ptr<icinga::Stream> const&, bool) (+0x4f) [0x7f679b25b51f]
(5) libbase.so: icinga::NetString::ReadStringFromStream(boost::intrusive_ptr<icinga::Stream> const&, icinga::String*, icinga::StreamReadContext&, bool) (+0x21e) [0x7f679b25b9ce]
(6) libremote.so:
@Ziaunys
Ziaunys / pre-commit
Created January 20, 2016 00:10
Puppet parser validation pre-commit hook
#!/bin/sh
syntax_errors=0
error_msg=$(mktemp /tmp/error_msg.XXXXXX)
if git rev-parse --quiet --verify HEAD > /dev/null
then
against=HEAD
else
# Initial commit: diff against an empty tree object
@Ziaunys
Ziaunys / pre-commit.sh
Created October 21, 2015 21:59
puppet parser validate pre-commit hook
#!/bin/sh
syntax_errors=0
error_msg=$(mktemp /tmp/error_msg.XXXXXX)
if git rev-parse --quiet --verify HEAD > /dev/null
then
against=HEAD
else
# Initial commit: diff against an empty tree object
@Ziaunys
Ziaunys / gist:cc364aa3bed01385c110
Created April 22, 2015 23:41
icingaweb2 nginx config example
server {
listen *:80;
root /usr/share/icingaweb2/public;
access_log /var/log/nginx/ssl-icingaweb2_app.access.log;
error_log /var/log/nginx/ssl-icingaweb2_app.error.log;
location ~ ^/icingaweb2(.+)? {
alias /usr/share/icingaweb2/public;
index index.php
@Ziaunys
Ziaunys / gorilla mux
Last active December 31, 2015 23:29
Mux laziness..
type Handler struct {
Function func(http.ResponseWriter, *http.Request)
Methods []string
}
func AddHandlers(r *mux.Router, handles map[string]Handler) {
for k, v := range handles {
r.HandleFunc(k, v.Function).Methods(v.Methods...)
}