summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <fcuny@twitter.com>2018-11-23 09:27:06 -0800
committerFranck Cuny <fcuny@twitter.com>2018-11-23 09:27:06 -0800
commit4492c5cfbe0e99666afed6780b674beaa670d1a1 (patch)
tree0b60557a2640f364ddeef4cbca9d72b2358e618b
parent[tmux] Small change to binding + fix terminal (diff)
downloademacs.d-4492c5cfbe0e99666afed6780b674beaa670d1a1.tar.gz
[bash] Let's try to use emacs tty
Diffstat (limited to '')
-rwxr-xr-xconfigs/rcs/bashrc2
-rw-r--r--configs/rcs/emacs.d/init.el37
-rw-r--r--playgrounds/aurora/fio.aurora45
-rw-r--r--playgrounds/aurora/hello-job.aurora22
-rw-r--r--playgrounds/aurora/iperf.aurora37
-rw-r--r--playgrounds/aurora/smf1-test-cron-job.aurora17
-rw-r--r--playgrounds/fio-bench.tgzbin0 -> 1189 bytes
-rw-r--r--playgrounds/fio/rand-read.fio16
-rw-r--r--playgrounds/fio/rand-write.fio14
-rwxr-xr-xplaygrounds/fio/runner.sh60
-rw-r--r--playgrounds/fio/seq-read.fio14
-rw-r--r--playgrounds/fio/seq-rw.fio17
-rw-r--r--playgrounds/fio/seq-write.fio14
-rwxr-xr-xscripts/cqlmetrics11
-rwxr-xr-xscripts/cqlq17
15 files changed, 311 insertions, 12 deletions
diff --git a/configs/rcs/bashrc b/configs/rcs/bashrc
index 42585a0..44995c8 100755
--- a/configs/rcs/bashrc
+++ b/configs/rcs/bashrc
@@ -1,4 +1,4 @@
-export EDITOR="emacsclient"
+export EDITOR="emacsclient -nw"
 export HISTFILE=
 export LANG="en_US.UTF-8"
 export LC_ALL="$LANG"
