Skip to content

Commit d6189a4

Browse files
authored
adjust file paths (#66)
1 parent d19f892 commit d6189a4

File tree

14 files changed

+62
-50
lines changed

14 files changed

+62
-50
lines changed

modules/ansible/collector.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ansible
33
import (
44
"github.com/NETWAYS/support-collector/pkg/collection"
55
"os"
6+
"path/filepath"
67
)
78

89
const ModuleName = "ansible"
@@ -44,10 +45,10 @@ func Collect(c *collection.Collection) {
4445
}
4546

4647
for name, cmd := range commands {
47-
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
48+
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
4849
}
4950

50-
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*ansible*")
51-
c.AddInstalledPackagesRaw(ModuleName+"/packages-python.txt", "*python*")
52-
c.AddInstalledPackagesRaw(ModuleName+"/packages-pip.txt", "*pip*")
51+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*ansible*")
52+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-python.txt"), "*python*")
53+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-pip.txt"), "*pip*")
5354
}

modules/base/collector.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/NETWAYS/support-collector/pkg/collection"
66
"gopkg.in/yaml.v3"
77
"os/exec"
8+
"path/filepath"
89
)
910

1011
const ModuleName = "base"
@@ -41,13 +42,13 @@ func Collect(c *collection.Collection) {
4142

4243
// Check if apparmor is installed and get status
4344
if _, err := exec.LookPath("apparmor_status"); err == nil {
44-
c.AddCommandOutput(ModuleName+"/apparmor-status.txt", "apparmor_status")
45+
c.AddCommandOutput(filepath.Join(ModuleName, "apparmor-status.txt"), "apparmor_status")
4546
}
4647

4748
// Check if we can detect SELinux enforcing
4849
for _, cmd := range []string{"sestatus", "getenforce"} {
4950
if _, err := exec.LookPath(cmd); err == nil {
50-
c.AddCommandOutput(ModuleName+"/selinux-status.txt", cmd)
51+
c.AddCommandOutput(filepath.Join(ModuleName, "selinux-status.txt"), cmd)
5152
break
5253
}
5354
}
@@ -60,8 +61,7 @@ func Collect(c *collection.Collection) {
6061
c.AddFilesIfFound(ModuleName, repositoryFiles...)
6162

6263
for _, cmd := range commands {
63-
name := ModuleName + "/" + cmd[0] + ".txt"
64-
c.AddCommandOutput(name, cmd[0], cmd[1:]...)
64+
c.AddCommandOutput(filepath.Join(ModuleName, cmd[0]+".txt"), cmd[0], cmd[1:]...)
6565
}
6666
}
6767

@@ -81,7 +81,7 @@ func CollectKernelInfo(c *collection.Collection) {
8181
return
8282
}
8383

84-
err = c.AddFileFromReaderRaw(ModuleName+"/kernel.yml", &buf)
84+
err = c.AddFileFromReaderRaw(filepath.Join(ModuleName, "kernel.yml"), &buf)
8585
if err != nil {
8686
c.Log.Error(err)
8787
}

modules/corosync/collector.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package corosync
33
import (
44
"github.com/NETWAYS/support-collector/pkg/collection"
55
"os"
6+
"path/filepath"
67
)
78

89
const ModuleName = "corosync"
@@ -61,10 +62,10 @@ func Collect(c *collection.Collection) {
6162
}
6263

6364
for _, service := range services {
64-
c.AddServiceStatusRaw(ModuleName+"/service-"+service+".txt", service)
65+
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service-"+service+".txt"), service)
6566
}
6667

6768
for name, cmd := range commands {
68-
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
69+
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
6970
}
7071
}

modules/grafana/collector.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/NETWAYS/support-collector/pkg/collection"
55
"github.com/NETWAYS/support-collector/pkg/obfuscate"
66
"os"
7+
"path/filepath"
78
)
89

910
const ModuleName = "grafana"
@@ -50,14 +51,14 @@ func Collect(c *collection.Collection) {
5051

5152
c.RegisterObfuscators(obfuscators...)
5253

53-
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*grafana*", "*chrome*", "*chromium*")
54-
c.AddServiceStatusRaw(ModuleName+"/service.txt", "grafana-server")
54+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*grafana*", "*chrome*", "*chromium*")
55+
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service.txt"), "grafana-server")
5556

5657
for _, file := range files {
5758
c.AddFiles(ModuleName, file)
5859
}
5960

6061
for name, cmd := range commands {
61-
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
62+
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
6263
}
6364
}

