blob: 54bbd4654320e4f791b5b6d3ce6425ccf28edd19 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
(defwidget disks []
(box :class "panel disks"
:orientation "h"
:spacing 8
:space-evenly false
:height {100+16}
(disk :mount "total"
:zfs true
:name "zpool"
)
(disk :mount "/mnt/4tb"
:name "4tb"
)
(disk :mount "/mnt/ssd"
:name "ssd"
)
)
)
(defwidget zfs []
(box :class "panel zfs"
:orientation "v"
:spacing 8
:space-evenly false
:hexpand true
(label :halign "start" :markup "<b>ZFS Volumes</b>")
(zvol :mount "/nix")
(zvol :mount "/persist")
(zvol :class "faint"
:mount "/home"
)
(zvol :class "faint"
:mount "/"
)
(zvol :class "total"
:mount "total"
:name "Total"
)
)
)
(defwidget disk [mount ?name ?zfs]
(meter
:value {
(zfs == true ? zpool : disks)[mount].used / ((zfs == true ? zpool : disks)[mount].used + (zfs == true ? zpool : disks)[mount].free) * 100}
:label {name != "" ? name : mount}
{round((zfs == true ? zpool : disks)[mount].used/1024/1024, 0) + " GiB"}
)
)
(defwidget zvol [mount ?name ?class]
(stat :class {class}
:key {name != "" ? name : mount}
:value {round(zpool[mount].used/1024/1024, 2) + " GiB"}
)
)
(defpoll disks
:interval "10s"
`df -x fuse -x tmpfs -x efivarfs -x devtmpfs -x zfs | tail -n +2 | awk '{ printf "%s free %d\\n%s used %d\\n", $6, $4, $6, $3 }' | xargs printf '{"%s": {"%s": %d}}\\n' | jq -scaM 'map(to_entries) | flatten | group_by(.key) | map({"\\(.[0].key)": map(.value | to_entries) | flatten | from_entries}) | add'`
)
(defpoll zpool
:interval "10s"
`df -t zfs --total | tail -n +2 | awk '{ printf "%s free %d\\n%s used %d\\n", $6, $4, $6, $3 }' | xargs printf '{"%s": {"%s": %d}}\\n' | jq -scaM 'map(to_entries) | flatten | group_by(.key) | map({"\\(.[0].key)": map(.value | to_entries) | flatten | from_entries}) | add | .total = ."-" | del(."-") | .total.free = ."/zpool".free'`
)
|