Cleanup, small fixes

pull/13/head
Paulo Truta 2021-06-07 22:47:38 +00:00
parent 5d92e213ee
commit 4dec81e487
2 changed files with 50 additions and 37 deletions

View File

@ -186,27 +186,34 @@ func getDevicesSpaceUsage(devices []Device) []Device {
for partitionIndex, partition := range device.Partitions { for partitionIndex, partition := range device.Partitions {
if partition.Mountpoint != "" {
s, _ := disk.Usage(partition.Mountpoint) s, _ := disk.Usage(partition.Mountpoint)
if s.Total == 0 { if s.Total == 0 {
continue continue
} }
partitionUsagePercent := fmt.Sprintf("%2.f%%", s.UsedPercent) partitionUsagePercent := fmt.Sprintf("%2.f%%", s.UsedPercent)
osUsageSplit := (uint64)(0)
edgeappsDirSize, err := getDirSize(utils.GetPath("edgeAppsPath"))
// TODO for later: Figure out to get correct paths for each partition...
// wsAppDataDirSize, err := getDirSize("/home/system/components/ws/appdata")
edgeappsUsageSplit := (uint64)(0) edgeappsUsageSplit := (uint64)(0)
if partition.Mountpoint == "/" && err == nil { bucketsUsageSplit := (uint64)(0)
// edgeappsUsageSplit = edgeappsDirSize + wsAppDataDirSize othersUsageSplit := (uint64)(0)
edgeappsUsageSplit = edgeappsDirSize
edgeappsDirSize, _ := getDirSize(utils.GetPath("edgeAppsPath"))
// TODO for later: Figure out to get correct paths for each partition...
wsAppDataDirSize, _ := getDirSize("/home/system/components/ws/appdata")
if partition.Mountpoint == "/" {
edgeappsUsageSplit = edgeappsDirSize + wsAppDataDirSize
deviceUsageStat.UsageSplit.EdgeApps += edgeappsUsageSplit deviceUsageStat.UsageSplit.EdgeApps += edgeappsUsageSplit
} }
bucketsUsageSplit := (uint64)(0) if device.MainDevice {
othersUsageSplit := (uint64)(0) osUsageSplit = (s.Used - othersUsageSplit - bucketsUsageSplit - edgeappsUsageSplit)
osUsageSplit := (s.Used - othersUsageSplit - bucketsUsageSplit - edgeappsUsageSplit) } else {
othersUsageSplit = (s.Used - bucketsUsageSplit - edgeappsUsageSplit)
}
partitionUsageSplit := UsageSplit{ partitionUsageSplit := UsageSplit{
OS: osUsageSplit, OS: osUsageSplit,
@ -233,6 +240,8 @@ func getDevicesSpaceUsage(devices []Device) []Device {
} }
}
devices[deviceIndex].UsageStat = deviceUsageStat devices[deviceIndex].UsageStat = deviceUsageStat
totalDevicePercentUsage := fmt.Sprintf("%2.f%%", (float32(devices[deviceIndex].UsageStat.Used)/float32(devices[deviceIndex].UsageStat.Total))*100) totalDevicePercentUsage := fmt.Sprintf("%2.f%%", (float32(devices[deviceIndex].UsageStat.Used)/float32(devices[deviceIndex].UsageStat.Total))*100)
devices[deviceIndex].UsageStat.Percent = totalDevicePercentUsage devices[deviceIndex].UsageStat.Percent = totalDevicePercentUsage

View File

@ -259,9 +259,13 @@ func ExecuteSchedules(tick int) {
} }
if tick%5 == 0 {
// Executing every 5 ticks
log.Println(taskGetStorageDevices())
}
if tick%30 == 0 { if tick%30 == 0 {
// Executing every 30 ticks // Executing every 30 ticks
log.Println(taskGetStorageDevices())
log.Println(taskGetEdgeApps()) log.Println(taskGetEdgeApps())
} }