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