application working with php
This commit is contained in:
@ -33,7 +33,7 @@ docker_subnet: "192.168.37.0/24"
|
|||||||
docker_gateway: "192.168.37.1"
|
docker_gateway: "192.168.37.1"
|
||||||
|
|
||||||
# cosmostat service folder root
|
# cosmostat service folder root
|
||||||
service_folder: "/opt/cosmos/cosmostat"
|
service_folder: "/opt/cosmostat"
|
||||||
|
|
||||||
# cosmostat will run under cosmos user
|
# cosmostat will run under cosmos user
|
||||||
service_user: "cosmos"
|
service_user: "cosmos"
|
||||||
@ -53,10 +53,10 @@ quick_refresh: false
|
|||||||
|
|
||||||
# cosmostat_settings
|
# cosmostat_settings
|
||||||
noisy_test: false
|
noisy_test: false
|
||||||
debug_output: true
|
debug_output: false
|
||||||
secure_api: false
|
secure_api: true
|
||||||
push_redis: true
|
push_redis: true
|
||||||
run_background : true
|
run_background : true
|
||||||
log_output: true
|
log_output: true
|
||||||
update_frequency: "1"
|
update_frequency: "2"
|
||||||
...
|
...
|
||||||
@ -68,7 +68,9 @@ class Component:
|
|||||||
for key, command in self._descriptor.get('metrics', {}).items():
|
for key, command in self._descriptor.get('metrics', {}).items():
|
||||||
if self.this_device != "None":
|
if self.this_device != "None":
|
||||||
formatted_command = command.format(this_device=self.this_device)
|
formatted_command = command.format(this_device=self.this_device)
|
||||||
self._properties[key] = run_command(formatted_command, True)
|
this_metric = run_command(formatted_command, True)
|
||||||
|
if this_metric is not None:
|
||||||
|
self._metrics[key] = this_metric
|
||||||
else:
|
else:
|
||||||
self._metrics[key] = run_command(command, True)
|
self._metrics[key] = run_command(command, True)
|
||||||
|
|
||||||
@ -113,12 +115,14 @@ class Component:
|
|||||||
# returns array of dicts for redis
|
# returns array of dicts for redis
|
||||||
def get_metrics_keys(self):
|
def get_metrics_keys(self):
|
||||||
result = []
|
result = []
|
||||||
|
empty_value = ["", "null", None, []]
|
||||||
for name, value in self._metrics.items():
|
for name, value in self._metrics.items():
|
||||||
this_metric = {
|
this_metric = {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"type": name,
|
"type": name,
|
||||||
"metric": value
|
"metric": value
|
||||||
}
|
}
|
||||||
|
if value not in empty_value:
|
||||||
result.append(this_metric)
|
result.append(this_metric)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -220,13 +224,13 @@ class System:
|
|||||||
multi_check = component["multi_check"]
|
multi_check = component["multi_check"]
|
||||||
# if multi, note that the command in device_list creates the list of things to pipe into this_device
|
# if multi, note that the command in device_list creates the list of things to pipe into this_device
|
||||||
if multi_check:
|
if multi_check:
|
||||||
letters = [chr(c) for c in range(ord('a'), ord('z')+1)]
|
letters = [chr(c) for c in range(ord('A'), ord('Z')+1)]
|
||||||
print(f"Creating one component of type {component_name} for each one found")
|
print(f"Creating one component of type {component_name} for each one found")
|
||||||
component_type_device_list = get_device_list(component_name)
|
component_type_device_list = get_device_list(component_name)
|
||||||
|
|
||||||
for this_device in component_type_device_list:
|
for this_device in component_type_device_list:
|
||||||
this_component_letter = letters[component_type_device_list.index(this_device)]
|
this_component_letter = letters[component_type_device_list.index(this_device)]
|
||||||
this_component_name = f"{this_device}_{this_component_letter}"
|
this_component_name = f"{component_name} {this_component_letter}"
|
||||||
print(f"{this_component_name} - {component_name} - {this_device}")
|
print(f"{this_component_name} - {component_name} - {this_device}")
|
||||||
self.add_components(Component(this_component_name, component_name, this_device))
|
self.add_components(Component(this_component_name, component_name, this_device))
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Block_Storage",
|
"name": "Block Storage",
|
||||||
"description": "{device_id} is of type {drive_type} with capacity of {drive_capacity}.",
|
"description": "{device_id} is of type {drive_type} with capacity of {drive_capacity}.",
|
||||||
"multi_check": "True",
|
"multi_check": "True",
|
||||||
"device_list": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{print $1}'",
|
"device_list": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{print $1}'",
|
||||||
|
|||||||
@ -11,30 +11,30 @@ listen 80;
|
|||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# Proxy everything under "/" to the Node backend
|
# Proxy everything under "/" to the php server backend
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://172.17.0.1:3000;
|
proxy_pass http://192.168.37.1:8080;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
}
|
}
|
||||||
|
# ----- Custom Nginx Configuration (inside <location> block) -----
|
||||||
|
location /socket.io/ {
|
||||||
|
# Forward to the Node WS server
|
||||||
|
proxy_pass http://192.168.37.1:3000; # or <node_container_ip>
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# Keep WebSocket upgrade headers
|
||||||
# Proxy everything under "/history" to the Apache backend
|
proxy_http_version 1.1;
|
||||||
# This is off for now
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
# --------------------------------------------------------------------
|
proxy_set_header Connection "upgrade";
|
||||||
#location /history/ {
|
|
||||||
# proxy_pass http://172.17.0.1:8080/;
|
# Optional: pass on other headers you care about
|
||||||
# proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
# proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
#}
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
# Optional: If you want `/history` (without trailing slash) to be
|
|
||||||
# redirected to `/history/`:
|
|
||||||
#location = /history {
|
|
||||||
# return 301 /history/;
|
|
||||||
#}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,13 +17,6 @@
|
|||||||
<div id="host_metrics" class="column">Connecting…</div>
|
<div id="host_metrics" class="column">Connecting…</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--
|
|
||||||
Here will go the graphs once i have all the stats first
|
|
||||||
<div class="container">
|
|
||||||
<h2>System Graphs</h2>
|
|
||||||
<div id="host_graphs" class="column">Connecting…</div>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Socket.IO client library -->
|
<!-- Socket.IO client library -->
|
||||||
<script src="socket.io/socket.io.js"></script>
|
<script src="socket.io/socket.io.js"></script>
|
||||||
@ -117,5 +117,5 @@ li {
|
|||||||
|
|
||||||
|
|
||||||
#host_metrics_table tbody tr td :nth-of-type(even) {
|
#host_metrics_table tbody tr td :nth-of-type(even) {
|
||||||
background-color: #23384e;
|
background-color: #2c3e50;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
owner: "{{ service_user }}"
|
owner: "{{ service_user }}"
|
||||||
group: "{{ service_user }}"
|
group: "{{ service_user }}"
|
||||||
|
|
||||||
- name: Cosmostat - Init - node.js - copy dashboard files
|
- name: Cosmostat - Init - copy dashboard web files
|
||||||
copy:
|
copy:
|
||||||
src: "web/html"
|
src: "web/html"
|
||||||
dest: "{{ service_control_web_folder }}/"
|
dest: "{{ service_control_web_folder }}/"
|
||||||
@ -28,21 +28,21 @@
|
|||||||
# mode: 0755
|
# mode: 0755
|
||||||
# owner: "{{ service_user }}"
|
# owner: "{{ service_user }}"
|
||||||
# group: "{{ service_user }}"
|
# group: "{{ service_user }}"
|
||||||
#
|
|
||||||
#- name: Cosmostat - Web - copy files for proxy container
|
- name: Cosmostat - Web - copy files for proxy container
|
||||||
# copy:
|
copy:
|
||||||
# src: "proxy/"
|
src: "proxy/"
|
||||||
# dest: "{{ service_control_web_folder }}/proxy"
|
dest: "{{ service_control_web_folder }}/proxy"
|
||||||
# mode: 0755
|
mode: 0755
|
||||||
# owner: "{{ service_user }}"
|
owner: "{{ service_user }}"
|
||||||
# group: "{{ service_user }}"
|
group: "{{ service_user }}"
|
||||||
|
|
||||||
- name: docker container handler
|
- name: docker container handler
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Cosmostat - Web - template docker-compose.yaml
|
- name: Cosmostat - Web - template docker-compose.yaml
|
||||||
template:
|
template:
|
||||||
src: docker-compose.yaml
|
src: docker-compose-php.yaml
|
||||||
dest: "{{ service_control_web_folder }}/docker-compose.yaml"
|
dest: "{{ service_control_web_folder }}/docker-compose.yaml"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
||||||
|
|||||||
57
templates/docker-compose-php.yaml
Normal file
57
templates/docker-compose-php.yaml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
services:
|
||||||
|
|
||||||
|
cosmostat_redis:
|
||||||
|
container_name: cosmostat_redis
|
||||||
|
image: redis:7-alpine
|
||||||
|
ports:
|
||||||
|
- "{{ docker_gateway }}:6379:6379"
|
||||||
|
networks:
|
||||||
|
- cosmostat_net
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
cosmostat_ws_node:
|
||||||
|
container_name: cosmostat_ws_node
|
||||||
|
build:
|
||||||
|
context: "{{ service_control_web_folder }}/node_server"
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
image: ws_node:latest
|
||||||
|
ports:
|
||||||
|
- "{{ (docker_gateway + ':') if secure_api else '' }}3000:3000"
|
||||||
|
networks:
|
||||||
|
- cosmostat_net
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- cosmostat_redis
|
||||||
|
|
||||||
|
cosmostat_web_dash:
|
||||||
|
container_name: cosmostat_web_dash
|
||||||
|
image: php:8.0-apache
|
||||||
|
ports:
|
||||||
|
- "{{ (docker_gateway + ':') if secure_api else '' }}8080:80"
|
||||||
|
volumes:
|
||||||
|
- ./html:/var/www/html/
|
||||||
|
networks:
|
||||||
|
- cosmostat_net
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
cosmostat_nginx_proxy:
|
||||||
|
container_name: cosmostat_nginx_proxy
|
||||||
|
image: nginx:latest
|
||||||
|
ports:
|
||||||
|
- "{{ (docker_gateway + ':') if secure_api else '' }}80:80"
|
||||||
|
volumes:
|
||||||
|
- ./proxy/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
networks:
|
||||||
|
- cosmostat_net
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- cosmostat_web_dash
|
||||||
|
- cosmostat_ws_node
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
networks:
|
||||||
|
cosmostat_net:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user