diff --git a/README.md b/README.md index 362bde3..fc3b43d 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,6 @@ The docker stack also uses a network on the 192.168.37.0/24 subnet, and secures Working on the network descriptor, and I think to make it easier on me i will use json output from ip The problem is that if an interface has multiple IPs, then I have multiple lines of data for IPs I think perhaps I will update my code to be aware of properties that may be arrays -I do think this makes more sense than having multiple cards for a single interface... \ No newline at end of file +I do think this makes more sense than having multiple cards for a single interface... + +Need to differentiate between LAN and WLAN, it's weird when it's not \ No newline at end of file diff --git a/files/api/Components.py b/files/api/Components.py index bdd1dfc..b0793ef 100644 --- a/files/api/Components.py +++ b/files/api/Components.py @@ -272,6 +272,7 @@ class System: print(f"System initializing, name {self.name}") # system contains an array of component objects self.components = [] + self.component_class_tree = component_class_tree # initialize system properties and metrics dicts self._properties: Dict[str, str] = {} self._metrics: Dict[str, str] = {} @@ -385,6 +386,9 @@ class System: def check_system_timer(self): time_lapsed = time.time() - float(self.recent_check) return time_lapsed < 30.0 + + def get_component_class_tree(self): + return self.component_class_tree ######################################################## # static metrics redis data functions diff --git a/files/api/app.py b/files/api/app.py index f8c44bf..6084d56 100644 --- a/files/api/app.py +++ b/files/api/app.py @@ -125,6 +125,11 @@ def php_summary(): def info(): return jsonify(get_info()) +# system info +@app.route('/descriptor', methods=['GET']) +def descriptor(): + return jsonify(get_descriptor()) + # socket timer @app.route('/start_timer', methods=['GET']) def start_timer(): @@ -239,6 +244,9 @@ def get_php_summary(): return result +def get_descriptor(): + return cosmostat_system.get_component_class_tree() + ####################################################################### ### Other Functions ####################################################################### diff --git a/files/api/component_descriptors.json b/files/api/component_descriptors.json index 8d64b61..269a099 100644 --- a/files/api/component_descriptors.json +++ b/files/api/component_descriptors.json @@ -36,22 +36,6 @@ "RAM Voltage" ] }, - { - "name": "STOR", - "description": "{Device Path} is of type {Drive Type} with capacity of {Total Capacity}.", - "multi_check": "True", - "device_list": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{print $1}'", - "properties": { - "Device Name": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{{print $1}}' | grep {this_device}", - "Device Path": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{{print \"/dev/\"$1}}' | grep {this_device}", - "Drive Type": "lsblk -d -o NAME,TRAN | grep {this_device} | awk '{{print $2}}'", - "Total Capacity": "lsblk -d -o NAME,SIZE | grep {this_device} | awk '{{print $2}}'", - "SMART Check": "sudo /usr/sbin/smartctl -x --json /dev/{this_device} | jq -r .smart_status.passed" - }, - "metrics": { - "placeholder": "" - } - }, { "name": "LAN", "description": "{Device ID} - {Device Name} - {MAC Address}", @@ -67,7 +51,7 @@ "Data Transmitted": "ifconfig {this_device} | grep RX | grep bytes | cut -d '(' -f2 | tr -d ')'", "Data Received": "ifconfig {this_device} | grep TX | grep bytes | cut -d '(' -f2 | tr -d ')'", "Link State": "cat /sys/class/net/{this_device}/operstate", - "Link Speed": "cat /sys/class/net/{this_device}/speed" + "Link Speed": "cat /sys/class/net/{this_device}/speed || true" }, "multi_metrics": [ "IP Address" @@ -82,7 +66,7 @@ "Device Model": "nvidia-smi --id={this_device} --query-gpu=name --format=csv,noheader,nounits", "Device ID": "echo NVGPU{this_device}", "Driver Version": "nvidia-smi --id={this_device} --query-gpu=driver_version --format=csv,noheader,nounits", - "Maximum Power": "nvidia-smi --id={this_device} --query-gpu=power.draw --format=csv,noheader,nounits", + "Maximum Power": "nvidia-smi --id={this_device} --query-gpu=power.limit --format=csv,noheader,nounits", "Memory Size": "nvidia-smi --id={this_device} --query-gpu=memory.total --format=csv,noheader,nounits" }, @@ -94,5 +78,21 @@ }, "precheck": "lspci | grep NV | wc -l" + }, + { + "name": "STOR", + "description": "{Device Path} is of type {Drive Type} with capacity of {Total Capacity}.", + "multi_check": "True", + "device_list": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{print $1}'", + "properties": { + "Device Name": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{{print $1}}' | grep {this_device}", + "Device Path": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{{print \"/dev/\"$1}}' | grep {this_device}", + "Drive Type": "lsblk -d -o NAME,TRAN | grep {this_device} | awk '{{print $2}}'", + "Total Capacity": "lsblk -d -o NAME,SIZE | grep {this_device} | awk '{{print $2}}'", + "SMART Check": "sudo /usr/sbin/smartctl -x --json /dev/{this_device} | jq -r .smart_status.passed" + }, + "metrics": { + "placeholder": "" + } } ] \ No newline at end of file diff --git a/files/web/html/index.php b/files/web/html/index.php index 11ef565..71e74e8 100644 --- a/files/web/html/index.php +++ b/files/web/html/index.php @@ -20,7 +20,18 @@

Matt-Cloud Cosmostat Dashboard

This dashboard shows the local Matt-Cloud system stats.

+

+ +
+ Component Desriptor

+ To view the component descriptor, you may
+ + curl -s https:///descriptor
+
+ This will return the entire JSON descriptor variable +

+
@@ -115,5 +126,17 @@ + + + \ No newline at end of file diff --git a/files/web/html/src/styles.css b/files/web/html/src/styles.css index 6584592..1a4d30f 100644 --- a/files/web/html/src/styles.css +++ b/files/web/html/src/styles.css @@ -49,3 +49,15 @@ li { #host_metrics_table tbody tr td :nth-of-type(even) { background-color: #3e5c78; } + +.help-link{ + cursor:pointer; + user-select:none; + color: #2c3e50; + text-align: right; +} +.help-link:hover{ text-decoration:underline; } + +#helpText{ + display:none; /* hidden by default */ +} diff --git a/files/web/proxy/nginx.conf b/files/web/proxy/nginx.conf index d0c06ad..b08b797 100644 --- a/files/web/proxy/nginx.conf +++ b/files/web/proxy/nginx.conf @@ -10,31 +10,40 @@ server { listen 80; server_name localhost; -# -------------------------------------------------------------------- -# Proxy everything under "/" to the php server backend -# -------------------------------------------------------------------- -location / { - proxy_pass http://192.168.37.1:8080; + # --------------------------------------- + # The API – only /descriptor + # --------------------------------------- + location = /descriptor { + proxy_pass http://192.168.37.1:5000/descriptor; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; -} -# ----- Custom Nginx Configuration (inside block) ----- -location /socket.io/ { - # Forward to the Node WS server - proxy_pass http://192.168.37.1:3000; # or + proxy_set_header X-Forwarded-Proto $sceme; + } - # Keep WebSocket upgrade headers - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; + # --------------------------------------- + # WebSocket endpoint + # --------------------------------------- + location /socket.io/ { + proxy_pass http://192.168.37.1:3000/socket.io/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } - # Optional: pass on other headers you care about - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; -} + # --------------------------------------- + # All other paths → Apache (PHP) + # --------------------------------------- + location / { + proxy_pass http://192.168.37.1:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } } \ No newline at end of file