Documentation ¶
Overview ¶
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2023=2025, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2023-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package teb contains templates and (templated) tables to format CLI output.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Index ¶
- Constants
- Variables
- func FmtBool(t bool) string
- func FmtCopies(copies int) string
- func FmtDateTime(t time.Time) (s string)
- func FmtDuration(ns int64, units string) string
- func FmtEC(gen int64, data, parity int, isCopy bool) string
- func FmtNodeStatus(node *meta.Snode) (status string)
- func FmtSize(size int64, units string, digits int) string
- func FmtStatValue(name, kind string, value int64, units string) string
- func FmtTime(t time.Time) (s string)
- func FmtXactRunFinAbrt(snap *core.Snap) (s string)
- func FormatDuration(d time.Duration) string
- func FuncMapUnits(units string, datedTime bool) (m template.FuncMap)
- func Init(w io.Writer, noColor bool)
- func LsoTemplate(propsList []string, hideHeader, addCachedCol, addStatusCol bool) string
- func Print(object any, templ string, aux ...Opts) error
- func ValidateUnits(units string) error
- type CntSiz
- type DiskStatsHelper
- type ListBucketsHelper
- type Opts
- type PerfTabCtx
- type ScrBp
- type ScrubHelper
- type SmapHelper
- type StatsAndStatusHelper
- type StatusHelper
- type StstMap
- type Table
Constants ¶
const ( NotSetVal = "-" UnknownStatusVal = "n/a" )
const ( ClusterTotal = "--- Cluster:" TargetTotal = "------- Sum:" )
const ( ScrObjects = iota ScrNotIn ScrMisplaced ScrMissingCp ScrSmallSz ScrLargeSz ScrVchanged ScrVremoved ScrNumStats // NOTE: must be the last )
const ( SmapTmpl = smapHdr + "{{ range $key, $value := .Smap.Pmap }}" + smapNode + "{{end}}\n" + smapHdr + smapBody SmapTmplNoHdr = "{{ range $key, $value := .Smap.Pmap }}" + smapNode + "{{end}}\n" + smapBody ClusterSummary = indent1 + "Proxies:\t{{FormatProxiesSumm .Smap}}\n" + indent1 + "Targets:\t{{FormatTargetsSumm .Smap .NumDisks}}\n" + indent1 + "Capacity:\t{{.Capacity}}\n" + indent1 + "Cluster Map:\t{{FormatSmap .Smap}}\n" + indent1 + "Software:\t{{FormatCluSoft .Version .BuildTime}}\n" + indent1 + "Deployment:\t{{ ( Deployments .Stst) }}\n" + indent1 + "Status:\t{{ ( OnlineStatus .Stst) }}\n" + indent1 + "Rebalance:\t{{FormatRebalance .Stst .CluConfig}}\n" + indent1 + "Authentication:\t{{if .CluConfig.Auth.Enabled}}enabled{{else}}disabled{{end}}\n" + indent1 + "Version:\t{{ ( Versions .Stst) }}\n" + indent1 + "Build:\t{{ ( BuildTimes .Stst) }}\n" // Config DaemonConfigTmpl = "{{ if .ClusterConfigDiff }}PROPERTY\t VALUE\t DEFAULT\n{{range $item := .ClusterConfigDiff }}" + "{{ $item.Name }}\t {{ $item.Current }}\t {{ $item.Old }}\n" + "{{end}}\n{{end}}" + "{{ if .LocalConfigPairs }}PROPERTY\t VALUE\n" + "{{range $item := .LocalConfigPairs }}" + "{{ $item.Name }}\t {{ $item.Value }}\n" + "{{end}}\n{{end}}" PropValTmpl = propValTmplHdr + PropValTmplNoHdr PropValTmplNoHdr = "{{range $p := . }}" + "{{$p.Name}}\t {{$p.Value}}\n" + "{{end}}" DownloadListNoHdrTmpl = "{{ range $key, $value := . }}" + downloadListBody + "{{end}}" DownloadListTmpl = downloadListHdr + DownloadListNoHdrTmpl DsortListNoHdrTmpl = "{{ range $value := . }}" + dsortListBody + "{{end}}" DsortListTmpl = dsortListHdr + DsortListNoHdrTmpl DsortListVerboseTmpl = dsortListHdr + "{{ range $value := . }}" + dsortListBody + indent1 + "Total Extracted Bytes:\t{{if (eq $value.Bytes 0) }}-{{else}}{{FormatBytesSig $value.Bytes 2}}{{end}}\n" + indent1 + "Extraction Time:\t{{if (eq $value.ExtractedDuration 0) }}-{{else}}{{FormatDuration $value.ExtractedDuration}}{{end}}\n" + indent1 + "Sorting Time:\t{{if (eq $value.SortingDuration 0) }}-{{else}}{{FormatDuration $value.SortingDuration}}{{end}}\n" + indent1 + "Creation Time:\t{{if (eq $value.CreationDuration 0) }}-{{else}}{{FormatDuration $value.CreationDuration}}{{end}}\n" + indent1 + "Description:\t{{$value.Metrics.Description}}\n" + "{{end}}" TransformListNoHdrTmpl = "{{ range $value := . }}" + transformListBody + "{{end}}" TransformListTmpl = transformListHdr + TransformListNoHdrTmpl XactBucketTmpl = xactBucketHdr + XactNoHdrBucketTmpl XactNoHdrBucketTmpl = "{{range $nodeSnaps := . }}" + xactBucketBodyAll + "{{end}}" XactNoBucketTmpl = xactNoBucketHdr + XactNoHdrNoBucketTmpl XactNoHdrNoBucketTmpl = "{{range $nodeSnaps := . }}" + xactNoBucketBodyAll + "{{end}}" XactFromToTmpl = xactFromToHdr + XactNoHdrFromToTmpl XactNoHdrFromToTmpl = "{{range $nodeSnaps := . }}" + xactFromToBodyAll + "{{end}}" XactECGetTmpl = xactECGetStatsHdr + XactECGetNoHdrTmpl XactECGetNoHdrTmpl = "{{range $daemon := . }}" + xactECGetBody + "{{end}}" XactECPutTmpl = xactECPutStatsHdr + XactECPutNoHdrTmpl XactECPutNoHdrTmpl = "{{range $nodeSnaps := . }}" + xactECPutBody + "{{end}}" ListBucketsSummBody = "{{range $k, $v := . }}" + "{{FormatBckName $v.Bck}}\t {{FormatBool $v.Info.IsBckPresent}}\t " + "{{$v.Info.ObjCount.Present}} {{$v.Info.ObjCount.Remote}}\t " + "{{FormatBytesUns $v.Info.TotalSize.OnDisk 2}} {{FormatBytesUns $v.Info.TotalSize.PresentObjs 2}} {{FormatBytesUns $v.Info.TotalSize.RemoteObjs 2}}\t " + "{{if (IsFalse $v.Info.IsBckPresent)}}-{{else}}{{$v.Info.UsedPct}}%{{end}}\n" + "{{end}}" ListBucketsSummTmpl = listBucketsSummHdr + ListBucketsSummBody ListBucketsHdrNoSummary = "NAME\t PRESENT\n" ListBucketsBodyNoSummary = "{{range $k, $v := . }}" + "{{FormatBckName $v.Bck}}\t {{FormatBool $v.Info.IsBckPresent}}\n" + "{{end}}" ListBucketsTmplNoSummary = ListBucketsHdrNoSummary + ListBucketsBodyNoSummary // Bucket summary templates BucketsSummariesTmpl = "NAME\t OBJECTS (cached, remote)\t OBJECT SIZES (min, avg, max)\t TOTAL OBJECT SIZE (cached, remote)\t USAGE(%)\n" + BucketsSummariesBody BucketsSummariesBody = "{{range $k, $v := . }}" + "{{FormatBckName $v.Bck}}\t {{$v.ObjCount.Present}} {{$v.ObjCount.Remote}}\t " + "{{FormatMAM $v.ObjSize.Min}} {{FormatMAM $v.ObjSize.Avg}} {{FormatMAM $v.ObjSize.Max}}\t " + "{{FormatBytesUns $v.TotalSize.PresentObjs 2}} {{FormatBytesUns $v.TotalSize.RemoteObjs 2}}\t {{$v.UsedPct}}%\n" + "{{end}}" // For `object put` mass uploader. A caller adds to the template // total count and size. That is why the template ends with \t MultiPutTmpl = "Files to upload:\nEXTENSION\t COUNT\t SIZE\n" + "{{range $k, $v := . }}" + "{{$k}}\t {{$v.Cnt}}\t {{FormatBytesSig $v.Size 2}}\n" + "{{end}}" + "TOTAL\t " ExtendedUsageTmpl = "{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}} - {{.Usage}}\n" + "\n\tCOMMANDS:\t" + "{{range .VisibleCategories}}" + "{{ range $index, $element := .VisibleCommands}}" + "{{if $index}}, {{end}}" + "{{if ( eq ( Mod $index 13 ) 12 ) }}\n\t\t{{end}}" + "{{$element.Name}}" + "{{if ( eq $element.Name \"search\" ) }}\n\t\t{{end}}" + "{{end}}{{end}}\n" + "{{if .VisibleFlags}}\tOPTIONS:\t" + "{{ range $index, $flag := .VisibleFlags}}" + "{{if $index}}, {{end}}" + "--{{FlagName $flag }}" + "{{end}}{{end}}\n" ShortUsageTmpl = `{{.HelpName}} - {{.Usage}} {{.UsageText}} USAGE: {{.HelpName}} {{.ArgsUsage}} See '--help' and docs/cli for details.` AuthNClusterTmpl = "CLUSTER ID\tALIAS\tURLs\n" + "{{ range $clu := . }}" + "{{ $clu.ID }}\t{{ $clu.Alias }}\t{{ JoinList $clu.URLs }}\n" + "{{end}}" AuthNRoleTmpl = "ROLE\tDESCRIPTION\n" + "{{ range $role := . }}" + "{{ $role.Name }}\t{{ $role.Description }}\n" + "{{end}}" AuthNUserTmpl = "NAME\tROLES\n" + "{{ range $user := . }}" + "{{ $user.ID }}\t{{ range $i, $role := $user.Roles }}" + "{{ if $i }}, {{ end }}{{ $role.Name }}" + "{{end}}\n" + "{{end}}" AuthNUserVerboseTmpl = "Name\t{{ .ID }}\n" + "Roles\t{{ range $i, $role := .Roles }}{{ if $i }}, {{ end }}{{ $role.Name }}{{ end }}\n" + "{{ range $role := .Roles }}" + "{{ if ne (len $role.ClusterACLs) 0 }}" + "CLUSTER ID\tALIAS\tPERMISSIONS\n" + "{{ range $clu := $role.ClusterACLs }}" + "{{ $clu.ID }}\t{{ $clu.Alias }}\t{{ FormatACL $clu.Access }}\n" + "{{end}}{{end}}" + "{{ if ne (len $role.BucketACLs) 0 }}" + "BUCKET\tPERMISSIONS\n" + "{{ range $bck := $role.BucketACLs }}" + "{{ FormatBckName $bck.Bck }}\t{{ FormatACL $bck.Access }}\n" + "{{end}}{{end}}" + "{{ end }}" AuthNRoleVerboseTmpl = "Role\t{{ .Name }}\n" + "Description\t{{ .Description }}\n" + "{{ if ne (len .ClusterACLs) 0 }}" + "CLUSTER ID\tALIAS\tPERMISSIONS\n" + "{{ range $clu := .ClusterACLs }}" + "{{ $clu.ID }}\t{{ $clu.Alias }}\t{{ FormatACL $clu.Access }}\n" + "{{end}}{{end}}" + "{{ if ne (len .BucketACLs) 0 }}" + "BUCKET\tPERMISSIONS\n" + "{{ range $bck := .BucketACLs }}" + "{{ FormatBckName $bck.Bck }}\t{{ FormatACL $bck.Access }}\n" + "{{end}}{{end}}" // `search` SearchTmpl = "{{ JoinListNL . }}\n" // `show mountpath` MpathListTmpl = "{{range $p := . }}" + "{{ $p.DaemonID }}\n" + "{{if and (eq (len $p.Mpl.Available) 0) (eq (len $p.Mpl.Disabled) 0)}}" + "\tNo mountpaths\n" + "{{else}}" + "{{if ne (len $p.Mpl.Available) 0}}" + "\tUsed: {{FormatCapPctMAM $p.Tcdf true}}\t " + "{{if (IsEqS $p.Tcdf.CsErr \"\")}}{{else}}{{$p.Tcdf.CsErr}}{{end}}\n" + "{{range $mp := $p.Mpl.Available }}" + "\t\t{{ $mp }} " + "{{range $k, $v := $p.Tcdf.Mountpaths}}" + "{{if (IsEqS $k $mp)}}{{FormatCDFDisks $v}}{{end}}" + "{{end}}\n" + "{{end}}{{end}}" + "{{if ne (len $p.Mpl.Disabled) 0}}" + "\tDisabled:\n" + "{{range $mp := $p.Mpl.Disabled }}" + "\t\t{{ $mp }}\n" + "{{end}}{{end}}" + "{{if ne (len $p.Mpl.WaitingDD) 0}}" + "\tTransitioning to disabled or detached pending resilver:\n" + "{{range $mp := $p.Mpl.WaitingDD }}" + "\t\t{{ $mp }}\n" + "{{end}}{{end}}" + "{{end}}{{end}}" )
const (
NodeOnline = "online"
)
Variables ¶
var ( ScrCols = [...]string{colObjects, colNotIn, colMisplaced, colMissingCp, colSmallSz, colLargeSz, colVchanged, colVremoved} ScrNums = [...]int64{0, 0, 0, 0, 0, 0, 0, 0} )
var ( AliasTemplate = "ALIAS\tCOMMAND\n{{range $alias := .}}" + "{{ $alias.Name }}\t{{ $alias.Value }}\n" + "{{end}}" HelpTemplateFuncMap = template.FuncMap{ "FlagName": func(f cli.Flag) string { return strings.SplitN(f.GetName(), ",", 2)[0] }, "Mod": func(a, mod int) int { return a % mod }, } )
var ( // ObjectPropsMap matches ObjEntry field ObjectPropsMap = map[string]string{ apc.GetPropsName: "{{FormatNameDirArch $obj.Name $obj.Flags}}", apc.GetPropsSize: "{{FormatBytesSig2 $obj.Size 2 $obj.Flags}}", apc.GetPropsChecksum: "{{$obj.Checksum}}", apc.GetPropsAtime: "{{$obj.Atime}}", apc.GetPropsVersion: "{{$obj.Version}}", apc.GetPropsLocation: "{{$obj.Location}}", apc.GetPropsCustom: "{{FormatObjCustom $obj.Custom}}", apc.GetPropsStatus: "{{FormatLsObjStatus $obj}}", apc.GetPropsCopies: "{{$obj.Copies}}", apc.GetPropsCached: "{{FormatLsObjIsCached $obj}}", } )
var Writer io.Writer
Functions ¶
func FmtDateTime ¶
func FmtDuration ¶
func FmtEC ¶
FmtEC formats EC data (DataSlices, ParitySlices, IsECCopy) into a readable string for CLI, e.g. "1:2[encoded]"
func FmtNodeStatus ¶
func FmtStatValue ¶
(with B, ns, and /s suffix)
func FmtXactRunFinAbrt ¶
func FormatDuration ¶
round to an assorted set of multiples
func LsoTemplate ¶
func ValidateUnits ¶
Types ¶
type DiskStatsHelper ¶
type ListBucketsHelper ¶
type PerfTabCtx ¶
type PerfTabCtx struct { Smap *meta.Smap Sid string // single target, unless "" Metrics cos.StrKVs // metric (aka stats) names and kinds Regex *regexp.Regexp // filter column names (case-insensitive) Units string // IEC, SI, raw Totals map[string]int64 // metrics to sum up (name => sum(column)), where the name is IN and the sum is OUT TotalsHdr string AvgSize bool // compute average size on the fly (and show it), e.g.: `get.size/get.n` Idle bool // currently idle NoColor bool }
type ScrubHelper ¶
type ScrubHelper struct {
All []*ScrBp
}
type SmapHelper ¶
type StatsAndStatusHelper ¶
type StatusHelper ¶
type StatusHelper struct { Smap *meta.Smap CluConfig *cmn.ClusterConfig Stst StatsAndStatusHelper Capacity string Version string // when all equal BuildTime string // ditto NumDisks int }
type StstMap ¶
type StstMap map[string]*stats.NodeStatus // by node ID (SID)
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func NewDiskTab ¶
func NewMpathCapTab ¶
func NewMpathCapTab(st StstMap, c *PerfTabCtx, showMpaths bool) *Table