Skip to content

Instantly share code, notes, and snippets.

@strarsis
strarsis / Terminal
Last active January 2, 2016 22:43
Traefik test
docker run -d -p 8080:8080 -p 80:80 -v $PWD/traefik.toml:/traefik.toml emilevauge/traefik
@strarsis
strarsis / gist:9678545f91d76a3a7afa307c7389435b
Created December 5, 2016 23:01 — forked from mjpowersjr/gist:740a9583e9ec8b49e0a3
Parsing the MySQL slow query log via Logstash (the easy way?)

The MySQL slow query log is a difficult format to extract information from. After looking at various examples with mixed results, I realized that it's much easier to configure MySQL to write the slow query log to a table in CSV format!

From the MySQL documentation:

By default, the log tables use the CSV storage engine that writes data in comma-separated values format. For users who have access to the .CSV files that contain log table data, the files are easy to import into other programs such as spreadsheets that can process CSV input.

my.cnf

Note: don't forget to open up permissions on your slow query log CSV file so logstash can read it!

# enable slow query log
@strarsis
strarsis / maillog.json
Created December 7, 2016 22:59 — forked from TinLe/maillog.json
maillog elasticsearch mapping template
{
"template" : "maillog-*",
"order" : 1,
"settings" : {
"number_of_shards" : 2,
"index.refresh_interval" : "90s"
},
"mappings" : {
"maillog" : {
"properties" : {
@strarsis
strarsis / logstash.conf
Created December 7, 2016 22:59 — forked from TinLe/logstash.conf
my logstash.conf file for postfix
input {
file {
path => "/var/log/maillog*"
exclude => "*.gz"
start_position => "beginning"
type => "maillog"
}
}
filter {
if [type] == "maillog" {
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
0 info it worked if it ends with ok
1 verbose cli [ '/root/.nvm/versions/node/v4.8.0/bin/node',
1 verbose cli '/root/.nvm/versions/node/v4.8.0/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'sharp' ]
2 info using npm@4.2.0
3 info using node@v4.8.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
@strarsis
strarsis / catVagrantfilePure.sh
Created February 26, 2017 15:36 — forked from fedir/catVagrantfilePure.sh
Strip Vagrantfile from comments and empty lines
#!/bin/bash
cat Vagrantfile | grep -vE '(^[[:space:]]*($|(#|!|;|//)))'
cat Vagrantfile | grep -vE '(^[[:space:]]*($|(#)))'
2017-02-28 17:27:41,215 p=23611 u=build | Using <redacted project folder path>/trellis/ansible.cfg as config file
2017-02-28 17:27:41,338 p=23611 u=build | statically included: <redacted project folder path>/trellis/roles/common/tasks/disable_challenge_sites.yml
2017-02-28 17:27:41,345 p=23611 u=build | statically included: <redacted project folder path>/trellis/roles/common/tasks/reload_nginx.yml
2017-02-28 17:27:41,470 p=23611 u=build | statically included: <redacted project folder path>/trellis/roles/users/tasks/connection-warnings.yml
2017-02-28 17:27:41,611 p=23611 u=build | statically included: <redacted project folder path>/trellis/vendor/roles/composer/tasks/global-require.yml
2017-02-28 17:27:41,653 p=23611 u=build | statically included: <redacted project folder path>/trellis/roles/letsencrypt/tasks/setup.yml
2017-02-28 17:27:41,668 p=23611 u=build | statically included: <redacted project folder path>/trellis/roles/letsencrypt/tasks/nginx.yml
2017-02-28 17:27:41,679 p=23611 u=build | statical
INFO global: Vagrant version: 1.9.1
INFO global: Ruby version: 2.2.5
INFO global: RubyGems version: 2.4.5.1
INFO global: VAGRANT_LOG="info"
INFO global: VAGRANT_OLD_ENV_IRBRC="/home/<redacted>/.rvm/rubies/ruby-2.4.0/.irbrc"
INFO global: VAGRANT_OLD_ENV_LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*
@strarsis
strarsis / deploy-hooks share-after.yml
Created April 2, 2017 21:30 — forked from mockey/deploy-hooks share-after.yml
Add wp language files on trellis deploy
---
- block:
- name: Install language files
command: wp core language install {{ item }}
args:
chdir: "{{ deploy_helper.new_release_path }}"
# check for existance of po-file, language install should only run once:
creates: "{{ deploy_helper.new_release_path }}/web/app/languages/{{ item }}.po"
with_items: "{{ project.languages }}"