Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions modules/ansible/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ansible
import (
"github.com/NETWAYS/support-collector/pkg/collection"
"os"
"path/filepath"
)

const ModuleName = "ansible"
Expand Down Expand Up @@ -44,10 +45,10 @@ func Collect(c *collection.Collection) {
}

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

c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*ansible*")
c.AddInstalledPackagesRaw(ModuleName+"/packages-python.txt", "*python*")
c.AddInstalledPackagesRaw(ModuleName+"/packages-pip.txt", "*pip*")
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*ansible*")
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-python.txt"), "*python*")
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-pip.txt"), "*pip*")
}
10 changes: 5 additions & 5 deletions modules/base/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/NETWAYS/support-collector/pkg/collection"
"gopkg.in/yaml.v3"
"os/exec"
"path/filepath"
)

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

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

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

for _, cmd := range commands {
name := ModuleName + "/" + cmd[0] + ".txt"
c.AddCommandOutput(name, cmd[0], cmd[1:]...)
c.AddCommandOutput(filepath.Join(ModuleName, cmd[0]+".txt"), cmd[0], cmd[1:]...)
}
}

Expand All @@ -81,7 +81,7 @@ func CollectKernelInfo(c *collection.Collection) {
return
}

err = c.AddFileFromReaderRaw(ModuleName+"/kernel.yml", &buf)
err = c.AddFileFromReaderRaw(filepath.Join(ModuleName, "kernel.yml"), &buf)
if err != nil {
c.Log.Error(err)
}
Expand Down
5 changes: 3 additions & 2 deletions modules/corosync/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package corosync
import (
"github.com/NETWAYS/support-collector/pkg/collection"
"os"
"path/filepath"
)

const ModuleName = "corosync"
Expand Down Expand Up @@ -61,10 +62,10 @@ func Collect(c *collection.Collection) {
}

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

for name, cmd := range commands {
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
}
}
7 changes: 4 additions & 3 deletions modules/grafana/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/NETWAYS/support-collector/pkg/collection"
"github.com/NETWAYS/support-collector/pkg/obfuscate"
"os"
"path/filepath"
)

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

c.RegisterObfuscators(obfuscators...)

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

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

for name, cmd := range commands {
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
}
}
11 changes: 6 additions & 5 deletions modules/graphite/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/NETWAYS/support-collector/pkg/obfuscate"
"github.com/NETWAYS/support-collector/pkg/util"
"os"
"path/filepath"
)

const ModuleName = "graphite"
Expand Down Expand Up @@ -79,10 +80,10 @@ func Collect(c *collection.Collection) {
}

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

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

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

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

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

c.AddInstalledPackagesRaw(ModuleName+"/packages-graphite.txt", "*graphite*", "*carbon*")
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages-graphite.txt"), "*graphite*", "*carbon*")
}
9 changes: 5 additions & 4 deletions modules/icinga2/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/NETWAYS/support-collector/pkg/obfuscate"
"os"
"os/exec"
"path/filepath"
)

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

c.RegisterObfuscators(obfuscators...)

c.AddInstalledPackagesRaw(ModuleName+"/packages.txt",
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"),
"*icinga2*",
"netways-plugin*",
"monitoring-plugin*",
"nagios-*")

c.AddServiceStatusRaw(ModuleName+"/service.txt", "icinga2")
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service.txt"), "icinga2")

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

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

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

for _, file := range possibleDaemons {
Expand Down
7 changes: 4 additions & 3 deletions modules/icingadb/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/NETWAYS/support-collector/pkg/collection"
"github.com/NETWAYS/support-collector/pkg/obfuscate"
"os"
"path/filepath"
)

