Skip to content

Instantly share code, notes, and snippets.

View phagedorn's full-sized avatar

Phillip Hagedorn phagedorn

  • HDI AG
  • Ha, Germany
View GitHub Profile
@phagedorn
phagedorn / create_launch_configuration_and_autoscaling_group.sh
Created January 26, 2018 11:05
create_launch_configuration_and_autoscaling_group.sh (quick and dirty)
#!/bin/bash
####### launch-configuration
ami=ami-af79ebc0
my_launch_config=copcc-2-test
my_key_pair=copcc-02 # aws ec2 describe-key-pairs|grep KeyName
instance_type=t2.nano
#my_userdata=
#######
@phagedorn
phagedorn / scale_instances.sh
Created January 25, 2018 22:01
scale aws autoscaling group via cli (quick and dirty)
#!/bin/bash
# scale_instances.sh -g AUTOSCALING_GROUP -c DESIRED_CAPACITY
# e.g. scale_instances -g copcc-02 -c 3
########### read parameter ####
while getopts c:g: option
do
case "${option}"
<?php
####### graphite sqlite events migration to mysql #######
####### phillip.hagedorn@gmail.com #######
# php-sqlite3 php-mysql
####### configuration #######
# source configuration for sqlite
$sqlite_file = "graphite.db";
@phagedorn
phagedorn / gist:65d9367dca63a5232e40
Last active August 29, 2015 14:06
top_5_largest_tables.sql
# Query to list top 5 largest tables in the database
# http://www.thegeekstuff.com/2008/11/overview-of-mysql-information_schema-database-with-practical-examples/
# This examples gives the top 5 largest space occupying tables in the database along with it’s size in MB.
SELECT concat(table_schema,'.',table_name) table_name,
concat(round(data_length/(1024*1024),2),'M') data_length
FROM information_schema.TABLES
ORDER BY data_length DESC LIMIT 5
@phagedorn
phagedorn / gist:ebee21579b259187024c
Last active August 29, 2015 14:06
more_then_1000_rows.sql
# Query to display tables with more than 1000 rows
# http://www.thegeekstuff.com/2008/11/overview-of-mysql-information_schema-database-with-practical-examples/
#Using the above mentioned information_schema tables you can build your own query to get metadata information. This example displays #the MySQL tables that have more than 1000 rows.
select concat(table_schema,'.',table_name) as table_name,table_rows
from information_schema.tables where table_rows > 1000
order by table_rows desc;
@phagedorn
phagedorn / grafana_build_master.sh
Last active August 29, 2015 14:05
Install grafana master on debian wheezy 64
#!/bin/bash
echo "- Install prerequirements"
echo "-- Install build tools"
apt-get update
apt-get install -y build-essential git curl
echo "-- Install NodsJS"
curl -sL https://deb.nodesource.com/setup | bash -
apt-get -y install nodejs
echo "- Build Grafana"
echo "-- Checkout Grafana sources"
@phagedorn
phagedorn / gist:b1f310cdebb7e89c3e54
Last active September 29, 2015 08:53
MySQLL Table size as MB/GB...
SELECT TABLE_NAME AS "Table",
TABLE_ROWS AS "Rows",
CONCAT((FORMAT((DATA_LENGTH) / POWER(1024,2),2)), ' Mb') AS "Data Size",
CONCAT((FORMAT((INDEX_LENGTH) / POWER(1024,2),2)), ' Mb') AS "Index Size",
CONCAT((FORMAT((DATA_LENGTH+ INDEX_LENGTH) / POWER(1024,2),2)), ' Mb') AS "Total Size",
TRIM(TRAILING ', ' FROM CONCAT_WS(', ', ENGINE, TABLE_COLLATION, CREATE_OPTIONS)) AS "Type"
FROM information_schema.TABLES
WHERE information_schema.TABLES.table_schema = "schema_name"
@phagedorn
phagedorn / grafana-authentication-proxy
Last active August 29, 2015 14:04
Init.d script grafana-authentication-proxy-init
#!/bin/sh
### BEGIN INIT INFO
# Provides: grafana-authentication-proxy
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: grafana-authentication-proxy
### END INIT INFO
@phagedorn
phagedorn / grafana_dashboards_backup.py
Last active August 29, 2015 14:04 — forked from jaimegago/gist:11229750
grafana_dashboards_backup.py
#!/usr/bin/python -tt
#
import datetime
import json
import logging
import logging.handlers
import optparse
import os
import re
import sys