teb

package
v0.0.0-...-a9afcfa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 22 Imported by: 0

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

View Source
const (
	NotSetVal = "-"

	UnknownStatusVal = "n/a"
)
View Source
const (
	ClusterTotal = "--- Cluster:"
	TargetTotal  = "------- Sum:"
)
View Source
const (
	ScrObjects = iota
	ScrNotIn
	ScrMisplaced
	ScrMissingCp
	ScrSmallSz
	ScrLargeSz
	ScrVchanged
	ScrVremoved

	ScrNumStats // NOTE: must be the last
)
View Source
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}}"
)
View Source
const (
	NodeOnline = "online"
)

Variables

View Source
var (
	ScrCols = [...]string{colObjects, colNotIn, colMisplaced, colMissingCp, colSmallSz, colLargeSz, colVchanged, colVremoved}
	ScrNums = [...]int64{0, 0, 0, 0, 0, 0, 0, 0}
)
View Source
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 },
	}
)
View Source
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}}",
	}
)
View Source
var Writer io.Writer

Functions

func FmtBool

func FmtBool(t bool) string

FmtBool returns "yes" if true, else "no"

func FmtCopies

func FmtCopies(copies int) string

FmtCopies formats an int to a string, where 0 becomes "-"

func FmtDateTime

func FmtDateTime(t time.Time) (s string)

func FmtDuration

func FmtDuration(ns int64, units string) string

func FmtEC

func FmtEC(gen int64, data, parity int, isCopy bool) string

FmtEC formats EC data (DataSlices, ParitySlices, IsECCopy) into a readable string for CLI, e.g. "1:2[encoded]"

func FmtNodeStatus

func FmtNodeStatus(node *meta.Snode) (status string)

func FmtSize

func FmtSize(size int64, units string, digits int) string

func FmtStatValue

func FmtStatValue(name, kind string, value int64, units string) string

(with B, ns, and /s suffix)

func FmtTime

func FmtTime(t time.Time) (s string)

func FmtXactRunFinAbrt

func FmtXactRunFinAbrt(snap *core.Snap) (s string)

func FormatDuration

func FormatDuration(d time.Duration) string

round to an assorted set of multiples

func FuncMapUnits

func FuncMapUnits(units string, datedTime bool) (m template.FuncMap)

func Init

func Init(w io.Writer, noColor bool)

func LsoTemplate

func LsoTemplate(propsList []string, hideHeader, addCachedCol, addStatusCol bool) string

func Print

func Print(object any, templ string, aux ...Opts) error

main func

func ValidateUnits

func ValidateUnits(units string) error

Types

type CntSiz

type CntSiz struct {
	Cnt int64
	Siz int64
}

type DiskStatsHelper

type DiskStatsHelper struct {
	TargetID string
	DiskName string
	Stat     cos.DiskStats
	Tcdf     *fs.Tcdf
}

type ListBucketsHelper

type ListBucketsHelper struct {
	XactID string
	Bck    cmn.Bck
	Props  *cmn.Bprops
	Info   *cmn.BsummResult
}

type Opts

type Opts struct {
	AltMap  template.FuncMap
	Units   string
	UseJSON bool
}

auxiliary

func Jopts

func Jopts(usejs bool) Opts

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
}

func (*PerfTabCtx) MakeTab

func (c *PerfTabCtx) MakeTab(st StstMap) (*Table, int, error)

return numNZ (non-zero) metrics OR bad status

type ScrBp

type ScrBp struct {
	Bck    cmn.Bck
	Prefix string
	Stats  [ScrNumStats]CntSiz
	// work
	Line  cos.Builder
	Cname string
}

type ScrubHelper

type ScrubHelper struct {
	All []*ScrBp
}

func (*ScrubHelper) MakeTab

func (h *ScrubHelper) MakeTab(units string, haveRemote bool) *Table

type SmapHelper

type SmapHelper struct {
	Smap         *meta.Smap
	ExtendedURLs bool
}

type StatsAndStatusHelper

type StatsAndStatusHelper struct {
	Pmap StstMap
	Tmap StstMap
}

func (*StatsAndStatusHelper) MakeTabP

func (h *StatsAndStatusHelper) MakeTabP(smap *meta.Smap, units string) *Table

proxy(ies)

func (*StatsAndStatusHelper) MakeTabT

func (h *StatsAndStatusHelper) MakeTabT(smap *meta.Smap, units string) *Table

target(s)

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 NewDiskTab(dsh []*DiskStatsHelper, smap *meta.Smap, regex *regexp.Regexp, units, totalsHdr string, withCap bool) *Table

func NewMpathCapTab

func NewMpathCapTab(st StstMap, c *PerfTabCtx, showMpaths bool) *Table

func (*Table) Template

func (t *Table) Template(hideHeader bool) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL