mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
hardcoding system hostcollector filenames
This commit is contained in:
@@ -27,7 +27,7 @@ func (a *AnalyzeHostBlockDevices) IsExcluded() (bool, error) {
|
||||
func (a *AnalyzeHostBlockDevices) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
|
||||
hostAnalyzer := a.hostAnalyzer
|
||||
|
||||
contents, err := getCollectedFileContents("system/block_devices.json")
|
||||
contents, err := getCollectedFileContents(collect.HostBlockDevicesPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get collected file")
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (a *AnalyzeHostCPU) IsExcluded() (bool, error) {
|
||||
func (a *AnalyzeHostCPU) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
|
||||
hostAnalyzer := a.hostAnalyzer
|
||||
|
||||
contents, err := getCollectedFileContents("system/cpu.json")
|
||||
contents, err := getCollectedFileContents(collect.HostCPUPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get collected file")
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
|
||||
"github.com/replicatedhq/troubleshoot/pkg/collect"
|
||||
)
|
||||
|
||||
type AnalyzeHostIPV4Interfaces struct {
|
||||
@@ -26,7 +27,7 @@ func (a *AnalyzeHostIPV4Interfaces) IsExcluded() (bool, error) {
|
||||
func (a *AnalyzeHostIPV4Interfaces) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
|
||||
hostAnalyzer := a.hostAnalyzer
|
||||
|
||||
contents, err := getCollectedFileContents("system/ipv4Interfaces.json")
|
||||
contents, err := getCollectedFileContents(collect.HostIPV4InterfacesPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get collected file")
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (a *AnalyzeHostKernelModules) IsExcluded() (bool, error) {
|
||||
//
|
||||
func (a *AnalyzeHostKernelModules) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
|
||||
hostAnalyzer := a.hostAnalyzer
|
||||
contents, err := getCollectedFileContents("system/kernel_modules.json")
|
||||
contents, err := getCollectedFileContents(collect.HostKernelModulesPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get collected file")
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func (a *AnalyzeHostMemory) IsExcluded() (bool, error) {
|
||||
func (a *AnalyzeHostMemory) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
|
||||
hostAnalyzer := a.hostAnalyzer
|
||||
|
||||
contents, err := getCollectedFileContents("system/memory.json")
|
||||
contents, err := getCollectedFileContents(collect.HostMemoryPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get collected file")
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func (a *AnalyzeHostOS) Analyze(getCollectedFileContents func(string) ([]byte, e
|
||||
result := AnalyzeResult{}
|
||||
result.Title = a.Title()
|
||||
|
||||
contents, err := getCollectedFileContents("system/hostos_info.json")
|
||||
contents, err := getCollectedFileContents(collect.HostOSInfoPath)
|
||||
if err != nil {
|
||||
return []*AnalyzeResult{&result}, errors.Wrap(err, "failed to get collected file")
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package analyzer
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -26,13 +25,7 @@ func (a *AnalyzeHostServices) IsExcluded() (bool, error) {
|
||||
func (a *AnalyzeHostServices) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
|
||||
hostAnalyzer := a.hostAnalyzer
|
||||
|
||||
collectorName := hostAnalyzer.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "systemctl_services"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
contents, err := getCollectedFileContents(name)
|
||||
contents, err := getCollectedFileContents(collect.HostServicesPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get collected file")
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (a *AnalyzeHostTime) IsExcluded() (bool, error) {
|
||||
func (a *AnalyzeHostTime) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
|
||||
hostAnalyzer := a.hostAnalyzer
|
||||
|
||||
contents, err := getCollectedFileContents("system/time.json")
|
||||
contents, err := getCollectedFileContents(collect.HostTimePath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get collected file")
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package v1beta2
|
||||
|
||||
type CPUAnalyze struct {
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
}
|
||||
|
||||
type MemoryAnalyze struct {
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
}
|
||||
|
||||
type TCPLoadBalancerAnalyze struct {
|
||||
@@ -41,12 +43,14 @@ type HTTPAnalyze struct {
|
||||
}
|
||||
|
||||
type TimeAnalyze struct {
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
}
|
||||
|
||||
type BlockDevicesAnalyze struct {
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
|
||||
MinimumAcceptableSize uint64 `json:"minimumAcceptableSize" yaml:"minimumAcceptableSize"`
|
||||
IncludeUnmountedPartitions bool `json:"includeUnmountedPartitions" yaml:"includeUnmountedPartitions"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
@@ -59,8 +63,9 @@ type SystemPackagesAnalyze struct {
|
||||
}
|
||||
|
||||
type KernelModulesAnalyze struct {
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
}
|
||||
|
||||
type TCPConnectAnalyze struct {
|
||||
@@ -70,8 +75,9 @@ type TCPConnectAnalyze struct {
|
||||
}
|
||||
|
||||
type IPV4InterfacesAnalyze struct {
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
}
|
||||
|
||||
type FilesystemPerformanceAnalyze struct {
|
||||
@@ -93,8 +99,9 @@ type HostServicesAnalyze struct {
|
||||
}
|
||||
|
||||
type HostOSAnalyze struct {
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
AnalyzeMeta `json:",inline" yaml:",inline"`
|
||||
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
|
||||
Outcomes []*Outcome `json:"outcomes" yaml:"outcomes"`
|
||||
}
|
||||
type HostAnalyze struct {
|
||||
CPU *CPUAnalyze `json:"cpu,omitempty" yaml:"cpu,omitempty"`
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
|
||||
@@ -29,6 +28,7 @@ type BlockDeviceInfo struct {
|
||||
|
||||
const lsblkColumns = "NAME,KNAME,PKNAME,TYPE,MAJ:MIN,SIZE,FSTYPE,MOUNTPOINT,SERIAL,RO,RM"
|
||||
const lsblkFormat = `NAME=%q KNAME=%q PKNAME=%q TYPE=%q MAJ:MIN="%d:%d" SIZE="%d" FSTYPE=%q MOUNTPOINT=%q SERIAL=%q RO="%d" RM="%d0"`
|
||||
const HostBlockDevicesPath = `system/block_devices.json`
|
||||
|
||||
type CollectHostBlockDevices struct {
|
||||
hostCollector *troubleshootv1beta2.HostBlockDevices
|
||||
@@ -85,16 +85,10 @@ func (c *CollectHostBlockDevices) Collect(progressChan chan<- interface{}) (map[
|
||||
return nil, errors.Wrap(err, "failed to marshal block device info")
|
||||
}
|
||||
|
||||
collectorName := c.hostCollector.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "block_devices"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
output := NewResult()
|
||||
output.SaveResult(c.BundlePath, name, bytes.NewBuffer(b))
|
||||
output.SaveResult(c.BundlePath, HostBlockDevicesPath, bytes.NewBuffer(b))
|
||||
|
||||
return map[string][]byte{
|
||||
name: b,
|
||||
HostBlockDevicesPath: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package collect
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
|
||||
@@ -15,6 +14,8 @@ type CPUInfo struct {
|
||||
PhysicalCount int `json:"physicalCount"`
|
||||
}
|
||||
|
||||
const HostCPUPath = `system/cpu.json`
|
||||
|
||||
type CollectHostCPU struct {
|
||||
hostCollector *troubleshootv1beta2.CPU
|
||||
BundlePath string
|
||||
@@ -48,16 +49,10 @@ func (c *CollectHostCPU) Collect(progressChan chan<- interface{}) (map[string][]
|
||||
return nil, errors.Wrap(err, "failed to marshal cpu info")
|
||||
}
|
||||
|
||||
collectorName := c.hostCollector.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "cpu"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
output := NewResult()
|
||||
output.SaveResult(c.BundlePath, name, bytes.NewBuffer(b))
|
||||
output.SaveResult(c.BundlePath, HostCPUPath, bytes.NewBuffer(b))
|
||||
|
||||
return map[string][]byte{
|
||||
name: b,
|
||||
HostCPUPath: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
|
||||
)
|
||||
|
||||
const HostIPV4InterfacesPath = `system/ipv4Interfaces.json`
|
||||
|
||||
type CollectHostIPV4Interfaces struct {
|
||||
hostCollector *troubleshootv1beta2.IPV4Interfaces
|
||||
BundlePath string
|
||||
@@ -50,16 +51,10 @@ func (c *CollectHostIPV4Interfaces) Collect(progressChan chan<- interface{}) (ma
|
||||
return nil, errors.Wrap(err, "failed to marshal network interfaces")
|
||||
}
|
||||
|
||||
collectorName := c.hostCollector.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "ipv4Interfaces"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
output := NewResult()
|
||||
output.SaveResult(c.BundlePath, name, bytes.NewBuffer(b))
|
||||
output.SaveResult(c.BundlePath, HostIPV4InterfacesPath, bytes.NewBuffer(b))
|
||||
|
||||
return map[string][]byte{
|
||||
name: b,
|
||||
HostIPV4InterfacesPath: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ type KernelModuleInfo struct {
|
||||
Status KernelModuleStatus `json:"status"`
|
||||
}
|
||||
|
||||
const HostKernelModulesPath = `system/time.json`
|
||||
|
||||
// kernelModuleCollector defines the interface used to collect modules from the
|
||||
// underlying host.
|
||||
type kernelModuleCollector interface {
|
||||
@@ -96,17 +98,11 @@ func (c *CollectHostKernelModules) Collect(progressChan chan<- interface{}) (map
|
||||
return nil, errors.Wrap(err, "failed to marshal kernel modules")
|
||||
}
|
||||
|
||||
collectorName := c.hostCollector.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "kernel_modules"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
output := NewResult()
|
||||
output.SaveResult(c.BundlePath, name, bytes.NewBuffer(b))
|
||||
output.SaveResult(c.BundlePath, HostKernelModulesPath, bytes.NewBuffer(b))
|
||||
|
||||
return map[string][]byte{
|
||||
name: b,
|
||||
HostKernelModulesPath: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package collect
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
|
||||
@@ -14,6 +13,8 @@ type MemoryInfo struct {
|
||||
Total uint64 `json:"total"`
|
||||
}
|
||||
|
||||
const HostMemoryPath = `system/memory.json`
|
||||
|
||||
type CollectHostMemory struct {
|
||||
hostCollector *troubleshootv1beta2.Memory
|
||||
BundlePath string
|
||||
@@ -41,16 +42,10 @@ func (c *CollectHostMemory) Collect(progressChan chan<- interface{}) (map[string
|
||||
return nil, errors.Wrap(err, "failed to marshal memory info")
|
||||
}
|
||||
|
||||
collectorName := c.hostCollector.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "memory"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
output := NewResult()
|
||||
output.SaveResult(c.BundlePath, name, bytes.NewBuffer(b))
|
||||
output.SaveResult(c.BundlePath, HostMemoryPath, bytes.NewBuffer(b))
|
||||
|
||||
return map[string][]byte{
|
||||
name: b,
|
||||
HostMemoryPath: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package collect
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
|
||||
@@ -17,6 +16,8 @@ type HostOSInfo struct {
|
||||
Platform string `json:"platform"`
|
||||
}
|
||||
|
||||
const HostOSInfoPath = `system/hostos_info.json`
|
||||
|
||||
type CollectHostOS struct {
|
||||
hostCollector *troubleshootv1beta2.HostOS
|
||||
BundlePath string
|
||||
@@ -46,16 +47,10 @@ func (c *CollectHostOS) Collect(progressChan chan<- interface{}) (map[string][]b
|
||||
return nil, errors.Wrap(err, "failed to marshal host os info")
|
||||
}
|
||||
|
||||
collectorName := c.hostCollector.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "hostos_info"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
output := NewResult()
|
||||
output.SaveResult(c.BundlePath, name, bytes.NewBuffer(b))
|
||||
output.SaveResult(c.BundlePath, HostOSInfoPath, bytes.NewBuffer(b))
|
||||
|
||||
return map[string][]byte{
|
||||
name: b,
|
||||
HostOSInfoPath: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
|
||||
@@ -20,6 +19,7 @@ type ServiceInfo struct {
|
||||
}
|
||||
|
||||
const systemctlFormat = `%s %s %s %s` // this leaves off the description
|
||||
const HostServicesPath = `system/systemctl_services.json`
|
||||
|
||||
type CollectHostServices struct {
|
||||
hostCollector *troubleshootv1beta2.HostServices
|
||||
@@ -64,16 +64,10 @@ func (c *CollectHostServices) Collect(progressChan chan<- interface{}) (map[stri
|
||||
return nil, errors.Wrap(err, "failed to marshal systemctl service info")
|
||||
}
|
||||
|
||||
collectorName := c.hostCollector.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "systemctl_services"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
output := NewResult()
|
||||
output.SaveResult(c.BundlePath, name, bytes.NewBuffer(b))
|
||||
output.SaveResult(c.BundlePath, HostServicesPath, bytes.NewBuffer(b))
|
||||
|
||||
return map[string][]byte{
|
||||
name: b,
|
||||
HostServicesPath: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/godbus/dbus"
|
||||
@@ -21,6 +20,8 @@ type TimeInfo struct {
|
||||
NTPActive bool `json:"ntp_active"`
|
||||
}
|
||||
|
||||
const HostTimePath = `system/time.json`
|
||||
|
||||
type CollectHostTime struct {
|
||||
hostCollector *troubleshootv1beta2.HostTime
|
||||
BundlePath string
|
||||
@@ -93,16 +94,10 @@ func (c *CollectHostTime) Collect(progressChan chan<- interface{}) (map[string][
|
||||
return nil, errors.Wrap(err, "failed to marshal time info")
|
||||
}
|
||||
|
||||
collectorName := c.hostCollector.CollectorName
|
||||
if collectorName == "" {
|
||||
collectorName = "time"
|
||||
}
|
||||
name := filepath.Join("system", collectorName+".json")
|
||||
|
||||
output := NewResult()
|
||||
output.SaveResult(c.BundlePath, name, bytes.NewBuffer(b))
|
||||
output.SaveResult(c.BundlePath, HostTimePath, bytes.NewBuffer(b))
|
||||
|
||||
return map[string][]byte{
|
||||
name: b,
|
||||
HostTimePath: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user