eyre.hardware
gather-hardware
(gather-hardware {:keys [exec shell]})Gathers CPU, memory, disk and virtualization facts from the host reachable via exec.
Arguments
Takes a map with:
:exec- an executor function that runs a script string on the target host and returns{:exit int :out string :err string}.:shell- the shell map returned byeyre.shell/gather-shell; its:typeselects which embedded collection script is run. Shells without a specific script fall back to the POSIX script.
Returns
A map with:
:cpu- a map{:model :cores :architecture :flags}where:modelis the processor name string,:coresthe number of logical cores,:architecturea normalized string (e.g."x86_64","aarch64","i386") and:flagsa set of lowercase CPU feature flag strings (e.g.#{"sse" "sse2" "avx2"}). On Windows the flag set may be inferred from the architecture when the processor feature bitmask is unavailable.:memory- a map{:total :swap}with total RAM and total swap in bytes.:disks- a vector of{:name :size :type}maps, sorted by:name, one per detected whole disk.:nameis the kernel device name on unix (e.g."nvme0n1","sda") and the drive model on Windows;:sizeis in bytes;:typeis one of:nvme,:ssdor:hdd.:virtualization- a map{:is-virtual? :type}.:is-virtual?is true when the host appears to be a VM or container;:typeis the detected platform keyword (e.g.:kvm,:qemu,:vmware,:virtualbox,:xen,:hyperv,:amazonor:docker) ornilon bare metal. Detection usessystemd-detect-virt, DMI vendor strings,kern.vm_guest, cgroup contents and/.dockerenvas available.
On unix the data comes from sysctl, /proc/cpuinfo, /proc/meminfo, lsblk, /sys/block, diskutil or geom depending on the platform; on Windows from PowerShell CIM queries or wmic.
Example
(hardware/gather-hardware {:exec local-exec :shell shell})
;; => {:cpu {:model "AMD Ryzen 9 7950X" :cores 32
;; :architecture "x86_64" :flags #{"sse" "sse2" ...}}
;; :memory {:total 67272187904 :swap 0}
;; :disks [{:name "nvme0n1" :size 2000398934016 :type :nvme}]
;; :virtualization {:is-virtual? false :type nil}}
gather-script
(gather-script shell-type)Returns the embedded collection script for shell-type. Falls back to the POSIX script when no specific script is available.
process-hardware
(process-hardware shell-type sections)Processes parsed hardware collection sections into a hardware facts map.