Skip to content

Commit 1c32bfd

Browse files
committed
add some daemon infos
1 parent 692c507 commit 1c32bfd

File tree

8 files changed

+73
-9
lines changed

8 files changed

+73
-9
lines changed

modules/base/collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func Collect(c *collection.Collection) {
5555
}
5656

5757
// Add repository settings, at least one of the locations should be found
58-
c.AddFilesAtLeastOne(ModuleName, repositoryFiles...)
58+
c.AddFilesIfFound(ModuleName, repositoryFiles...)
5959

6060
for _, cmd := range commands {
6161
name := ModuleName + "/" + cmd[0] + ".txt"

modules/icinga2/collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func Collect(c *collection.Collection) {
7070
c.AddFiles(ModuleName, file)
7171
}
7272

73-
c.AddFilesAtLeastOne(ModuleName, pluginFiles...)
73+
c.AddFilesIfFound(ModuleName, pluginFiles...)
7474

7575
for _, file := range optionalFiles {
7676
if _, err := os.Stat(file); err != nil {

modules/icingadirector/collector.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ const (
1111
)
1212

1313
var commands = map[string][]string{
14-
"health.txt": {"icingacli", "director", "health"},
14+
"health.txt": {"icingacli", "director", "health"},
15+
"user-icingadirector.txt": {"id", "icingadirector"},
16+
}
17+
18+
var possibleDaemons = []string{
19+
"/usr/lib/systemd/system/icinga-director.service",
20+
"/etc/systemd/system/icinga-director.service",
21+
"/etc/systemd/system/icinga-director.service.d",
22+
}
23+
24+
var journalctlLogs = map[string]collection.JournalElement{
25+
"journalctl-director.txt": {Service: "icinga-director.service"},
1526
}
1627

1728
// Detect if Icinga Director is installed on the system.
@@ -38,6 +49,16 @@ func Collect(c *collection.Collection) {
3849
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
3950
}
4051

52+
for _, file := range possibleDaemons {
53+
c.AddFilesIfFound(ModuleName, file)
54+
}
55+
56+
for name, element := range journalctlLogs {
57+
if service, err := collection.FindServices(element.Service); err == nil && len(service) > 0 {
58+
c.AddCommandOutput(ModuleName+"/"+name, "journalctl", "-u", element.Service)
59+
}
60+
}
61+
4162
// Get GIT Repository details
4263
if path, ok := collection.IsGitRepository(InstallationPath); collection.DetectGitInstalled() && ok {
4364
c.AddGitRepoInfo(ModuleName+"/git-info.yml", path)

modules/icingaweb2/collector.go

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,34 @@ var files = []string{
2424
"/var/log/icingaweb2",
2525
}
2626

27+
var possibleDaemons = []string{
28+
"/usr/lib/systemd/system/icinga-vspheredb.service",
29+
"/etc/systemd/system/icinga-vspheredb.service",
30+
"/etc/systemd/system/icinga-vspheredb.service.d/",
31+
"/usr/lib/systemd/system/icinga-reporting.service",
32+
"/etc/systemd/system/icinga-reporting.service",
33+
"/etc/systemd/system/icinga-reporting.service.d",
34+
"/usr/lib/systemd/system/icinga-x509.service",
35+
"/etc/systemd/system/icinga-x509.service",
36+
"/etc/systemd/system/icinga-x509.service.d",
37+
}
38+
39+
var tmpFiles = []string{
40+
"/usr/lib/tmpfiles.d/icinga-vspheredb.conf",
41+
"/etc/tmpfiles.d/icinga-vspheredb.conf",
42+
}
43+
2744
var commands = map[string][]string{
28-
"version.txt": {"icingacli", "version"},
29-
"modules.txt": {"icingacli", "module", "list"},
45+
"version.txt": {"icingacli", "version"},
46+
"modules.txt": {"icingacli", "module", "list"},
47+
"vpsheredb-socket.txt": {"ls", "-la", "/run/icinga-vspheredb/"},
48+
"user-icingavspheredb.txt": {"id", "icingavspheredb"},
49+
}
50+
51+
var journalctlLogs = map[string]collection.JournalElement{
52+
"journalctl-vspheredb.txt": {Service: "icinga-vspheredb.service"},
53+
"journalctl-reporting.txt": {Service: "icinga-reporting.service"},
54+
"journalctl-x509.txt": {Service: "icinga-x509.service"},
3055
}
3156

3257
var obfuscators = []*obfuscate.Obfuscator{
@@ -72,6 +97,14 @@ func Collect(c *collection.Collection) {
7297
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
7398
}
7499

100+
for _, file := range possibleDaemons {
101+
c.AddFilesIfFound(ModuleName, file)
102+
}
103+
104+
for _, file := range tmpFiles {
105+
c.AddFilesIfFound(ModuleName, file)
106+
}
107+
75108
// Detect PHP related packages and services
76109
c.AddInstalledPackagesRaw(ModuleName+"/packages-php.txt", "*php*")
77110

@@ -81,6 +114,12 @@ func Collect(c *collection.Collection) {
81114
}
82115
}
83116

117+
for name, element := range journalctlLogs {
118+
if service, err := collection.FindServices(element.Service); err == nil && len(service) > 0 {
119+
c.AddCommandOutput(ModuleName+"/"+name, "journalctl", "-u", element.Service)
120+
}
121+
}
122+
84123
// Detect webserver packages
85124
c.AddInstalledPackagesRaw(ModuleName+"/packages-webserver.txt", "*apache*", "*httpd*")
86125
}

modules/mysql/collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ func Collect(c *collection.Collection) {
4646

4747
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*mysql*", "*mariadb*")
4848
c.AddServiceStatusRaw(ModuleName+"/service.txt", service)
49-
c.AddFilesAtLeastOne(ModuleName, possibleConfigPaths...)
49+
c.AddFilesIfFound(ModuleName, possibleConfigPaths...)
5050
}

modules/postgresql/collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func Collect(c *collection.Collection) {
4141
c.Log.Info("Collecting PostgreSQL information")
4242

4343
c.AddInstalledPackagesRaw(ModuleName+"/packages.txt", "*postgresql*", "*pgsql*")
44-
c.AddFilesAtLeastOne(ModuleName, files...)
44+
c.AddFilesIfFound(ModuleName, files...)
4545

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

pkg/collection/collection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (c *Collection) AddFiles(prefix, source string) {
148148
}
149149
}
150150

151-
func (c *Collection) AddFilesAtLeastOne(prefix string, sources ...string) {
151+
func (c *Collection) AddFilesIfFound(prefix string, sources ...string) {
152152
var foundFiles int
153153

154154
for _, source := range sources {
@@ -167,7 +167,7 @@ func (c *Collection) AddFilesAtLeastOne(prefix string, sources ...string) {
167167
}
168168

169169
if foundFiles == 0 {
170-
c.Log.Warnf("Found no files under: %s", strings.Join(sources, " "))
170+
c.Log.Debugf("Found no files under: %s", strings.Join(sources, " "))
171171
}
172172
}
173173

pkg/collection/services.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const (
1515

1616
const sysVInitD = "/etc/init.d"
1717

18+
type JournalElement struct {
19+
Service string
20+
}
21+
1822
// ErrNoServiceManager is returned when we could not detect one.
1923
var ErrNoServiceManager = errors.New("could not detect a supported service manager")
2024

0 commit comments

Comments
 (0)