const (
Expand Down Expand Up @@ -62,7 +63,7 @@ func Collect(c *collection.Collection) {

c.RegisterObfuscators(obfuscators...)

c.AddInstalledPackagesRaw(ModuleName+"/packages.txt",
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"),
"*icingadb*",
"icingadb-redis",
)
Expand All @@ -80,12 +81,12 @@ func Collect(c *collection.Collection) {
}

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

for name, element := range journalctlLogs {
if service, err := collection.FindServices(element.Service); err == nil && len(service) > 0 {
c.AddCommandOutput(ModuleName+"/"+name, "journalctl", "-u", element.Service, "--since", "7 days ago")
c.AddCommandOutput(filepath.Join(ModuleName, name), "journalctl", "-u", element.Service, "--since", "7 days ago")
}
}
}
11 changes: 6 additions & 5 deletions modules/icingadirector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package icingadirector
import (
"github.com/NETWAYS/support-collector/pkg/collection"
"os"
"path/filepath"
)

const (
Expand Down Expand Up @@ -40,13 +41,13 @@ func Collect(c *collection.Collection) {

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

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

// TODO: more infos on modules, GIT details

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

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

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

// Get GIT Repository details
if path, ok := collection.IsGitRepository(InstallationPath); collection.DetectGitInstalled() && ok {
c.AddGitRepoInfo(ModuleName+"/git-info.yml", path)
c.AddGitRepoInfo(filepath.Join(ModuleName, "git-info.yml"), path)
}
}
12 changes: 6 additions & 6 deletions modules/icingaweb2/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ func Collect(c *collection.Collection) {

c.RegisterObfuscators(obfuscators...)

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

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

CollectModuleInfo(c)
Expand All @@ -105,24 +105,24 @@ func Collect(c *collection.Collection) {
}

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

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

timestamp := "7 days ago"

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

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

func CollectModuleInfo(c *collection.Collection) {
Expand Down
5 changes: 3 additions & 2 deletions modules/influxdb/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package influxdb
import (
"github.com/NETWAYS/support-collector/pkg/collection"
"os"
"path/filepath"
)

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

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

c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*influx*")
c.AddServiceStatusRaw(ModuleName+"/service.txt", "influxdb")
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*influx*")
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service.txt"), "influxdb")

for _, file := range files {
c.AddFiles(ModuleName, file)
Expand Down
5 changes: 3 additions & 2 deletions modules/keepalived/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/NETWAYS/support-collector/pkg/collection"
"github.com/NETWAYS/support-collector/pkg/obfuscate"
"os"
"path/filepath"
)

const ModuleName = "keepalived"
Expand Down Expand Up @@ -63,10 +64,10 @@ func Collect(c *collection.Collection) {
}

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

for name, cmd := range commands {
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
}
}
7 changes: 4 additions & 3 deletions modules/mysql/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mysql
import (
"github.com/NETWAYS/support-collector/pkg/collection"
"os"
"path/filepath"
)

const (
Expand Down Expand Up @@ -54,12 +55,12 @@ func Collect(c *collection.Collection) {

c.Log.Info("Collecting MySQL/MariaDB information")

c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*mysql*", "*mariadb*")
c.AddServiceStatusRaw(ModuleName+"/service.txt", service)
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*mysql*", "*mariadb*")
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service.txt"), service)
c.AddFilesIfFound(ModuleName, possibleConfigPaths...)

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

for _, file := range optionalFiles {
Expand Down
7 changes: 4 additions & 3 deletions modules/postgresql/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package postgresql
import (
"github.com/NETWAYS/support-collector/pkg/collection"
"os"
"path/filepath"
)

const ModuleName = "postgresql"
Expand Down Expand Up @@ -44,14 +45,14 @@ func Collect(c *collection.Collection) {

c.Log.Info("Collecting PostgreSQL information")

c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*postgresql*", "*pgsql*")
c.AddInstalledPackagesRaw(filepath.Join(ModuleName, "packages.txt"), "*postgresql*", "*pgsql*")
c.AddFilesIfFound(ModuleName, files...)

for _, service := range possibleServices {
c.AddServiceStatusRaw(ModuleName+"/service-"+service+".txt", service)
c.AddServiceStatusRaw(filepath.Join(ModuleName, "service-"+service+".txt"), service)
}

for name, cmd := range commands {
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
c.AddCommandOutput(filepath.Join(ModuleName, name), cmd[0], cmd[1:]...)
}
}
Loading