croshealthd

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package croshealthd provides methods for running and obtaining output from cros_healthd commands.

Index

Constants

View Source
const (
	RoutineBatteryCapacity         string = "battery_capacity"
	RoutineBatteryHealth                  = "battery_health"
	RoutineURandom                        = "urandom"
	RoutineSmartctlCheck                  = "smartctl_check"
	RoutineACPower                        = "ac_power"
	RoutineCPUCache                       = "cpu_cache"
	RoutineCPUStress                      = "cpu_stress"
	RoutineFloatingPointAccurary          = "floating_point_accuracy"
	RoutineNVMEWearLevel                  = "nvme_wear_level"
	RoutineNVMESelfTest                   = "nvme_self_test"
	RoutineDiskRead                       = "disk_read"
	RoutinePrimeSearch                    = "prime_search"
	RoutineBatteryDischarge               = "battery_discharge"
	RoutineBatteryCharge                  = "battery_charge"
	RoutineMemory                         = "memory"
	RoutineLanConnectivity                = "lan_connectivity"
	RoutineSignalStrength                 = "signal_strength"
	RoutineGatewayCanBePinged             = "gateway_can_be_pinged"
	RoutineHasSecureWifiConnection        = "has_secure_wifi_connection"
	RoutineDNSResolverPresent             = "dns_resolver_present"
	RoutineDNSLatency                     = "dns_latency"
	RoutineDNSResolution                  = "dns_resolution"
	RoutineCaptivePortal                  = "captive_portal"
	RoutineHTTPFirewall                   = "http_firewall"
	RoutineHTTPSFirewall                  = "https_firewall"
	RoutineHTTPSLatency                   = "https_latency"
)

List of cros_healthd diagnostic routines

View Source
const (
	StatusReady         string = "Ready"
	StatusRunning              = "Running"
	StatusWaiting              = "Waiting"
	StatusPassed               = "Passed"
	StatusFailed               = "Failed"
	StatusError                = "Error"
	StatusCancelled            = "Cancelled"
	StatusFailedToStart        = "Failed to start"
	StatusRemoved              = "Removed"
	StatusCancelling           = "Cancelling"
	StatusUnsupported          = "Unsupported"
	StatusNotRun               = "Not run"
)

List of possible routine statuses

View Source
const NotApplicable = "N/A"

NotApplicable is the value printed for optional fields when they aren't populated.

Variables

This section is empty.

Functions

func GetDiagRoutines

func GetDiagRoutines(ctx context.Context) ([]string, error)

GetDiagRoutines returns a list of valid routines for the device on success, or an error.

func RunAndParseJSONTelem

func RunAndParseJSONTelem(ctx context.Context, params TelemParams, outDir string, result interface{}) error

RunAndParseJSONTelem runs RunTelem and parses the JSON output. Example:

var result certainStruct
err := RunAndParseJSONTelem(_, _, _, &result)

func RunAndParseTelem

func RunAndParseTelem(ctx context.Context, params TelemParams, outDir string) ([][]string, error)

RunAndParseTelem runs RunTelem and parses the CSV output into a two-dimensional array. An error is returned if there is a failure to obtain or parse the output or if a line of output has an unexpected number of fields.

func RunTelem

func RunTelem(ctx context.Context, params TelemParams, outDir string) ([]byte, error)

RunTelem runs cros-health-tool's telem command with the given params and returns the output. It also dumps the output to a file for debugging. An error is returned if there is a failure to run the command or save the output to a file.

Types

type RoutineParams

type RoutineParams struct {
	Routine string // The name of the routine to run
	Cancel  bool   // Boolean flag to cancel the routine
}

RoutineParams are different configuration options for running a diagnostic routine.

type RoutineResult

type RoutineResult struct {
	Progress int
	Status   string
}

RoutineResult contains the progress of the routine as a percentage and the routine status.

func RunDiagRoutine

func RunDiagRoutine(ctx context.Context, params RoutineParams) (*RoutineResult, error)

RunDiagRoutine runs the specified routine based on `params`. Returns a RoutineResult on success or an error.

type TelemCategory

type TelemCategory string

TelemCategory represents a category flag that can be passed to the cros_healthd telem command.

const (
	TelemCategoryAudio             TelemCategory = "audio"
	TelemCategoryBacklight         TelemCategory = "backlight"
	TelemCategoryBattery           TelemCategory = "battery"
	TelemCategoryBluetooth         TelemCategory = "bluetooth"
	TelemCategoryBootPerformance   TelemCategory = "boot_performance"
	TelemCategoryBus               TelemCategory = "bus"
	TelemCategoryCPU               TelemCategory = "cpu"
	TelemCategoryDisplay           TelemCategory = "display"
	TelemCategoryFan               TelemCategory = "fan"
	TelemCategoryGraphics          TelemCategory = "graphics"
	TelemCategoryMemory            TelemCategory = "memory"
	TelemCategoryNetwork           TelemCategory = "network"
	TelemCategoryStatefulPartition TelemCategory = "stateful_partition"
	TelemCategoryStorage           TelemCategory = "storage"
	TelemCategorySystem            TelemCategory = "system"
	TelemCategorySystem2           TelemCategory = "system2"
	TelemCategoryTimezone          TelemCategory = "timezone"
)

Categories for the cros_healthd telem command.

type TelemParams

type TelemParams struct {
	// The category to pass as the --category flag.
	Category TelemCategory
	// The pid to pass as the --process flag.
	PID int
}

TelemParams provides arguments for running `cros-health-tool telem`.

Jump to

Keyboard shortcuts

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