Skip to content

Commit 6e8d1ee

Browse files
authored
Refactor capture-system-info to include detailed host environment variables (#79)
- Split Linux and macOS logic for improved maintainability. - Capture additional host details: OS, kernel, CPU, GPU, and memory. - Standardize state variables (`RUN.env.host.*`) for consistency. - Add dynamic dispatch for OS-specific system info capture.
1 parent 5fcd23d commit 6e8d1ee

File tree

1 file changed

+24
-8
lines changed
  • scripts/perf-lab/helpers

1 file changed

+24
-8
lines changed

scripts/perf-lab/helpers/os.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,28 @@ scripts:
1010
then:
1111
- set-state: RUN.os linux
1212

13-
capture-system-info:
14-
- sh: grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"'
13+
capture-system-info-linux:
14+
- sh: "hostnamectl | grep 'Operating System:' | cut -d: -f2 | xargs"
1515
then:
16-
- regex: ".*rhel.*"
17-
then:
18-
- script: check-and-install-package
19-
with:
20-
command: fastfetch
21-
package: epel-release
16+
- set-state: RUN.env.host.os
17+
- sh: "hostnamectl | grep 'Hardware Model:' | cut -d: -f2 | xargs"
18+
then:
19+
- set-state: RUN.env.host.type
20+
- sh: "hostnamectl | grep 'Kernel:' | cut -d: -f2 | xargs"
21+
then:
22+
- set-state: RUN.env.host.kernel
23+
- sh: |
24+
lscpu | awk -F: '/^Model name:/ {model=$2} /^CPU\(s):/ {cpus=$2} END {gsub(/^[ \t]+|[ \t]+$/, "", model); gsub(/^[ \t]+|[ \t]+$/, "", cpus); print model " (" cpus " cpus)"}'
25+
then:
26+
- set-state: RUN.env.host.cpu
27+
- sh: "lspci | grep -iE 'vga|3d|display' | sed 's/.*: //; s/ (rev.*)$//' | head -n1"
28+
then:
29+
- set-state: RUN.env.host.gpu
30+
- sh: free -h | grep '^Mem:' | awk '{print $2}'
31+
then:
32+
- set-state: RUN.env.host.memory
33+
34+
capture-system-info-macos:
2235
- script: check-and-install-package
2336
with:
2437
command: fastfetch
@@ -48,6 +61,9 @@ scripts:
4861
then:
4962
- set-state: RUN.env.host.memory
5063
64+
capture-system-info:
65+
- script: capture-system-info-${{os}}
66+
5167
sudo-linux:
5268
- sh: sudo ${{command}}
5369

0 commit comments

Comments
 (0)