Files
cosmoserver/files/api/component_descriptors.json
2026-03-15 10:22:30 -07:00

46 lines
2.5 KiB
JSON

[
{
"name": "CPU",
"description": "{model_name} with {core_count} cores.",
"multi_check": "False",
"properties": {
"core_count": "lscpu --json | jq -r '.lscpu[] | select(.field==\"CPU(s):\") | .data'",
"model_name": "lscpu --json | jq -r '.lscpu[] | select(.field==\"Model name:\") | .data'"
},
"metrics": {
"1m_load": "cat /proc/loadavg | awk '{print $1}'",
"5m_load": "cat /proc/loadavg | awk '{print $2}'",
"15m_load": "cat /proc/loadavg | awk '{print $3}'"
}
},
{
"name": "RAM",
"description": "Total {bytes_total}GB in {module_count} modules.",
"multi_check": "False",
"properties": {
"bytes_total": "sudo lshw -json -c memory | jq -r '.[] | select(.description==\"System Memory\").size' | awk '{printf \"%.2f\\n\", $1/1073741824}'",
"module_count": "sudo lshw -json -c memory | jq -r '.[] | select(.id | contains(\"bank\")) | .id ' | wc -l"
},
"metrics": {
"used_capacity_mb": "free -m | grep Mem | awk '{print $3}'",
"free_capacity_mb": "free -m | grep Mem | awk '{print $4}'"
}
},
{
"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}'",
"properties": {
"device_name": "lsblk -d -o NAME,SIZE | grep -v -e 0B -e NAME | awk '{{print $1}}' | grep {this_device}",
"device_id": "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}}'",
"drive_capacity": "lsblk -d -o NAME,SIZE | grep {this_device} | awk '{{print $2}}'"
},
"metrics": {
"smart_status": "sudo smartctl -x --json /dev/{this_device} | jq -r .smart_status.passed",
"ssd_endurance_string": "sudo smartctl -x --json /dev/{this_device} | jq -r '.physical_block_size as $block |.ata_device_statistics.pages[] | select(.name == \"General Statistics\") | .table[] | select(.name == \"Logical Sectors Written\") | .value as $sectors | ($sectors * $block) / 1073741824 ' | awk '{{printf \"%.2f GiB Written\\n\", $0}}' || true",
"nvme_endurance_string": "sudo smartctl -x --json /dev/{this_device} | jq -r ' .nvme_smart_health_information_log.data_units_written as $dw | .logical_block_size as $ls | ($dw * $ls) / 1073741824 ' | awk '{{printf \"%.2f GiB Written\\n\", $0}}' || true"
}
}
]