package master_ui import ( "fmt" "html/template" "strconv" "strings" ) func bytesToHumanReadble(b uint64) string { const unit = 1024 if b < unit { return fmt.Sprintf("%d B", b) } div, exp := uint64(unit), 0 for n := b / unit; n >= unit; n /= unit { div *= unit exp++ } return fmt.Sprintf("%.2f %ciB", float64(b)/float64(div), "KMGTPE"[exp]) } func percentFrom(total uint64, part_of uint64) string { return fmt.Sprintf("%.2f", (float64(part_of)/float64(total))*100) } func join(data []int64) string { var ret []string for _, d := range data { ret = append(ret, strconv.Itoa(int(d))) } return strings.Join(ret, ",") } var funcMap = template.FuncMap{ "join": join, "bytesToHumanReadble": bytesToHumanReadble, "percentFrom": percentFrom, } var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(` SeaweedFS {{ .Version }}

Disk Stats

{{ range .DiskStatuses }} {{ end }}
Path Total Free % Usage
{{ .Dir }} {{ bytesToHumanReadble .All }} {{ bytesToHumanReadble .Free }} {{ percentFrom .All .Used}}

System Stats

{{ range $key, $val := .Stats }} {{ end }}
Masters {{.Masters}}
Weekly # ReadRequests {{ .Counters.ReadRequests.WeekCounter.ToList | join }}
Daily # ReadRequests {{ .Counters.ReadRequests.DayCounter.ToList | join }}
Hourly # ReadRequests {{ .Counters.ReadRequests.HourCounter.ToList | join }}
Last Minute # ReadRequests {{ .Counters.ReadRequests.MinuteCounter.ToList | join }}
{{ $key }} {{ $val }}

Volumes

{{ range .Volumes }} {{ end }}
Id Collection Data Size Files Trash TTL ReadOnly
{{ .Id }} {{ .Collection }} {{ .Size }} Bytes {{ .FileCount }} {{ .DeleteCount }} / {{.DeletedByteCount}} Bytes {{ .Ttl }} {{ .ReadOnly }}

Remote Volumes

{{ range .RemoteVolumes }} {{ end }}
Id Collection Size Files Trash Remote Key
{{ .Id }} {{ .Collection }} {{ .Size }} Bytes {{ .FileCount }} {{ .DeleteCount }} / {{.DeletedByteCount}} Bytes {{ .RemoteStorageName }} {{ .RemoteStorageKey }}

Erasure Coding Shards

{{ range .EcVolumes }} {{ end }}
Id Collection Shard Size Shards CreatedAt
{{ .VolumeId }} {{ .Collection }} {{ .ShardSize }} Bytes {{ .ShardIdList }} {{ .CreatedAt.Format "02 Jan 06 15:04 -0700" }}
`))