diff --git a/configs/rcs/emacs.d/init.el b/configs/rcs/emacs.d/init.el
index ff43b51..1abd6b1 100644
--- a/configs/rcs/emacs.d/init.el
+++ b/configs/rcs/emacs.d/init.el
@@ -100,7 +100,7 @@
   :config
   (progn
     (defun fcuny/setup-frame(&optional frame)
-      (fringe-mode '(5 . 5))
+      (fringe-mode '(8 . 8))
       (setq-default frame-title-format "%b")
       (set-face-attribute 'default nil :height 150 :weight 'normal :width 'normal :font "Source Code Pro")
       (when (eq system-type 'darwin)
@@ -146,13 +146,6 @@
   (setq auto-revert-verbose nil)
   (global-auto-revert-mode t))
 
-(use-package ido
-  :init
-  (ido-mode t)
-  :config
-  (setq ido-enable-prefix nil
-        ido-create-new-buffer 'always))
-
 (use-package hl-line
   :config
   (global-hl-line-mode t))
@@ -274,10 +267,10 @@
   :hook (go-mode . fcuny/go-mode-setup)
   :init
   (defun fcuny/go-mode-setup ()
-    (setq tab-width 2)
+    (setq tab-width 4)
     (add-hook 'before-save-hook 'gofmt-before-save))
   :config
-  (when (memq windows-system '(mac ns))
+  (when (memq window-system '(mac ns))
     (exec-path-from-shell-copy-env "GOPATH")))
 
 (use-package python
@@ -304,7 +297,9 @@
   :defer 5)
 
 (use-package puppet-mode
-  :ensure t)
+  :ensure t
+  :bind (:map puppet-mode-map
+              ("C-c |" . puppet-align-block)))
 
 (use-package yaml-mode
   :ensure t)
@@ -325,3 +320,23 @@
   :ensure t
   :hook ((protobuf-mode . flyspell-prog-mode)
          (protobuf-mode . flycheck-mode)))
+
+(use-package counsel
+  :ensure t
+  :init (counsel-mode 1) (ivy-mode 1)
+  :bind
+  (("M-x"     . counsel-M-x)
+   ("C-s"     . counsel-grep-or-swiper)
+   ("C-x C-f" . counsel-find-file)
+   ("C-x C-r" . counsel-recentf)
+   ("C-c f"   . counsel-git)
+   ("C-c s"   . counsel-git-grep)
+   ("C-c /"   . counsel-ag)
+   ("C-x r l" . counsel-bookmark))
+  :custom
+  (counsel-find-file-at-point t)
+  (ivy-use-virtual-buffers t)
+  (ivy-count-format "(%d/%d) ")
+  (ivy-height 10)
+  :config
+  (use-package swiper :ensure t))
diff --git a/playgrounds/aurora/fio.aurora b/playgrounds/aurora/fio.aurora
new file mode 100644
index 0000000..b26debf
--- /dev/null
+++ b/playgrounds/aurora/fio.aurora
@@ -0,0 +1,45 @@
+downloadFIO = Process(
+  name='download-fio',
+  cmdline='curl -o fio.rpm https://svn.twitter.biz/rpms/fio.x86_64/RPMS/x86_64/fio-1.50-2.twitter.x86_64.rpm'
+)
+
+installBenchs = Packer.install(
+  'fio-bench',
+  role = 'fcuny',
+  version = 'latest'
+)
+
+mvFIO = Process(
+  name='move-fio',
+  cmdline='mv fio/* . && rm -rf fio',
+)
+
+extractFIO = Process(
+  name='extract-fio',
+  cmdline='rpm2cpio fio.rpm | cpio -idmv'
+)
+
+runFIO = Process(
+  name='run-fio',
+  cmdline='./runner.sh',
+)
+
+jobs = [
+  Job(
+    cluster='smf1',
+    role='fcuny',
+    environment='devel',
+    name='fio',
+    task=Task(
+      processes=[downloadFIO, extractFIO, runFIO, installBenchs, mvFIO],
+      resources=Resources(cpu=4, ram=4096 * MB, disk=10 * GB),
+      constraints=order(installBenchs, mvFIO, downloadFIO, extractFIO, runFIO)
+    ),
+    instances=3,
+    constraints={
+      'base_platform': 'f4ww',
+      'dedicated': '*/manhattan',
+      'host': 'limit:1',
+    }
+  )
+]
diff --git a/playgrounds/aurora/hello-job.aurora b/playgrounds/aurora/hello-job.aurora
new file mode 100644
index 0000000..a825fdb
--- /dev/null
+++ b/playgrounds/aurora/hello-job.aurora
@@ -0,0 +1,22 @@
+hello_date = Process(
+  name='hello-date',
+  cmdline='while true; do date; sleep 10; done'
+)
+
+jobs = [
+  Service(
+    cluster='smf1',
+    environment='devel',
+    role='fcuny',
+    name='hello-date',
+    task=Task(
+      processes=[hello_date],
+      resources=Resources(cpu=10, ram=1024 * MB, disk=512 * MB)
+    ),
+    instances=1,
+    constraints={
+      'host': 'smf1-fki-16-sr1',
+      'dedicated': '*/manhattan',
+    }
+  )
+]
diff --git a/playgrounds/aurora/iperf.aurora b/playgrounds/aurora/iperf.aurora
new file mode 100644
index 0000000..e071bd2
--- /dev/null
+++ b/playgrounds/aurora/iperf.aurora
@@ -0,0 +1,37 @@
+class StandardProfile(Struct):
+  environment=Default(String, 'prod')
+  tier=Default(String, 'preferred')
+
+DevelProfile = StandardProfile(
+  environment = 'devel',
+  tier = 'preemptible',
+)
+
+api = Process(
+  name = 'iperf',
+  cmdline = '/usr/bin/iperf3 -s -p {{thermos.ports[http]}}'
+)
+
+task = Task(
+  name = api.name(),
+  resources = Resources(cpu = 1.0, ram = 4 * GB, disk = 1 * GB),
+  processes = [api]
+)
+
+service_template = Service(
+  role='fcuny',
+  name = 'iperf',
+  environment='{{profile.environment}}',
+  task = task,
+  instances = 3,
+  contact = 'fcuny@twitter.com',
+  announce=Announcer(),
+  tier ='{{profile.tier}}',
+  constraints={
+    'host': 'smf1-bgr-27-sr1',
+  }
+)
+
+jobs = [
+  service_template(cluster='smf1-test').bind(profile=DevelProfile()),
+]
diff --git a/playgrounds/aurora/smf1-test-cron-job.aurora b/playgrounds/aurora/smf1-test-cron-job.aurora
new file mode 100644
index 0000000..3ade1b4
--- /dev/null
+++ b/playgrounds/aurora/smf1-test-cron-job.aurora
@@ -0,0 +1,17 @@
+# A cron job that runs every 5 minutes.
+jobs = [
+  Job(
+    cluster = 'smf1-test',
+    role = 'fcuny',
+    environment = 'test',
+    name = 'cron_hello_world-trashing',
+    cron_schedule = '*/5 * * * *',
+    constraints = {
+        'host': 'smf1-fki-17-sr1',
+    },
+    instances=10,
+    task = SimpleTask(
+      'cron_hello_world',
+      'echo "Hello world from cron, the time is now $(date --rfc-822)"'),
+  ),
+]
diff --git a/playgrounds/fio-bench.tgz b/playgrounds/fio-bench.tgz
new file mode 100644
index 0000000..06ff644
--- /dev/null
+++ b/playgrounds/fio-bench.tgz
Binary files differdiff --git a/playgrounds/fio/rand-read.fio b/playgrounds/fio/rand-read.fio
new file mode 100644
index 0000000..8d473af
--- /dev/null
+++ b/playgrounds/fio/rand-read.fio
@@ -0,0 +1,16 @@
+[global]
+name=fio-rand-RW
+filename=./data/fio-rand-RW
+rw=randrw
+rwmixread=60
+rwmixwrite=40
+bs=4K
+direct=0
+numjobs=4
+time_based=1
+runtime=900
+
+[file1]
+size=8G
+ioengine=libaio
+iodepth=16
diff --git a/playgrounds/fio/rand-write.fio b/playgrounds/fio/rand-write.fio
new file mode 100644
index 0000000..5564414
--- /dev/null
+++ b/playgrounds/fio/rand-write.fio
@@ -0,0 +1,14 @@
+[global]
+name=fio-rand-write
+filename=./data/fio-rand-write
+rw=randwrite
+bs=4K
+direct=0
+numjobs=4
+time_based=1
+runtime=900
+
+[file1]
+size=8G
+ioengine=libaio
+iodepth=16
diff --git a/playgrounds/fio/runner.sh b/playgrounds/fio/runner.sh
new file mode 100755
index 0000000..8df8895
--- /dev/null
+++ b/playgrounds/fio/runner.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+## Helper script to run fio tests and generate reports
+
+DATA_DIR=./data
+LOG_DIR=./logs
+REPORT_DIR=./reports
+
+FIO_BIN=./usr/bin/fio
+if [ "${2}x" != "x" ]; then
+  FIO_BIN=${2}
+fi
+
+FIOS_LIST=$(ls *.fio)
+NOW_EPOCH=$(date +"%s")
+LOG_DIR_READS=${LOG_DIR}/reads
+LOG_DIR_WRITES=${LOG_DIR}/writes
+
+# create required directories
+mkdir -p ${DATA_DIR}
+
+if [ -d "${REPORT_DIR}" ]; then
+  echo "Report directory exists, archiving using current timestamp: ${NOW_EPOCH}"
+  mv ${REPORT_DIR} ${REPORT_DIR}_${NOW_EPOCH}
+fi
+mkdir -p ${REPORT_DIR}
+
+if [ -d "${LOG_DIR}" ]; then
+  echo "Log directory exists, archiving using current timestamp: ${NOW_EPOCH}"
+  mv ${LOG_DIR} ${LOG_DIR}_${NOW_EPOCH}
+fi
+mkdir -p ${LOG_DIR_WRITES}
+mkdir -p ${LOG_DIR_READS}
+
+# run all fios in sequential order
+for i in $(echo ${FIOS_LIST} | tr " " "\n")
+do
+  echo -e "\nStarting fio test ${i}..."
+  ${FIO_BIN} ./${i} --output ${REPORT_DIR}/${i}.out
+
+  mv *read*.log ${LOG_DIR_READS}/
+  mv *write*.log ${LOG_DIR_WRITES}/
+
+  rm -f data/*   # delete created fio files after each run
+
+  echo "Completed fio test ${i}."
+done
+
+# plot reports to svg
+FIO_PLOT_BIN=./usr/bin/fio_generate_plots
+if type "${FIO_PLOT_BIN}" > /dev/null && type "gnuplot" > /dev/null; then
+
+  echo "fio_generate_plots is installed generating svg reports based on fio logs"
+
+  ( cd ${LOG_DIR_READS} && for f in *.log; do mv $f ${f/.[1-3]/}; done && ${FIO_PLOT_BIN} "All-Reads" )
+  ( cd ${LOG_DIR_WRITES} && for f in *.log; do mv $f ${f/.[1-3]/}; done && ${FIO_PLOT_BIN} "All-Writes" )
+
+  mv ${LOG_DIR_READS}/*.svg ${REPORT_DIR}/
+  mv ${LOG_DIR_WRITES}/*.svg ${REPORT_DIR}/
+fi
diff --git a/playgrounds/fio/seq-read.fio b/playgrounds/fio/seq-read.fio
new file mode 100644
index 0000000..c3225a3
--- /dev/null
+++ b/playgrounds/fio/seq-read.fio
@@ -0,0 +1,14 @@
+[global]
+name=fio-seq-reads
+filename=./data/fio-seq-reads
+rw=read
+bs=256K
+direct=1
+numjobs=1
+time_based=1
+runtime=900
+
+[file1]
+size=8G
+ioengine=libaio
+iodepth=16
diff --git a/playgrounds/fio/seq-rw.fio b/playgrounds/fio/seq-rw.fio
new file mode 100644
index 0000000..81c50e7
--- /dev/null
+++ b/playgrounds/fio/seq-rw.fio
@@ -0,0 +1,17 @@
+[global]
+name=fio-seq-RW
+filename=./data/fio-seq-RW
+rw=rw
+rwmixread=60
+rwmixwrite=40
+bs=256K
+direct=0
+numjobs=4
+time_based=1
+runtime=900
+
+[file1]
+size=8G
+ioengine=libaio
+iodepth=16
+
diff --git a/playgrounds/fio/seq-write.fio b/playgrounds/fio/seq-write.fio
new file mode 100644
index 0000000..88fbeaa
--- /dev/null
+++ b/playgrounds/fio/seq-write.fio
@@ -0,0 +1,14 @@
+[global]
+name=fio-seq-write
+filename=./data/fio-seq-write
+rw=write
+bs=256K
+direct=0
+numjobs=1
+time_based=1
+runtime=900
+
+[file1]
+size=8G
+ioengine=libaio
+iodepth=16
diff --git a/scripts/cqlmetrics b/scripts/cqlmetrics
new file mode 100755
index 0000000..db3db6a
--- /dev/null
+++ b/scripts/cqlmetrics
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+service=$1
+
+if [ -z "${service}" ]; then
+  exit 1
+fi
+
+zone="${2:-smf1}"
+
+echo $(cql -z "${zone}" k "${service}" "sd.${service}" | fzf)
diff --git a/scripts/cqlq b/scripts/cqlq
new file mode 100755
index 0000000..bf47c50
--- /dev/null
+++ b/scripts/cqlq
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+service=$1
+if [ -z "${service}" ]; then
+  exit 1
+fi
+
+zone="${2:-smf1}"
+
+metric=$(cqlmetrics "${service}" "${zone}")
+
+query="zone(${zone}, ts(${service}, members(sd.${service}), ${metric}))"
+
+short_id=$(curl -s --negotiate -u : -X POST https://monitoring.twitter.biz/api/2/url/shortener --data "{\"longUrl\":\"/query?&queries=%5B%7B%22id%22%3A%22query-1%22%2C%22name%22%3A%22Query%201%22%2C%22query%22%3A%22$query%22%2C%22settings%22%3A%7B%22visible%22%3Atrue%7D%7D%5D\"}" | jq '.id')
+
+echo "http://monitoring.twitter.biz/tiny/${short_id}"
+open "http://monitoring.twitter.biz/tiny/${short_id}"