From f34ec0b5ba9ae5854cd45dfcbc8b7390997763f1 Mon Sep 17 00:00:00 2001 From: Panagiotis_Klironomos Date: Tue, 15 Jun 2021 17:38:45 +0000 Subject: [PATCH] Upload files to 'Fluentd' --- Fluentd/fleuntd-test-mongo.yml.sh | 15 ++++ Fluentd/fluentd-config-update.yml | 103 +++++++++++++++++++++++++ Fluentd/fluentd-config-update.yml.sh | 15 ++++ Fluentd/fluentd-test-mongo-free.yml | 44 +++++++++++ Fluentd/fluentd-test-mongo-free.yml.sh | 15 ++++ 5 files changed, 192 insertions(+) create mode 100644 Fluentd/fleuntd-test-mongo.yml.sh create mode 100644 Fluentd/fluentd-config-update.yml create mode 100644 Fluentd/fluentd-config-update.yml.sh create mode 100644 Fluentd/fluentd-test-mongo-free.yml create mode 100644 Fluentd/fluentd-test-mongo-free.yml.sh diff --git a/Fluentd/fleuntd-test-mongo.yml.sh b/Fluentd/fleuntd-test-mongo.yml.sh new file mode 100644 index 0000000..9c44a49 --- /dev/null +++ b/Fluentd/fleuntd-test-mongo.yml.sh @@ -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 \ No newline at end of file diff --git a/Fluentd/fluentd-config-update.yml b/Fluentd/fluentd-config-update.yml new file mode 100644 index 0000000..284bf40 --- /dev/null +++ b/Fluentd/fluentd-config-update.yml @@ -0,0 +1,103 @@ +# config + + @type stdout + + +# input log + + @type tail + + path /var/log/*.log + path_key tailed_path + + tag stats.node + + # parse json + + @type json + + + pos_file /tmp/fluentd--1605454018.pos + + + +# input stats + + @type tail + + path /var/log-in/*/* + path_key tailed_path + + tag log.node + + # parse none + + @type none + + + pos_file /tmp/fluentd--1605454014.pos + + + +# output mongo log* + + @type copy + + @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 + + + + flush_interval 20s + + + + @type stdout + + + + @type file + path /tmp/mylog + + timekey 1d + timekey_use_utc true + timekey_wait 10s + + + + + + +# output mongo stats* + + @type copy + + @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 + + + @type stdout + + diff --git a/Fluentd/fluentd-config-update.yml.sh b/Fluentd/fluentd-config-update.yml.sh new file mode 100644 index 0000000..ee88882 --- /dev/null +++ b/Fluentd/fluentd-config-update.yml.sh @@ -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 \ No newline at end of file diff --git a/Fluentd/fluentd-test-mongo-free.yml b/Fluentd/fluentd-test-mongo-free.yml new file mode 100644 index 0000000..67a47b1 --- /dev/null +++ b/Fluentd/fluentd-test-mongo-free.yml @@ -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 }}" + + + \ No newline at end of file diff --git a/Fluentd/fluentd-test-mongo-free.yml.sh b/Fluentd/fluentd-test-mongo-free.yml.sh new file mode 100644 index 0000000..bf8c792 --- /dev/null +++ b/Fluentd/fluentd-test-mongo-free.yml.sh @@ -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 \ No newline at end of file