report

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Copyright 2018 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// JournalDateFormat defines the timestamp format for journalctl since/until flags
	JournalDateFormat = "2006-01-02 15:04:05"

	// FilterSystem defines a report collection filter to fetch system diagnostics
	FilterSystem = "system"

	// FilterKubernetes defines a report collection filter to fetch kubernetes diagnostics
	FilterKubernetes = "kubernetes"

	// FilterEtcd defines a report collection filter to fetch etcd data
	FilterEtcd = "etcd"

	// FilterTimeline defines a report collection filter to fetch the status timeline
	FilterTimeline = "timeline"

	// FilterResources defines a report collection filter to fetch gravity resources
	FilterResources = "resources"
)

Variables

AllFilters lists all available collector filters

Functions

func Collect

func Collect(ctx context.Context, config Config, w io.Writer) error

Collect collects diagnostic information using the default set of collectors. The results are written as a compressed tarball to w.

Types

type Collector

type Collector interface {
	// Collect collects diagnostics using CommandRunner and serializes
	// them using specified Writer
	Collect(context.Context, FileWriter, utils.CommandRunner) error
}

Collector defines an interface to collect diagnostic information

type CollectorFunc

type CollectorFunc func(context.Context, FileWriter, utils.CommandRunner) error

CollectorFunc allows ordinary functions as Collectors

func (CollectorFunc) Collect

func (r CollectorFunc) Collect(ctx context.Context, w FileWriter, runner utils.CommandRunner) error

Collect invokes this function with the specified parameters. Implements Collector

type Collectors

type Collectors []Collector

Collectors is a list of Collectors

func NewKubernetesCollector

func NewKubernetesCollector(ctx context.Context, runner utils.CommandRunner, since time.Duration) Collectors

NewKubernetesCollector returns a list of collectors to fetch kubernetes-specific diagnostics.

func NewSystemCollector

func NewSystemCollector(since time.Duration) Collectors

NewSystemCollector returns a list of collectors to fetch system information

func ResourceCollectors

func ResourceCollectors() Collectors

ResourceCollectors returns gravity resource collectors.

func (Collectors) Collect

func (r Collectors) Collect(ctx context.Context, reportWriter FileWriter, runner utils.CommandRunner) error

Collect implements Collector for a list of Collectors

type Command

type Command struct {
	// contains filtered or unexported fields
}

Command defines a generic command with a name and a list of arguments

func Cmd

func Cmd(name string, args ...string) Command

Cmd creates a new Command with the given name and command line

func Self

func Self(name string, args ...string) Command

Self returns a reference to this binary. name names the resulting output file. args is the list of optional command line arguments

func (Command) Collect

func (r Command) Collect(ctx context.Context, reportWriter FileWriter, runner utils.CommandRunner) error

Collect implements Collector for this Command

func (Command) String

func (r Command) String() string

String returns a text representation of this command

type Config

type Config struct {
	log.FieldLogger
	// Filters lists collection filters.
	Filters []string
	// Compressed controls whether the resulting tarball is compressed
	Compressed bool
	// Packages specifies the package service for the package
	// diagnostics collector
	Packages pack.PackageService
	// Since specifies the start of the time filter. A value of 1h will report
	// log entries starting from one hour ago up till the end of the time filter.
	Since time.Duration
}

Config defines collector configuration

type FileWriter

type FileWriter interface {
	// NewWriter creates a new report writer with the specified name.
	NewWriter(name string) (io.WriteCloser, error)
}

FileWriter is a factory for creating named file writers

type FileWriterFunc

type FileWriterFunc func(name string) (io.WriteCloser, error)

FileWriterFunc is a functional wrapper for NamedWriter

func NewFileWriter

func NewFileWriter(dir string) FileWriterFunc

NewFileWriter creates a Writer that writes to a file in the specified directory dir

func (FileWriterFunc) NewWriter

func (r FileWriterFunc) NewWriter(name string) (io.WriteCloser, error)

NewWriter creates a new writer to write to a file with the specified name

type PackageCollector

type PackageCollector struct {
	// contains filtered or unexported fields
}

PackageCollector collects package-specific diagnostic information

func NewPackageCollector

func NewPackageCollector(packages pack.PackageService) *PackageCollector

NewPackageCollector returns a new package collector for the specified package service

func (PackageCollector) Collect

func (r PackageCollector) Collect(ctx context.Context, reportWriter FileWriter, runner utils.CommandRunner) error

Collect iterates through the system packages and outputs them using the specified reportWriter.

type PendingWriter

type PendingWriter struct {
	// contains filtered or unexported fields
}

PendingWriter forwards data to the underlying file. It only creates a file if there's data to forward.

func NewPendingFileWriter

func NewPendingFileWriter(path string) *PendingWriter

NewPendingFileWriter creates a new instance of the pendingWriter for the specified path

func (*PendingWriter) Close

func (r *PendingWriter) Close() error

Close closes the underlying file if it has been created. It implements io.Closer

func (*PendingWriter) Write

func (r *PendingWriter) Write(data []byte) (n int, err error)

Write forwards specified data to the underlying file which is created at this point if not yet existing. It implements io.Writer

type ScriptCollector

type ScriptCollector struct {
	// contains filtered or unexported fields
}

ScriptCollector is a convenience Collector to execute bash scripts

func Script

func Script(name, script string) ScriptCollector

Script creates a new script collector

func (ScriptCollector) Collect

func (r ScriptCollector) Collect(ctx context.Context, reportWriter FileWriter, runner utils.CommandRunner) error

Collect implements Collector using a bash script

func (ScriptCollector) String

func (r ScriptCollector) String() string

String returns a text representation of this script

type TimelineCollector

type TimelineCollector struct{}

TimelineCollector collects the cluster status timeline.

func NewTimelineCollector

func NewTimelineCollector() *TimelineCollector

NewTimelineCollector returns a new timeline collector.

func (TimelineCollector) Collect

func (r TimelineCollector) Collect(ctx context.Context, reportWriter FileWriter, runner utils.CommandRunner) error

Collect collects the cluster status timeline.

Jump to

Keyboard shortcuts

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