modules/graphite/collector.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/NETWAYS/support-collector/pkg/obfuscate"
66
"github.com/NETWAYS/support-collector/pkg/util"
77
"os"
8+
"path/filepath"
89
)
910

1011
const ModuleName = "graphite"
@@ -79,10 +80,10 @@ func Collect(c *collection.Collection) {
7980
}
8081

8182
for name, cmd := range commandsPython {
82-
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
83+
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
8384
}
8485

85-
c.AddInstalledPackagesRaw(ModuleName+"/packages-python"+suffix+".txt", "*python"+suffix+"*")
86+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-python"+suffix+".txt"), "*python"+suffix+"*")
8687
}
8788

8889
if !pythonFound {
@@ -109,11 +110,11 @@ func Collect(c *collection.Collection) {
109110

110111
for name, element := range journalctlLogs {
111112
if service, err := collection.FindServices(element.Service); err == nil && len(service) > 0 {
112-
c.AddCommandOutput(ModuleName+"/"+name, "journalctl", "-u", element.Service, "--since", timestamp)
113+
c.AddCommandOutput(filepath.Join(ModuleName, name), "journalctl", "-u", element.Service, "--since", timestamp)
113114
}
114115
}
115116

116-
c.AddFileDataRaw(ModuleName+"/processlist.txt", []byte(processes))
117+
c.AddFileDataRaw(filepath.Join(ModuleName, "processlist.txt"), []byte(processes))
117118

118-
c.AddInstalledPackagesRaw(ModuleName+"/packages-graphite.txt", "*graphite*", "*carbon*")
119+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-graphite.txt"), "*graphite*", "*carbon*")
119120
}

modules/icinga2/collector.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/NETWAYS/support-collector/pkg/obfuscate"
66
"os"
77
"os/exec"
8+
"path/filepath"
89
)
910

1011
const ModuleName = "icinga2"
@@ -63,16 +64,16 @@ func Collect(c *collection.Collection) {
6364

6465
c.RegisterObfuscators(obfuscators...)
6566

66-
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt",
67+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"),
6768
"*icinga2*",
6869
"netways-plugin*",
6970
"monitoring-plugin*",
7071
"nagios-*")
7172

72-
c.AddServiceStatusRaw(ModuleName+"/service.txt", "icinga2")
73+
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service.txt"), "icinga2")
7374

7475
if collection.DetectServiceManager() == "systemd" {
75-
c.AddCommandOutput(ModuleName+"/systemd-icinga2.service", "systemctl", "cat", "icinga2.service")
76+
c.AddCommandOutput(filepath.Join(ModuleName, "systemd-icinga2.service"), "systemctl", "cat", "icinga2.service")
7677
}
7778

