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"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func staticDisk() Disk {
|
||||
|
@ -26,7 +27,9 @@ func (s *System) liveDisk() {
|
|||
return
|
||||
}
|
||||
used := d.Used
|
||||
total := d.Total
|
||||
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/shirou/gopsutil/v3/mem"
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func staticRam() Ram {
|
||||
|
@ -28,7 +29,9 @@ func (s *System) liveRam() {
|
|||
return
|
||||
}
|
||||
used := r.Used
|
||||
total := r.Total
|
||||
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>
|
||||
</svg>
|
||||
<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="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
||||
<div
|
||||
|
@ -70,7 +70,9 @@
|
|||
<use xlink:href="#ram"></use>
|
||||
</svg>
|
||||
<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="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
||||
<div
|
||||
|
@ -86,7 +88,9 @@
|
|||
<use xlink:href="#disk"></use>
|
||||
</svg>
|
||||
<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="bg-slate-300 dark:bg-slate-700 h-px mt-1">
|
||||
<div
|
||||
|
|
Loading…
Add table
Reference in a new issue