This file contains hidden or 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
from collections import defaultdict | |
def auto_nested_dict(): | |
return defaultdict(auto_nested_dict) | |
if __name __ == '__main__': | |
d = auto_nested_dict() | |
d['wats']['up']['world'] = 'Here I am!' |
This file contains hidden or 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
(ENV)> ls -1 /var/www/ | grep packet_capture | |
packet_capture_server1_1376450197.cap.gz | |
packet_capture_server2_1376450500.cap.gz | |
packet_capture_server3_1376451234.cap.gz |
This file contains hidden or 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
(ENV)> ansible-playbook parallel-tcpdump.yml -i hosts |
This file contains hidden or 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
- name: remove files from server | |
file: path=/tmp/${cap_file}.gz state=absent |
This file contains hidden or 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
- name: compress capture file | |
command: gzip ${cap_file} chdir=/tmp | |
- name: copy logs to local boxes webroot | |
fetch: src=/tmp/${cap_file}.gz dest=/var/www/ flat=yes |
This file contains hidden or 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
- name: kill tcpdump | |
command: /usr/bin/pkill tcpdump | |
ignore_errors: yes |
This file contains hidden or 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
- pause: minutes=1 prompt="pause for 60 seconds or press Ctrl + c then c to continue" |
This file contains hidden or 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
tasks: | |
- name: start tcpdump | |
command: /usr/sbin/tcpdump -i eth0 -s 0 -w /tmp/${cap_file} | |
async: 60 | |
poll: 0 |
This file contains hidden or 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
- hosts: all | |
sudo: yes | |
vars: | |
cap_file: packet_capture_{{ ansible_hostname }}_{{ ansible_date_time['epoch'] }}.cap |
This file contains hidden or 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
> ps -e | grep 27439 | |
> |