add api for descriptor to root domain, tidying things up
This commit is contained in:
@ -10,3 +10,5 @@ Working on the network descriptor, and I think to make it easier on me i will us
|
|||||||
The problem is that if an interface has multiple IPs, then I have multiple lines of data for IPs
|
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 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...
|
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
|
||||||
@ -272,6 +272,7 @@ class System:
|
|||||||
print(f"System initializing, name {self.name}")
|
print(f"System initializing, name {self.name}")
|
||||||
# system contains an array of component objects
|
# system contains an array of component objects
|
||||||
self.components = []
|
self.components = []
|
||||||
|
self.component_class_tree = component_class_tree
|
||||||
# initialize system properties and metrics dicts
|
# initialize system properties and metrics dicts
|
||||||
self._properties: Dict[str, str] = {}
|
self._properties: Dict[str, str] = {}
|
||||||
self._metrics: Dict[str, str] = {}
|
self._metrics: Dict[str, str] = {}
|
||||||
@ -386,6 +387,9 @@ class System:
|
|||||||
time_lapsed = time.time() - float(self.recent_check)
|
time_lapsed = time.time() - float(self.recent_check)
|
||||||
return time_lapsed < 30.0
|
return time_lapsed < 30.0
|
||||||
|
|
||||||
|
def get_component_class_tree(self):
|
||||||
|
return self.component_class_tree
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
# static metrics redis data functions
|
# static metrics redis data functions
|
||||||
########################################################
|
########################################################
|
||||||
|
|||||||
@ -125,6 +125,11 @@ def php_summary():
|
|||||||
def info():
|
def info():
|
||||||
return jsonify(get_info())
|
return jsonify(get_info())
|
||||||
|
|
||||||
|
# system info
|
||||||
|
@app.route('/descriptor', methods=['GET'])
|
||||||
|
def descriptor():
|
||||||
|
return jsonify(get_descriptor())
|
||||||
|
|
||||||
# socket timer
|
# socket timer
|
||||||
@app.route('/start_timer', methods=['GET'])
|
@app.route('/start_timer', methods=['GET'])
|
||||||
def start_timer():
|
def start_timer():
|
||||||
@ -239,6 +244,9 @@ def get_php_summary():
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_descriptor():
|
||||||
|
return cosmostat_system.get_component_class_tree()
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### Other Functions
|
### Other Functions
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|||||||
@ -36,22 +36,6 @@
|
|||||||
"RAM Voltage"
|
"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",
|
"name": "LAN",
|
||||||
"description": "{Device ID} - {Device Name} - {MAC Address}",
|
"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 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 ')'",
|
"Data Received": "ifconfig {this_device} | grep TX | grep bytes | cut -d '(' -f2 | tr -d ')'",
|
||||||
"Link State": "cat /sys/class/net/{this_device}/operstate",
|
"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": [
|
"multi_metrics": [
|
||||||
"IP Address"
|
"IP Address"
|
||||||
@ -82,7 +66,7 @@
|
|||||||
"Device Model": "nvidia-smi --id={this_device} --query-gpu=name --format=csv,noheader,nounits",
|
"Device Model": "nvidia-smi --id={this_device} --query-gpu=name --format=csv,noheader,nounits",
|
||||||
"Device ID": "echo NVGPU{this_device}",
|
"Device ID": "echo NVGPU{this_device}",
|
||||||
"Driver Version": "nvidia-smi --id={this_device} --query-gpu=driver_version --format=csv,noheader,nounits",
|
"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"
|
"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"
|
"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": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -20,7 +20,18 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>Matt-Cloud Cosmostat Dashboard</h2>
|
<h2>Matt-Cloud Cosmostat Dashboard</h2>
|
||||||
This dashboard shows the local Matt-Cloud system stats.<p>
|
This dashboard shows the local Matt-Cloud system stats.<p>
|
||||||
|
<div class="help-link" id="helpToggle" >API</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="helpText" class="card">
|
||||||
|
<strong>Component Desriptor</strong><p>
|
||||||
|
To view the component descriptor, you may <br>
|
||||||
|
<code>
|
||||||
|
curl -s https://<?php echo $_SERVER['SERVER_NAME'] ?>/descriptor<br>
|
||||||
|
</code>
|
||||||
|
This will return the entire JSON descriptor variable
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div id="host_components" class="column">
|
<div id="host_components" class="column">
|
||||||
|
|
||||||
@ -115,5 +126,17 @@
|
|||||||
<!-- matt-cloud redis script -->
|
<!-- matt-cloud redis script -->
|
||||||
<script src="src/redis.js"></script>
|
<script src="src/redis.js"></script>
|
||||||
|
|
||||||
|
<!-- Toggle the help text when the link is clicked -->
|
||||||
|
<script>
|
||||||
|
document.getElementById('helpToggle').addEventListener('click', function () {
|
||||||
|
const help = document.getElementById('helpText');
|
||||||
|
if (help.style.display === 'none' || help.style.display === '') {
|
||||||
|
help.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
help.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -49,3 +49,15 @@ li {
|
|||||||
#host_metrics_table tbody tr td :nth-of-type(even) {
|
#host_metrics_table tbody tr td :nth-of-type(even) {
|
||||||
background-color: #3e5c78;
|
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 */
|
||||||
|
}
|
||||||
|
|||||||
@ -10,31 +10,40 @@ server {
|
|||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# ---------------------------------------
|
||||||
# Proxy everything under "/" to the php server backend
|
# The API – only /descriptor
|
||||||
# --------------------------------------------------------------------
|
# ---------------------------------------
|
||||||
location / {
|
location = /descriptor {
|
||||||
proxy_pass http://192.168.37.1:8080;
|
proxy_pass http://192.168.37.1:5000/descriptor;
|
||||||
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 $sceme;
|
||||||
# ----- 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
|
# ---------------------------------------
|
||||||
|
# WebSocket endpoint
|
||||||
|
# ---------------------------------------
|
||||||
|
location /socket.io/ {
|
||||||
|
proxy_pass http://192.168.37.1:3000/socket.io/;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
# 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;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user