application working with php
This commit is contained in:
@ -68,7 +68,9 @@ class Component:
|
||||
for key, command in self._descriptor.get('metrics', {}).items():
|
||||
if self.this_device != "None":
|
||||
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:
|
||||
self._metrics[key] = run_command(command, True)
|
||||
|
||||
@ -113,13 +115,15 @@ class Component:
|
||||
# returns array of dicts for redis
|
||||
def get_metrics_keys(self):
|
||||
result = []
|
||||
empty_value = ["", "null", None, []]
|
||||
for name, value in self._metrics.items():
|
||||
this_metric = {
|
||||
"name": self.name,
|
||||
"type": name,
|
||||
"metric": value
|
||||
}
|
||||
result.append(this_metric)
|
||||
if value not in empty_value:
|
||||
result.append(this_metric)
|
||||
return result
|
||||
|
||||
def get_properties_keys(self):
|
||||
@ -220,13 +224,13 @@ class System:
|
||||
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_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")
|
||||
component_type_device_list = get_device_list(component_name)
|
||||
|
||||
for this_device in component_type_device_list:
|
||||
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}")
|
||||
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}.",
|
||||
"multi_check": "True",
|
||||
"device_list": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{print $1}'",
|
||||
|
||||
Reference in New Issue
Block a user