Get GPUs JSON output.
This commit is contained in:
+14
-15
@@ -117,24 +117,23 @@ append_to_report() {
|
||||
# --- 1. Detect Graphics ---
|
||||
detect_graphics() {
|
||||
local gpus="[]"
|
||||
local obj
|
||||
local brand
|
||||
local renderer
|
||||
local product
|
||||
local integrated
|
||||
local pci_addr
|
||||
|
||||
OLD_IFS="\$IFS"
|
||||
IFS=\$'n'
|
||||
|
||||
for line in \$(lspci | grep -e VGA -e 3D >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"); do
|
||||
local pci_addr
|
||||
while read -r gpu; do
|
||||
pci_addr="\$(lspci | grep VGA | head -c 7)"
|
||||
|
||||
# Brand
|
||||
for b in Intel AMD NVIDIA; do
|
||||
if echo "\${line}" | grep -i "\${b}" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}"; then
|
||||
brand="\${b}"
|
||||
else
|
||||
brand="unknown"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -169,20 +168,20 @@ detect_graphics() {
|
||||
integrated="false"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
obj=\$(jq -n \
|
||||
--arg b "\${brand}" \
|
||||
--arg r "\${renderer}" \
|
||||
--arg p "\${product}" \
|
||||
--argjson i "\${integrated}" \
|
||||
'{brand: \${b}, renderer: \${r}, product: \${p}, integrated: \${i}}')
|
||||
|
||||
gpus=\$(echo "\$gpus" | jq --argjson obj "\$obj" '. += [\$obj]')
|
||||
|
||||
done < <(lspci | grep -e "VGA" -e "3D" >> "${REMOTE_STDOUT}" 2>> "${REMOTE_STDERR}")
|
||||
|
||||
IFS="\${OLD_IFS}"
|
||||
|
||||
local obj
|
||||
obj=\$(jq -n \
|
||||
--arg b "\$brand" \
|
||||
--arg r "\$renderer" \
|
||||
--arg p "\$product" \
|
||||
--argjson i "\$integrated" \
|
||||
'{brand: \$b, renderer: \$r, product: \$p, integrated: \$i}')
|
||||
|
||||
gpus=\$(echo "\$gpus" | jq --argjson obj "\$obj" '. += [\$obj]')
|
||||
|
||||
append_to_report "graphics" "\$gpus"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user