Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/1- version A.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/1- version B.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/1- version c.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2 -4 run mosquitto on vm2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2-1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2-2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2-3.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3- 6 test sensor.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3-1 test sensor.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3-2 -1 tesetsensor.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3-2 tesetsensor.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3-4 tesetsensor.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3-5 test sensor.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/4- 1 push image.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/4- 2 dockercompose.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/4- 3 dockercompose.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/4- 4 docker compose check ports.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/5-1 mqtt.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/5-2 mqtt.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/5-3 mqtt.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/A- 1 sensor .PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/A- 2 sensor .PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/A- 3 sensor .PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/B 1 mosq.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/B 2 mosq.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/f1.PNG
Binary file added assets/images/f2.PNG
Binary file added assets/images/f3.PNG
Binary file added assets/images/g1.PNG
Binary file added assets/images/g2.PNG
Binary file added assets/images/grafana 1 .PNG
Binary file added assets/images/grafana 1- 1 .PNG
Binary file added assets/images/grafana 2.PNG
Binary file added assets/images/grafana 3.PNG
Binary file added assets/images/grafana 4.PNG
Binary file added assets/images/influxdb 1.PNG
Binary file added assets/images/telegraf conf.PNG
109 changes: 109 additions & 0 deletions report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
- Install on each virtual machine docker and docker-compose.

