MCPcopy Create free account
hub / github.com/FloatTech/NanoBot-Plugin / diskstate

Function diskstate

plugin/status/main.go:575–597  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

573}
574
575func diskstate() (stateinfo []*status, err error) {
576 parts, err := disk.Partitions(false)
577 if err != nil {
578 return
579 }
580 stateinfo = make([]*status, 0, len(parts))
581 for _, v := range parts {
582 mp := v.Mountpoint
583 if strings.HasPrefix(mp, "/snap/") || strings.HasPrefix(mp, "/apex/") {
584 continue
585 }
586 diskusage, err := disk.Usage(mp)
587 if err != nil {
588 continue
589 }
590 stateinfo = append(stateinfo, &status{
591 precent: math.Round(diskusage.UsedPercent),
592 name: mp,
593 text: []string{storagefmt(float64(diskusage.Used)) + " / " + storagefmt(float64(diskusage.Total))},
594 })
595 }
596 return stateinfo, nil
597}
598
599func moreinfo(m *ctrl.Control[*nano.Ctx]) (stateinfo []*status, err error) {
600 var mems runtime.MemStats

Callers 1

drawstatusFunction · 0.85

Calls 1

storagefmtFunction · 0.85

Tested by

no test coverage detected