Files
zeekay ca324e043d feat: replace MinIO fork with SeaweedFS-engine Hanzo S3
Kill MinIO; migrate object storage to SeaweedFS, rebranded Hanzo S3.
- module github.com/hanzoai/s3 (all 1920 imports rewritten); seaweedfs/{raft,goexif,go-fuse,cockroachdb-parser} kept as deps
- binary weed -> s3; display brand SeaweedFS -> Hanzo S3 (Server/version/admin); wire identifiers unchanged for S3 compat
- Dockerfile builds s3 (CGO_ENABLED=0, ldflags) -> ghcr.io/hanzoai/s3 via shared CI
- MinIO preserved in git history (prior main)
2026-06-19 23:34:08 -07:00

57 lines
2.1 KiB
Go
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build !windows && !openbsd && !netbsd && !plan9 && !solaris
package main
import (
"log"
"syscall"
)
// go run unmaintained/disk/disk_status.go
type DiskStatus struct {
Dir string `protobuf:"bytes,1,opt,name=dir,proto3" json:"dir,omitempty"`
All uint64 `protobuf:"varint,2,opt,name=all,proto3" json:"all,omitempty"`
Used uint64 `protobuf:"varint,3,opt,name=used,proto3" json:"used,omitempty"`
Free uint64 `protobuf:"varint,4,opt,name=free,proto3" json:"free,omitempty"`
PercentFree float32 `protobuf:"fixed32,5,opt,name=percent_free,json=percentFree,proto3" json:"percent_free,omitempty"`
PercentUsed float32 `protobuf:"fixed32,6,opt,name=percent_used,json=percentUsed,proto3" json:"percent_used,omitempty"`
DiskType string `protobuf:"bytes,7,opt,name=disk_type,json=diskType,proto3" json:"disk_type,omitempty"`
// new fields about avail blocks
Avail uint64 `protobuf:"varint,4,opt,name=avail,proto3" json:"avail,omitempty"`
PercentAvail float32 `protobuf:"fixed32,5,opt,name=percent_avail,json=percentAvail,proto3" json:"percent_avail,omitempty"`
}
func main() {
dirs := []string{"/mnt/sdb", "/mnt/sdc", "/mnt/sdd", "/mnt/sde", "/mnt/sdf", "/mnt/sdg", "/mnt/sdh", "/mnt/sdi", "/mnt/sdj"}
// dirs := []string{"/mnt/sdb"}
for _, dir := range dirs {
disk := &DiskStatus{Dir: dir}
fillInDiskStatus(disk)
// bytes, _ := json.Marshal(disk)
// log.Printf("disk status %s", bytes)
log.Printf("disk: %s avail: %f free: %f", disk.Dir, disk.PercentAvail, disk.PercentFree)
}
}
func fillInDiskStatus(disk *DiskStatus) {
fs := syscall.Statfs_t{}
err := syscall.Statfs(disk.Dir, &fs)
if err != nil {
return
}
disk.All = fs.Blocks * uint64(fs.Bsize)
disk.Free = fs.Bfree * uint64(fs.Bsize)
disk.Used = disk.All - disk.Free
disk.PercentFree = float32((float64(disk.Free) / float64(disk.All)) * 100)
disk.PercentUsed = float32((float64(disk.Used) / float64(disk.All)) * 100)
// avail blocks
disk.Avail = fs.Bavail * uint64(fs.Bsize)
disk.PercentAvail = float32((float64(disk.Avail) / float64(disk.All)) * 100)
return
}