Skip to content

Commit c2136fc

Browse files
Merge pull request #574 from replicatedhq/diamonwiggins/sc-46879/hostcollectors-supportbundles
Host Collectors in Support Bundles
2 parents 9ec9806 + 9898d3f commit c2136fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+293
-107
lines changed

pkg/analyze/host_block_devices.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (a *AnalyzeHostBlockDevices) IsExcluded() (bool, error) {
2727
func (a *AnalyzeHostBlockDevices) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
2828
hostAnalyzer := a.hostAnalyzer
2929

30-
contents, err := getCollectedFileContents("system/block_devices.json")
30+
contents, err := getCollectedFileContents(collect.HostBlockDevicesPath)
3131
if err != nil {
3232
return nil, errors.Wrap(err, "failed to get collected file")
3333
}

pkg/analyze/host_certificate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (a *AnalyzeHostCertificate) Analyze(getCollectedFileContents func(string) (
2626
if collectorName == "" {
2727
collectorName = "certificate"
2828
}
29-
name := filepath.Join("certificate", collectorName+".json")
29+
name := filepath.Join("host-collectors/certificate", collectorName+".json")
3030
contents, err := getCollectedFileContents(name)
3131
if err != nil {
3232
return nil, errors.Wrap(err, "failed to get collected file")

pkg/analyze/host_cpu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (a *AnalyzeHostCPU) IsExcluded() (bool, error) {
2525
func (a *AnalyzeHostCPU) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
2626
hostAnalyzer := a.hostAnalyzer
2727

28-
contents, err := getCollectedFileContents("system/cpu.json")
28+
contents, err := getCollectedFileContents(collect.HostCPUPath)
2929
if err != nil {
3030
return nil, errors.Wrap(err, "failed to get collected file")
3131
}

pkg/analyze/host_disk_usage.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package analyzer
33
import (
44
"encoding/json"
55
"fmt"
6+
"path/filepath"
67
"strconv"
78
"strings"
89

@@ -27,15 +28,18 @@ func (a *AnalyzeHostDiskUsage) IsExcluded() (bool, error) {
2728
func (a *AnalyzeHostDiskUsage) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
2829
hostAnalyzer := a.hostAnalyzer
2930

30-
key := collect.HostDiskUsageKey(hostAnalyzer.CollectorName)
31-
contents, err := getCollectedFileContents(key)
31+
name := filepath.Join("host-collectors/diskUsage", "diskUsage.json")
32+
if hostAnalyzer.CollectorName != "" {
33+
name = filepath.Join("host-collectors/diskUsage", hostAnalyzer.CollectorName+".json")
34+
}
35+
contents, err := getCollectedFileContents(name)
3236
if err != nil {
33-
return nil, errors.Wrapf(err, "failed to get collected file %s", key)
37+
return nil, errors.Wrapf(err, "failed to get collected file %s", name)
3438
}
3539

3640
diskUsageInfo := collect.DiskUsageInfo{}
3741
if err := json.Unmarshal(contents, &diskUsageInfo); err != nil {
38-
return nil, errors.Wrapf(err, "failed to unmarshal disk usage info from %s", key)
42+
return nil, errors.Wrapf(err, "failed to unmarshal disk usage info from %s", name)
3943
}
4044

4145
result := AnalyzeResult{

pkg/analyze/host_filesystem_performance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (a *AnalyzeHostFilesystemPerformance) Analyze(getCollectedFileContents func
3434
if collectorName == "" {
3535
collectorName = "filesystemPerformance"
3636
}
37-
name := filepath.Join("filesystemPerformance", collectorName+".json")
37+
name := filepath.Join("host-collectors/filesystemPerformance", collectorName+".json")
3838
contents, err := getCollectedFileContents(name)
3939
if err != nil {
4040
return nil, errors.Wrapf(err, "failed to get collected file %s", name)

pkg/analyze/host_http.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ func (a *AnalyzeHostHTTP) IsExcluded() (bool, error) {
3232
func (a *AnalyzeHostHTTP) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
3333
hostAnalyzer := a.hostAnalyzer
3434

35-
name := filepath.Join("http", "result.json")
35+
name := filepath.Join("host-collectors/http", "result.json")
3636
if hostAnalyzer.CollectorName != "" {
37-
name = filepath.Join("http", hostAnalyzer.CollectorName+".json")
37+
name = filepath.Join("host-collectors/http", hostAnalyzer.CollectorName+".json")
3838
}
3939
contents, err := getCollectedFileContents(name)
4040
if err != nil {

pkg/analyze/host_httploadbalancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (a *AnalyzeHostHTTPLoadBalancer) Analyze(getCollectedFileContents func(stri
2929
if collectorName == "" {
3030
collectorName = "httpLoadBalancer"
3131
}
32-
fullPath := path.Join("httpLoadBalancer", fmt.Sprintf("%s.json", collectorName))
32+
fullPath := path.Join("host-collectors/httpLoadBalancer", fmt.Sprintf("%s.json", collectorName))
3333

3434
collected, err := getCollectedFileContents(fullPath)
3535
if err != nil {

pkg/analyze/host_ipv4interfaces.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/pkg/errors"
1111
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
12+
"github.com/replicatedhq/troubleshoot/pkg/collect"
1213
)
1314

1415
type AnalyzeHostIPV4Interfaces struct {
@@ -26,7 +27,7 @@ func (a *AnalyzeHostIPV4Interfaces) IsExcluded() (bool, error) {
2627
func (a *AnalyzeHostIPV4Interfaces) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
2728
hostAnalyzer := a.hostAnalyzer
2829

29-
contents, err := getCollectedFileContents("system/ipv4Interfaces.json")
30+
contents, err := getCollectedFileContents(collect.HostIPV4InterfacesPath)
3031
if err != nil {
3132
return nil, errors.Wrap(err, "failed to get collected file")
3233
}

pkg/analyze/host_kernel_modules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (a *AnalyzeHostKernelModules) IsExcluded() (bool, error) {
4343
//
4444
func (a *AnalyzeHostKernelModules) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
4545
hostAnalyzer := a.hostAnalyzer
46-
contents, err := getCollectedFileContents("system/kernel_modules.json")
46+
contents, err := getCollectedFileContents(collect.HostKernelModulesPath)
4747
if err != nil {
4848
return nil, errors.Wrap(err, "failed to get collected file")
4949
}

pkg/analyze/host_memory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (a *AnalyzeHostMemory) IsExcluded() (bool, error) {
2626
func (a *AnalyzeHostMemory) Analyze(getCollectedFileContents func(string) ([]byte, error)) ([]*AnalyzeResult, error) {
2727
hostAnalyzer := a.hostAnalyzer
2828

29-
contents, err := getCollectedFileContents("system/memory.json")
29+
contents, err := getCollectedFileContents(collect.HostMemoryPath)
3030
if err != nil {
3131
return nil, errors.Wrap(err, "failed to get collected file")
3232
}

0 commit comments

Comments
 (0)