-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from thalesmg/shortids
sync latest changes to master
- Loading branch information
Showing
17 changed files
with
367 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
|
||
- name: define hosts | ||
hosts: localhost | ||
gather_facts: no | ||
roles: | ||
- define_inventory | ||
|
||
- name: fetch logs | ||
hosts: emqx | ||
become: yes | ||
become_user: root | ||
tasks: | ||
- name: syslog | ||
fetch: | ||
src: "/var/log/syslog" | ||
dest: "./tmp/data/{{ emqx_script_result_file }}/{{ inventory_hostname_short }}/syslog" | ||
flat: yes | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
|
||
- name: define hosts | ||
hosts: localhost | ||
gather_facts: no | ||
roles: | ||
- define_inventory | ||
|
||
- name: stop emqx and clean logs | ||
hosts: emqx | ||
become: yes | ||
become_user: root | ||
roles: | ||
- stop_emqx | ||
- clean_logs | ||
|
||
- name: start cores | ||
hosts: cores | ||
become: yes | ||
become_user: root | ||
roles: | ||
- start_emqx | ||
|
||
- name: start replicants | ||
hosts: replicants | ||
become: yes | ||
become_user: root | ||
roles: | ||
- start_emqx | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
#!/usr/bin/env bb | ||
;; -*- mode: clojure; -*- | ||
|
||
(let [[bastion-ip num-emqx] *command-line-args* | ||
emqxs (map #(str "emqx-" % ".int.thalesmg") (range (Integer/parseInt num-emqx)))] | ||
(doseq [emqx emqxs] | ||
(println (str "ssh" | ||
" -o StrictHostKeyChecking=no" | ||
" -J ec2-user@" | ||
bastion-ip | ||
" ubuntu@" | ||
emqx)))) | ||
(let [[bastion-ip num-emqx num-cores] *command-line-args* | ||
emqxs (map #(str "emqx-" % ".int.thalesmg") (range (Integer/parseInt num-emqx))) | ||
make-line (fn [emqx] | ||
(str "ssh" | ||
" -o StrictHostKeyChecking=no" | ||
" -J ec2-user@" | ||
bastion-ip | ||
" ubuntu@" | ||
emqx)) | ||
cores (->> emqxs | ||
(take (Integer/parseInt num-cores)) | ||
(map make-line) | ||
(str/join "\n")) | ||
replicants (->> emqxs | ||
(drop (Integer/parseInt num-cores)) | ||
(map make-line) | ||
(str/join "\n")) | ||
all (str/join "\n" [cores replicants])] | ||
(spit "par-hosts.txt" all) | ||
(spit "cores.txt" cores) | ||
(spit "replicants.txt" replicants) | ||
(println all)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- name: clear mnesia dir | ||
shell: "rm -rf /var/lib/emqx/mnesia/*" | ||
|
||
- name: clear emqx logs | ||
shell: "rm -rf /var/log/emqx/*" | ||
|
||
- name: clear syslog | ||
shell: "echo > /var/log/syslog" | ||
|
||
- name: clear mem ets dumps | ||
shell: "rm /tmp/*_mem-ets-dump.txt" | ||
ignore_errors: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
|
||
- name: produce node_dump | ||
shell: "/usr/lib/emqx/bin/node_dump" | ||
register: node_dump_invoke | ||
ignore_errors: yes | ||
- name: find node dump location | ||
when: not node_dump_invoke.failed | ||
set_fact: | ||
node_dump_path: "{{ node_dump_invoke.stdout | regex_search(regexp, '\\1') }}" | ||
vars: | ||
regexp: "Created a node dump (.+)" | ||
- name: fetch node dump | ||
when: not node_dump_invoke.failed and node_dump_path is defined and node_dump_path | ||
fetch: | ||
src: "{{ node_dump_path[0] }}" | ||
dest: "./tmp/data/{{ emqx_script_result_file }}/{{ inventory_hostname_short }}-node_dump.tar.gz" | ||
flat: yes | ||
- name: crashdump? | ||
stat: | ||
path: "/var/log/emqx/erl_crash.dump" | ||
register: crashdump_stat | ||
- name: syslog? | ||
stat: | ||
path: "/var/log/syslog" | ||
register: syslog_stat | ||
- name: fetch crashdump | ||
when: crashdump_stat.stat.exists | ||
fetch: | ||
src: "{{ crashdump_stat.stat.path }}" | ||
dest: "./tmp/data/{{ emqx_script_result_file }}/{{ inventory_hostname_short }}-crashdump" | ||
flat: yes | ||
- name: fetch syslog | ||
when: syslog_stat.stat.exists | ||
fetch: | ||
src: "{{ syslog_stat.stat.path }}" | ||
dest: "./tmp/data/{{ emqx_script_result_file }}/{{ inventory_hostname_short }}-syslog" | ||
flat: yes | ||
- name: find mem ets dumps | ||
shell: "ls /tmp/*_mem-ets-dump.txt 2>/dev/null || true" | ||
register: mem_ets_dumps | ||
- name: tar mem ets dumps | ||
when: mem_ets_dumps.stdout_lines | ||
shell: | | ||
cd /tmp | ||
tar -cjf {{ emqx_script_result_file }}.mem-ets-dump.tar.bz2 *_mem-ets-dump.txt | ||
- name: fetch mem ets dumps | ||
when: mem_ets_dumps.stdout_lines | ||
fetch: | ||
src: "/tmp/{{ emqx_script_result_file }}.mem-ets-dump.tar.bz2" | ||
dest: "./tmp/data/{{ emqx_script_result_file }}/{{ inventory_hostname_short }}-mem-ets-dump.tar.bz2" | ||
flat: yes | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
|
||
- name: results? | ||
stat: | ||
path: "./tmp/data/{{ emqx_script_result_file }}" | ||
register: results_stat | ||
- block: | ||
- name: copy to destination | ||
copy: | ||
remote_src: yes | ||
src: "{{ results_stat.stat.path }}" | ||
dest: "{{ emqx_script_result_dest }}/" | ||
- name: remove original | ||
file: | ||
path: "{{ results_stat.stat.path }}" | ||
state: absent | ||
when: results_stat.stat.exists and results_stat.stat.isdir and emqx_script_result_dest is defined and emqx_script_result_dest | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- name: start emqx | ||
shell: emqx start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- name: stop systemd emqx | ||
systemd: | ||
name: emqx | ||
state: stopped | ||
daemon_reload: yes | ||
|
||
- name: stop emqx | ||
block: | ||
- name: stop emqx | ||
shell: env EMQX_WAIT_FOR_STOP=20 emqx stop | ||
register: stop_result | ||
retries: 1 | ||
delay: 3 | ||
until: '"badrpc,timeout" not in stop_result.stderr' | ||
failed_when: '"badrpc,timeout" in stop_result.stderr' | ||
rescue: | ||
- name: REALLY stop emqx | ||
shell: "pkill -9 beam.smp" | ||
ignore_errors: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.