![1- version A](https://user-images.githubusercontent.com/25878224/234697074-ee27f537-754b-4935-a552-43f76bdc7843.PNG)

![1- version B](https://user-images.githubusercontent.com/25878224/234697168-816b99c6-c84f-45f1-a5b7-a51d7c514424.PNG)

![1- version c](https://user-images.githubusercontent.com/25878224/234697182-737a155a-0f8f-4ab9-84e7-6c8fa20391fb.PNG)

- Create the four Sensors classes (Temperature, Pressure, Current, Humidity) by module "sensor.py"

![A- 1 sensor ](https://user-images.githubusercontent.com/25878224/235059677-3d219643-9710-4199-8916-76d7c819f968.PNG)

![A- 2 sensor ](https://user-images.githubusercontent.com/25878224/235059709-062cf237-5f9e-4ea0-8bdf-b74e7459d3a2.PNG)

![A- 3 sensor ](https://user-images.githubusercontent.com/25878224/235059716-a834701f-fe0b-4e9d-96f6-67001fc99398.PNG)

- Configure the docker image configuration file (DockerFile)

FROM python:3.7
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "main.py"]

- Build the docker image with the following command:

sudo docker build -t souhair/sensor-simulator:v0.0.1 .

![1](https://github.com/souhair/DockerPractice/assets/25878224/f753b2b5-8f6d-487b-ad27-22d0ac182b41)


- Download mosquitto broker, create mosquitto.conf file

![B 1 mosq](https://user-images.githubusercontent.com/25878224/235062194-88a0e5df-c59e-4d56-8648-84c3127bdc53.PNG)

- Start a container with a binding to a port and loading a conf file into the system

![B 2 mosq](https://user-images.githubusercontent.com/25878224/235062613-a823d3e5-bbd6-4e00-8ce1-6488e5acbe8e.PNG)

- Let's see when running this command to test temperature sensor:

![3- 6 test sensor](https://user-images.githubusercontent.com/25878224/235064111-59c08193-60a6-4e1c-9f97-717ef6a3a63d.PNG)

![3-1 test sensor](https://user-images.githubusercontent.com/25878224/235064130-5a82d272-818a-49ae-8d53-3e826f6a8cc0.PNG)

![3-5 test sensor](https://user-images.githubusercontent.com/25878224/235064223-3cd49436-a18d-48c3-95dd-cdaabfba1424.PNG)

- And check with mqtt explorer

![5-1 mqtt](https://user-images.githubusercontent.com/25878224/235063223-29384927-36ec-483a-9fc8-d1ceedeb4c9f.PNG)


- Pushing the Image to DockerHub

![2](https://github.com/souhair/DockerPractice/assets/25878224/10c8bdd0-6434-4a71-892f-3c977f560615)

![3](https://github.com/souhair/DockerPractice/assets/25878224/5cc298da-2f5c-4555-916e-08efd353a584)

![4](https://github.com/souhair/DockerPractice/assets/25878224/8af60964-a911-4c5a-ad79-2cb9e76495d3)


- Now test all sensors:

![3-2 tesetsensor](https://user-images.githubusercontent.com/25878224/235063689-efbb0454-b255-4288-be44-e04beb389fe8.PNG)

![3-4 tesetsensor](https://user-images.githubusercontent.com/25878224/235064211-247cd9fa-c7db-4bc4-9165-26b15aa9bb3c.PNG)

![3-2 -1 tesetsensor](https://user-images.githubusercontent.com/25878224/235063939-1f29b84a-4c0a-48d7-a14a-d1f702212b1b.PNG)


- Check with mqtt explorer

![5-3 mqtt](https://user-images.githubusercontent.com/25878224/235063315-6e97974e-e161-4947-bbc2-f03dd62ec598.PNG)

- After that, we create a docker-compose file:

![8 compose server 1](https://github.com/souhair/DockerPractice/assets/25878224/dd366dd0-016a-4992-88b6-a08ec65d5fc5)

![9 compose server 2](https://github.com/souhair/DockerPractice/assets/25878224/49bdf3dd-ff4b-43a1-980b-9bcad41deddf)

In Linux A:
- Influxdb
Run a container with a database with an attached volume (version 1.8)

![influxdb 1](https://user-images.githubusercontent.com/25878224/235066231-131e54e7-93a2-429a-a40a-985b413cb592.PNG)

- Telegraf - configration file

![telegraf conf](https://user-images.githubusercontent.com/25878224/235066474-db765f99-3908-4e73-91b8-e5f41a9dab50.PNG)

- Now we have:

![f1](https://github.com/souhair/DockerPractice/assets/25878224/0aaf4e12-eea0-4c43-9e98-8e2eeb45db61)

![f2](https://user-images.githubusercontent.com/25878224/235067324-c976bfbf-e29b-4f4d-8f3a-6e31e4770036.PNG)

![f3](https://user-images.githubusercontent.com/25878224/235067345-81b4ed28-8be9-4f21-a521-2d03533cb9f8.PNG)

- Grafana on port 3000

![grafana 1- 1 ](https://user-images.githubusercontent.com/25878224/235066132-86838126-656b-4e4c-93b2-56bb8ef54275.PNG)

![5](https://github.com/souhair/DockerPractice/assets/25878224/ad13e673-39b7-4b93-beda-41e3ed6f3b97)

![6](https://github.com/souhair/DockerPractice/assets/25878224/629b8eae-c696-49d7-9d95-34fee7abd5cd)

![7](https://github.com/souhair/DockerPractice/assets/25878224/b92efedc-9215-4004-a25a-220fa061c203)

14 changes: 14 additions & 0 deletions vms/client/client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/bash
# script to create the third virtual machine
ip link add macvlan1 link eth0 type macvlan mode bridge
ip address add dev macvlan1 192.168.4.100/24
ip link set macvlan1 up
ip route add 192.168.18.0/24 via 192.168.4.1
while [ true ] ; do
read -t 3 -n 1
if [ $? = 0 ] ; then
break ;
else
echo "waiting for the keypress"
fi
done
1 change: 1 addition & 0 deletions vms/client/simulator/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SIM_HOST_IP = 192.168.4.1
20 changes: 14 additions & 6 deletions vms/client/simulator/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@ version: "3"

services:
temp_sensor:
image: antonaleks/data-simulator
image: souhair/sensor-simulator:v0.0.1
environment:
- SIM_HOST=192.168.1.1
- SIM_HOST=$SIM_HOST_IP
- SIM_NAME=TIRCAHL24
- SIM_PERIOD=5
- SIM_TYPE=temperature
pressure_sensor:
image: antonaleks/data-simulator
image: souhair/sensor-simulator:v0.0.1
environment:
- SIM_HOST=192.168.1.1
- SIM_HOST=$SIM_HOST_IP
- SIM_NAME=PIRCAHL11
- SIM_PERIOD=10
- SIM_TYPE=pressure
current_sensor:
image: antonaleks/data-simulator
image: souhair/sensor-simulator:v0.0.1
environment:
- SIM_HOST=192.168.1.1
- SIM_HOST=$SIM_HOST_IP
- SIM_NAME=A0_CURRENT
- SIM_PERIOD=1
- SIM_TYPE=current
humidity_sensor:
image: souhair/sensor-simulator:v0.0.1
environment:
- SIM_HOST=$SIM_HOST_IP
- SIM_NAME=H0_HUMIDITY
- SIM_PERIOD=10
- SIM_TYPE=humidity

17 changes: 15 additions & 2 deletions vms/client/simulator/entity/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __str__(self):


class Temperature(Sensor):
step = 25
step = 15

def __init__(self, name):
super().__init__(name)
Expand All @@ -31,7 +31,7 @@ def generate_new_value(self):


class Pressure(Sensor):
step = 55
step = 65

def __init__(self, name):
super().__init__(name)
Expand All @@ -52,3 +52,16 @@ def generate_new_value(self):
import math
self.value = math.sin(self.step)
self.step = self.step + 1

class Humidity(Sensor):
step = 0

def __init__(self, name):
super().__init__(name)
self.type = "humidity"

def generate_new_value(self):
import math
self.value = (math.cos(self.step + 3) + 2) * 10
self.step = self.step + 4

2 changes: 1 addition & 1 deletion vms/client/simulator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
name = "sensor" if "SIM_NAME" not in environ.keys() else environ["SIM_NAME"]
period = 1 if "SIM_PERIOD" not in environ.keys() else int(environ["SIM_PERIOD"])
type_sim = "temperature" if "SIM_TYPE" not in environ.keys() else environ["SIM_TYPE"]
sensors = {"temperature": Temperature, "pressure": Pressure, "current": Current}
sensors = {"temperature": Temperature, "pressure": Pressure, "current": Current, "humidity": Humidity}


def on_publish(client, userdata, result): # create function for callback
Expand Down
10 changes: 10 additions & 0 deletions vms/gateway/gateway.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash
# script to create the second virtual machine

ip link add macvlan1 link eth0 type macvlan mode bridge
ip address add dev macvlan1 192.168.18.1/24
ip link set macvlan1 up
ip link add macvlan2 link eth0 type macvlan mode bridge
ip address add dev macvlan2 192.168.4.1/24
ip link set macvlan2 up

6 changes: 3 additions & 3 deletions vms/server/infra/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ services:
networks:
- server-net
telegraf:
image: telegraf
image: telegraf:1.26.2
container_name: telegraf
volumes:
- ./telegraf:/etc/telegraf:ro
restart: unless-stopped
networks:
- server-net
grafana:
image: grafana/grafana
image: grafana/grafana:9.5.1-ubuntu
container_name: grafana
volumes:
- grafana_data:/var/lib/grafana
Expand All @@ -39,4 +39,4 @@ volumes:
grafana_data: {}

networks:
server-net: {}
server-net: {}
Loading