Only show units of storage, when diff to total
This commit is contained in:
parent
003375b3a9
commit
726452e386
3 changed files with 17 additions and 7 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/shirou/gopsutil/v3/disk"
|
"github.com/shirou/gopsutil/v3/disk"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func staticDisk() Disk {
|
func staticDisk() Disk {
|
||||||
|
@ -26,7 +27,9 @@ func (s *System) liveDisk() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
used := d.Used
|
used := d.Used
|
||||||
total := d.Total
|
|
||||||
s.Live.Disk.Value = humanize.IBytes(d.Used)
|
s.Live.Disk.Value = humanize.IBytes(d.Used)
|
||||||
s.Live.Disk.Percentage = math.RoundToEven(percent.PercentOfFloat(float64(used), float64(total)))
|
if strings.HasSuffix(s.Live.Disk.Value, strings.Split(s.Static.Disk.Total, " ")[1]) {
|
||||||
|
s.Live.Disk.Value = strings.Split(s.Live.Disk.Value, " ")[0]
|
||||||
|
}
|
||||||
|
s.Live.Disk.Percentage = math.RoundToEven(percent.PercentOfFloat(float64(used), float64(d.Total)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/shirou/gopsutil/v3/mem"
|
"github.com/shirou/gopsutil/v3/mem"
|
||||||
"math"
|
"math"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func staticRam() Ram {
|
func staticRam() Ram {
|
||||||
|
@ -28,7 +29,9 @@ func (s *System) liveRam() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
used := r.Used
|
used := r.Used
|
||||||
total := r.Total
|
|
||||||
s.Live.Ram.Value = humanize.IBytes(r.Used)
|
s.Live.Ram.Value = humanize.IBytes(r.Used)
|
||||||
s.Live.Ram.Percentage = math.RoundToEven(percent.PercentOfFloat(float64(used), float64(total)))
|
if strings.HasSuffix(s.Live.Ram.Value, strings.Split(s.Static.Ram.Total, " ")[1]) {
|
||||||
|
s.Live.Ram.Value = strings.Split(s.Live.Ram.Value, " ")[0]
|
||||||
|
}
|
||||||
|
s.Live.Ram.Percentage = math.RoundToEven(percent.PercentOfFloat(float64(used), float64(r.Total)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<use xlink:href="#cpu"></use>
|
<use xlink:href="#cpu"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<div class="w-full truncate">
|
<div class="w-full truncate">
|
||||||
<div class="truncate">{{ .System.Static.CPU.Name }}</div>
|
<div class="truncate text-slate-800 dark:text-slate-50">{{ .System.Static.CPU.Name }}</div>
|
||||||
<div class="text-xs truncate">{{ .System.Static.CPU.Threads }}</div>
|
<div class="text-xs truncate">{{ .System.Static.CPU.Threads }}</div>
|
||||||
<div class="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
<div class="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
||||||
<div
|
<div
|
||||||
|
@ -70,7 +70,9 @@
|
||||||
<use xlink:href="#ram"></use>
|
<use xlink:href="#ram"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<div class="w-full truncate">
|
<div class="w-full truncate">
|
||||||
<div class="truncate"><span id="systemRamValue">{{ .System.Live.Ram.Value }}</span> / {{ .System.Static.Ram.Total }}</div>
|
<div class="truncate text-slate-800 dark:text-slate-50">
|
||||||
|
<span id="systemRamValue">{{ .System.Live.Ram.Value }}</span> / {{ .System.Static.Ram.Total }}
|
||||||
|
</div>
|
||||||
<div class="text-xs truncate">{{ .System.Static.Ram.Swap }}</div>
|
<div class="text-xs truncate">{{ .System.Static.Ram.Swap }}</div>
|
||||||
<div class="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
<div class="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
||||||
<div
|
<div
|
||||||
|
@ -86,7 +88,9 @@
|
||||||
<use xlink:href="#disk"></use>
|
<use xlink:href="#disk"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<div class="w-full truncate">
|
<div class="w-full truncate">
|
||||||
<div class="truncate"><span id="systemDiskValue">{{ .System.Live.Disk.Value }}</span> / {{ .System.Static.Disk.Total }}</div>
|
<div class="truncate text-slate-800 dark:text-slate-50">
|
||||||
|
<span id="systemDiskValue">{{ .System.Live.Disk.Value }}</span> / {{ .System.Static.Disk.Total }}
|
||||||
|
</div>
|
||||||
<div class="text-xs truncate">{{ .System.Static.Disk.Partitions }}</div>
|
<div class="text-xs truncate">{{ .System.Static.Disk.Partitions }}</div>
|
||||||
<div class="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
<div class="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
||||||
<div
|
<div
|
||||||
|
|
Loading…
Add table
Reference in a new issue