-
Notifications
You must be signed in to change notification settings - Fork 237
/
from-dmidecode.nu
36 lines (35 loc) · 1.05 KB
/
from-dmidecode.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Convert from output of dmidecode to structured data
export def "from dmidecode" [] {
lines
| skip until {|x|
$x starts-with 'Handle'
}
| split list ''
| each {|entry|
let parsed_entry = (
$entry
| get 0
| parse 'Handle {handle}, DMI type {type}, {bytes} bytes'
| get 0
| insert description ($entry|get 1)
| insert values {
if ($entry|length) > 2 {
if ($entry|get 2|str trim) == 'Header and Data:' {
{'header_and_data': ($entry|skip 3|str trim)}
} else {
$entry
| skip 2
| split column ':'
| str trim
| str downcase column1
| str replace -a ' ' '_' column1
| transpose -r -d
}
} else {
{}
}
}
)
$parsed_entry
}
}