teb

package
v0.0.0-...-9e9a750 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 23 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-2023, 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, NVIDIA CORPORATION. All rights reserved.

Package teb contains templates and (templated) tables to format CLI output.

  • Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.

Package teb contains templates and (templated) tables to format CLI output.

  • Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.

Package teb contains templates and (templated) tables to format CLI output.

  • Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.

Package teb contains templates and (templated) tables to format CLI output.

  • Copyright (c) 2018-2023, 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-2023, 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 (
	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 + "Deployment:\t{{ ( Deployments .Status) }}\n" +
		indent1 + "Status:\t{{ ( OnlineStatus .Status) }}\n" +
		indent1 + "Rebalance:\t{{ ( Rebalance .Status) }}\n" +
		indent1 + "Authentication:\t{{if .CluConfig.Auth.Enabled}}enabled{{else}}disabled{{end}}\n" +
		indent1 + "Version:\t{{ ( Versions .Status) }}\n" +
		indent1 + "Build:\t{{ ( BuildTimes .Status) }}\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

	//
	// all other xactions
	//
	XactBucketTmpl      = xactBucketHdr + XactNoHdrBucketTmpl
	XactNoHdrBucketTmpl = "{{range $daemon := . }}" + xactBucketBodyAll + "{{end}}"

	// same as above except for: src-bck, dst-bck columns
	XactFromToTmpl      = xactFromToHdr + XactNoHdrFromToTmpl
	XactNoHdrFromToTmpl = "{{range $daemon := . }}" + xactFromToBodyAll + "{{end}}"

	// same as above for: no bucket column
	XactNoBucketTmpl      = xactNoBucketHdr + XactNoHdrNoBucketTmpl
	XactNoHdrNoBucketTmpl = "{{range $daemon := . }}" + xactNoBucketBodyAll + "{{end}}"

	XactECGetTmpl      = xactECGetStatsHdr + XactECGetNoHdrTmpl
	XactECGetNoHdrTmpl = "{{range $daemon := . }}" + xactECGetBody + "{{end}}"

	XactECPutTmpl      = xactECPutStatsHdr + XactECPutNoHdrTmpl
	XactECPutNoHdrTmpl = "{{range $daemon := . }}" + 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}}"

	BucketSummaryValidateTmpl = "BUCKET\t OBJECTS\t MISPLACED\t MISSING COPIES\n" + bucketSummaryValidateBody

	// 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.ID }}\t{{ $role.Desc }}\n" +
		"{{end}}"

	AuthNUserTmpl = "NAME\tROLES\n" +
		"{{ range $user := . }}" +
		"{{ $user.ID }}\t{{ JoinList $user.Roles }}\n" +
		"{{end}}"

	AuthNUserVerboseTmpl = "Name\t{{ .ID }}\n" +
		"Roles\t{{ JoinList .Roles }}\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}}" +
		"{{ $bck }}\t{{ FormatACL $bck.Access }}\n" +
		"{{end}}{{end}}"

	AuthNRoleVerboseTmpl = "Role\t{{ .ID }}\n" +
		"Description\t{{ .Desc }}\n" +
		"{{ if ne (len .Roles) 0 }}" +
		"Roles\t{{ JoinList .Roles }}\n" +
		"{{ end }}" +
		"{{ 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}}" +
		"{{ $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.TargetCDF true}}\t " +
		"{{if (IsEqS $p.TargetCDF.CsErr \"\")}}{{else}}{{$p.TargetCDF.CsErr}}{{end}}\n" +
		"{{range $mp := $p.Mpl.Available }}" +
		"\t\t{{ $mp }} " +

		"{{range $k, $v := $p.TargetCDF.Mountpaths}}" +
		"{{if (IsEqS $k $mp)}}{{$v.FS}}{{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}}"
)

output templates

View Source
const (
	NodeOnline = "online"
)

Variables

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:     "{{FormatNameArch $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 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 FmtStartEnd

func FmtStartEnd(start, end time.Time) (startS, endS string)

func FmtStatValue

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

(with B, ns, and /s suffix)

func FmtXactStatus

func FmtXactStatus(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) (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 DiskStatsHelper

type DiskStatsHelper struct {
	TargetID string
	DiskName string
	Stat     ios.DiskStats
}

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
}

type SmapHelper

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

type StatsAndStatusHelper

type StatsAndStatusHelper struct {
	Pmap StstMap
	Tmap StstMap
}

type StatusHelper

type StatusHelper struct {
	Smap      *meta.Smap
	CluConfig *cmn.ClusterConfig
	Status    StatsAndStatusHelper
	Capacity  string
	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 NewDaeMapStatus

func NewDaeMapStatus(ds *StatsAndStatusHelper, smap *meta.Smap, daeType, units string) *Table

func NewDaeStatus

func NewDaeStatus(st *stats.NodeStatus, smap *meta.Smap, daeType, units string) *Table

func NewDiskTab

func NewDiskTab(dsh []DiskStatsHelper, smap *meta.Smap, regex *regexp.Regexp, units, totalsHdr string) *Table

func NewMpathCapTab

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

func NewPerformanceTab

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

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