Panagiotis_Klironomos
3 years ago
5 changed files with 192 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||||
|
#!/bin/sh |
||||
|
|
||||
|
|
||||
|
ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) |
||||
|
ip6=$(/sbin/ip -o -6 addr list eth0 | awk '{print $4}' | cut -d/ -f1) |
||||
|
|
||||
|
echo "[service]" > /project/courses/fluentd/inventory.yml |
||||
|
/project/bin/swarmlab-nmap >> /project/courses/fluentd/inventory.yml |
||||
|
|
||||
|
|
||||
|
# include master or not |
||||
|
echo $ip4 >> /project/courses/fluentd/inventory.yml |
||||
|
|
||||
|
|
||||
|
ansible-playbook -u docker -i inventory.yml fluentd-test-mongo.yml -f 5 --ask-pass --ask-become-pass |
@ -0,0 +1,103 @@ |
|||||
|
# config |
||||
|
<match debug.*> |
||||
|
@type stdout |
||||
|
</match> |
||||
|
|
||||
|
# input log |
||||
|
<source> |
||||
|
@type tail |
||||
|
|
||||
|
path /var/log/*.log |
||||
|
path_key tailed_path |
||||
|
|
||||
|
tag stats.node |
||||
|
|
||||
|
# parse json |
||||
|
<parse> |
||||
|
@type json |
||||
|
</parse> |
||||
|
|
||||
|
pos_file /tmp/fluentd--1605454018.pos |
||||
|
</source> |
||||
|
|
||||
|
|
||||
|
# input stats |
||||
|
<source> |
||||
|
@type tail |
||||
|
|
||||
|
path /var/log-in/*/* |
||||
|
path_key tailed_path |
||||
|
|
||||
|
tag log.node |
||||
|
|
||||
|
# parse none |
||||
|
<parse> |
||||
|
@type none |
||||
|
</parse> |
||||
|
|
||||
|
pos_file /tmp/fluentd--1605454014.pos |
||||
|
</source> |
||||
|
|
||||
|
|
||||
|
# output mongo log* |
||||
|
<match log.*> |
||||
|
@type copy |
||||
|
<store> |
||||
|
@type mongo_replset |
||||
|
|
||||
|
database app_swarmlab |
||||
|
collection logs |
||||
|
nodes swarmlabmongo1:27017,swarmlabmongo2:27017,swarmlabmongo1:27017 |
||||
|
|
||||
|
user app_swarmlab |
||||
|
password app_swarmlab |
||||
|
|
||||
|
replica_set rs0 |
||||
|
num_retries 60 |
||||
|
capped |
||||
|
capped_size 100m |
||||
|
|
||||
|
|
||||
|
<buffer> |
||||
|
flush_interval 20s |
||||
|
</buffer> |
||||
|
</store> |
||||
|
<store> |
||||
|
@type stdout |
||||
|
</store> |
||||
|
|
||||
|
<store> |
||||
|
@type file |
||||
|
path /tmp/mylog |
||||
|
<buffer> |
||||
|
timekey 1d |
||||
|
timekey_use_utc true |
||||
|
timekey_wait 10s |
||||
|
</buffer> |
||||
|
</store> |
||||
|
|
||||
|
|
||||
|
</match> |
||||
|
|
||||
|
# output mongo stats* |
||||
|
<match stats.*> |
||||
|
@type copy |
||||
|
<store> |
||||
|
@type mongo_replset |
||||
|
|
||||
|
database app_swarmlab |
||||
|
collection logs |
||||
|
nodes swarmlabmongo1:27017,swarmlabmongo2:27017,swarmlabmongo1:27017 |
||||
|
|
||||
|
user swarmlab |
||||
|
password swarmlab |
||||
|
|
||||
|
replica_set rs0 |
||||
|
num_retries 60 |
||||
|
capped |
||||
|
capped_size 100m |
||||
|
</store> |
||||
|
<store> |
||||
|
@type stdout |
||||
|
</store> |
||||
|
</match> |
@ -0,0 +1,15 @@ |
|||||
|
#!/bin/sh |
||||
|
|
||||
|
|
||||
|
ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) |
||||
|
ip6=$(/sbin/ip -o -6 addr list eth0 | awk '{print $4}' | cut -d/ -f1) |
||||
|
|
||||
|
echo "[service]" > /project/courses/fluentd/inventory.yml |
||||
|
/project/bin/swarmlab-nmap >> /project/courses/fluentd/inventory.yml |
||||
|
|
||||
|
|
||||
|
# include master or not |
||||
|
echo $ip4 >> /project/courses/fluentd/inventory.yml |
||||
|
|
||||
|
|
||||
|
ansible-playbook -u docker -i inventory.yml fluentd-config-update.yml -f 5 --ask-pass --ask-become-pass |
@ -0,0 +1,44 @@ |
|||||
|
--- |
||||
|
- hosts: service |
||||
|
remote_user: docker |
||||
|
gather_facts: no |
||||
|
vars: |
||||
|
user: "docker" |
||||
|
|
||||
|
tasks: |
||||
|
|
||||
|
# -------------------------------------------------------------------------------------- |
||||
|
# --------------------- create test dir |
||||
|
# -------------------------------------------------------------------------------------- |
||||
|
|
||||
|
# ------------------------ |
||||
|
# test dir |
||||
|
# ------------------------- |
||||
|
- name: make dir for test |
||||
|
become: true |
||||
|
file: |
||||
|
path: "/var/log-in/test" |
||||
|
state: directory |
||||
|
owner: docker |
||||
|
group: docker |
||||
|
mode: '0755' |
||||
|
|
||||
|
# -------------------------------------------------------------------------------------- |
||||
|
# --------------------- kill and save ps tp tmp |
||||
|
# -------------------------------------------------------------------------------------- |
||||
|
|
||||
|
- name: find fluentd |
||||
|
#shell: free -h >> /var/log-in/test/test |
||||
|
shell: free -h |
||||
|
#shell: "ps efw -opid,cmd -Cfluentd | pgrep -o fluentd" |
||||
|
register: fluentddate |
||||
|
|
||||
|
- name: ls fluentddate |
||||
|
debug: var=fluentddate.stdout_lines |
||||
|
|
||||
|
- name: write to /var/log-in/test/test2 |
||||
|
shell: "echo {{ item }} >> /var/log-in/test/test2" |
||||
|
with_items: "{{ fluentddate.stdout_lines }}" |
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,15 @@ |
|||||
|
#!/bin/sh |
||||
|
|
||||
|
|
||||
|
ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) |
||||
|
ip6=$(/sbin/ip -o -6 addr list eth0 | awk '{print $4}' | cut -d/ -f1) |
||||
|
|
||||
|
echo "[service]" > /project/courses/fluentd/inventory.yml |
||||
|
/project/bin/swarmlab-nmap >> /project/courses/fluentd/inventory.yml |
||||
|
|
||||
|
|
||||
|
# include master or not |
||||
|
echo $ip4 >> /project/courses/fluentd/inventory.yml |
||||
|
|
||||
|
|
||||
|
ansible-playbook -u docker -i inventory.yml fluentd-test-mongo-free.yml -f 5 --ask-pass --ask-become-pass |
Loading…
Reference in new issue