Browse Source

Upload files to ''

master
anastasia_petr 4 years ago
parent
commit
ae3fe84c54
  1. 41
      fluentd-test-mongo-free.yml
  2. 15
      fluentd-test-mongo-free.yml.sh
  3. 15
      fluentd-test-mongo.yml.sh
  4. 65
      inventory.yml

41
fluentd-test-mongo-free.yml

@ -0,0 +1,41 @@
---
- 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 }}"

15
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

15
fluentd-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

65
inventory.yml

@ -0,0 +1,65 @@
package standarinputIO;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/**
*
* @author anasf
*/
public class StandardInputIO {
final static String endstr="000000"; //this variable ends the process
static String AM="[0-9]{6}";
static float average=0;
static ArrayList<String> students = new ArrayList<String>();
static int count=0;
static String str;
static boolean flag=true;
static int size=0;
static String temp;
static String[] data;
public static void main(String[] args) throws IOException {
System.out.println("Give students ID and the grades in this way.Spacifically 'AM course1 grade1 course2 grade2... and press ENTER'");
System.out.println("To end the process type-> 000000 and press ENTER");
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
// Reading data using readLine
while(flag) {
str=input.readLine();
if(!str.startsWith(endstr)) {
students.add(str);
size++;
}
else {
flag=false;
}
}
System.out.println("The process of reading students' data finished");
System.out.println("The calculation of average will start!");
for(int i=0;i<size;i++) {
temp=students.get(i);
data=temp.split("[ \t]");
for(int j=2;j<data.length;j=j+2)
{
// calculate the average
average=average+Float.parseFloat(data[j]);
count++;
}
average=average/count;
System.out.println("Average of student "+data[0]+": "+average);
average=0;
count=0;
}
System.out.println("Reading of grades was completed successfully!");
}
}
Loading…
Cancel
Save