7879
for _, file := range files {
@@ -90,7 +91,7 @@ func Collect(c *collection.Collection) {
9091
}
9192

9293
for name, cmd := range commands {
93-
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
94+
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
9495
}
9596

9697
for _, file := range possibleDaemons {

modules/icingadb/collector.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/NETWAYS/support-collector/pkg/collection"
55
"github.com/NETWAYS/support-collector/pkg/obfuscate"
66
"os"
7+
"path/filepath"
78
)
89

910
const (
@@ -62,7 +63,7 @@ func Collect(c *collection.Collection) {
6263

6364
c.RegisterObfuscators(obfuscators...)
6465

65-
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt",
66+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"),
6667
"*icingadb*",
6768
"icingadb-redis",
6869
)
@@ -80,12 +81,12 @@ func Collect(c *collection.Collection) {
8081
}
8182

8283
for _, service := range services {
83-
c.AddServiceStatusRaw(ModuleName+"/service-"+service+".txt", service)
84+
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service-"+service+".txt"), service)
8485
}
8586

8687
for name, element := range journalctlLogs {
8788
if service, err := collection.FindServices(element.Service); err == nil && len(service) > 0 {
88-
c.AddCommandOutput(ModuleName+"/"+name, "journalctl", "-u", element.Service, "--since", "7 days ago")
89+
c.AddCommandOutput(filepath.Join(ModuleName, name), "journalctl", "-u", element.Service, "--since", "7 days ago")
8990
}
9091
}
9192
}

modules/icingadirector/collector.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package icingadirector
33
import (
44
"github.com/NETWAYS/support-collector/pkg/collection"
55
"os"
6+
"path/filepath"
67
)
78

89
const (
@@ -40,13 +41,13 @@ func Collect(c *collection.Collection) {
4041

4142
c.Log.Info("Collecting Icinga Director information")
4243

43-
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*icinga*director*")
44-
c.AddServiceStatusRaw(ModuleName+"/service.txt", "icinga-director")
44+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*icinga*director*")
45+
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service.txt"), "icinga-director")
4546

4647
// TODO: more infos on modules, GIT details
4748

4849
for name, cmd := range commands {
49-
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
50+
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
5051
}
5152

5253
for _, file := range possibleDaemons {
@@ -55,12 +56,12 @@ func Collect(c *collection.Collection) {
5556

5657
for name, element := range journalctlLogs {
5758
if service, err := collection.FindServices(element.Service); err == nil && len(service) > 0 {
58-
c.AddCommandOutput(ModuleName+"/"+name, "journalctl", "-u", element.Service, "--since \"7 days ago\"")
59+
c.AddCommandOutput(filepath.Join(ModuleName, name), "journalctl", "-u", element.Service, "--since \"7 days ago\"")
5960
}
6061
}
6162

6263
// Get GIT Repository details
6364
if path, ok := collection.IsGitRepository(InstallationPath); collection.DetectGitInstalled() && ok {
64-
c.AddGitRepoInfo(ModuleName+"/git-info.yml", path)
65+
c.AddGitRepoInfo(filepath.Join(ModuleName, "git-info.yml"), path)
6566
}
6667
}

modules/icingaweb2/collector.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ func Collect(c *collection.Collection) {
8080

8181
c.RegisterObfuscators(obfuscators...)
8282

83-
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*icingaweb2*", "*icingacli*")
83+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*icingaweb2*", "*icingacli*")
8484

8585
if _, ok := collection.IsGitRepository("/usr/share/icingaweb2"); ok {
86-
c.AddGitRepoInfo(ModuleName+"/git.yml", "/usr/share/icingaweb2")
86+
c.AddGitRepoInfo(filepath.Join(ModuleName, "git.yml"), "/usr/share/icingaweb2")
8787
}
8888

8989
CollectModuleInfo(c)
@@ -105,24 +105,24 @@ func Collect(c *collection.Collection) {
105105
}
106106

107107
// Detect PHP related packages and services
108-
c.AddInstalledPackagesRaw(ModuleName+"/packages-php.txt", "*php*")
108+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-php.txt"), "*php*")
109109

110110
if services, err := collection.FindServices("*php*-fpm"); err == nil && len(services) > 0 {
111111
for _, name := range services {
112-
c.AddServiceStatusRaw(ModuleName+"/service-"+name+".txt", name)
112+
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service-"+name+".txt"), name)
113113
}
114114
}
115115

116116
timestamp := "7 days ago"
117117

118118
for name, element := range journalctlLogs {
119119
if service, err := collection.FindServices(element.Service); err == nil && len(service) > 0 {
120-
c.AddCommandOutput(ModuleName+"/"+name, "journalctl", "-u", element.Service, "--since", timestamp)
120+
c.AddCommandOutput(filepath.Join(ModuleName, name), "journalctl", "-u", element.Service, "--since", timestamp)
121121
}
122122
}
123123

124124
// Detect webserver packages
125-
c.AddInstalledPackagesRaw(ModuleName+"/packages-webserver.txt", "*apache*", "*httpd*")
125+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-webserver.txt"), "*apache*", "*httpd*")
126126
}
127127

128128
func CollectModuleInfo(c *collection.Collection) {

modules/influxdb/collector.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package influxdb
33
import (
44
"github.com/NETWAYS/support-collector/pkg/collection"
55
"os"
6+
"path/filepath"
67
)
78

89
const ModuleName = "influxdb"
@@ -35,8 +36,8 @@ func Collect(c *collection.Collection) {
3536

3637
c.Log.Info("Collecting InfluxDB information")
3738

38-
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*influx*")
39-
c.AddServiceStatusRaw(ModuleName+"/service.txt", "influxdb")
39+
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*influx*")
40+
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service.txt"), "influxdb")
4041

4142
for _, file := range files {
4243
c.AddFiles(ModuleName, file)

0 commit comments

Comments
 (0)