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
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/NETWAYS/support-collector/modules/icingadb"
"github.com/NETWAYS/support-collector/modules/icingadirector"
"github.com/NETWAYS/support-collector/modules/icingaweb2"
"github.com/NETWAYS/support-collector/modules/keepalived"
"github.com/NETWAYS/support-collector/modules/influxdb"
"github.com/NETWAYS/support-collector/modules/mysql"
"github.com/NETWAYS/support-collector/modules/postgresql"
Expand Down Expand Up @@ -50,6 +51,7 @@ var modules = map[string]func(*collection.Collection){
"icinga2": icinga2.Collect,
"icingaweb2": icingaweb2.Collect,
"icinga-director": icingadirector.Collect,
"keepalived": keepalived.Collect,
"mysql": mysql.Collect,
"influxdb": influxdb.Collect,
"postgresql": postgresql.Collect,
Expand All @@ -67,6 +69,7 @@ var (
"icingaweb2",
"icinga-director",
"icingadb",
"keepalived",
"mysql",
"influxdb",
"postgresql",
Expand Down
56 changes: 56 additions & 0 deletions modules/keepalived/collector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package keepalived

import (
"github.com/NETWAYS/support-collector/pkg/collection"
"github.com/NETWAYS/support-collector/pkg/obfuscate"
"os"
)

const ModuleName = "keepalived"

var relevantPaths = []string{
"/etc/keepalived",
}

var files = []string{
"/etc/keepalived/keepalived.conf",
}

var commands = map[string][]string{
"version.txt": {"keepalived", "--version"},
}

var obfuscators = []*obfuscate.Obfuscator{
// auth_pass in keepalived.conf
obfuscate.NewFile(`(?i)(auth_pass) (.*)`, `conf`),
}

func Detect() bool {
for _, path := range relevantPaths {
_, err := os.Stat(path)
if err == nil {
return true
}
}

return false
}

func Collect(c *collection.Collection) {
if !Detect() {
c.Log.Info("Could not find keepalived")
return
}

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

c.RegisterObfuscators(obfuscators...)

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

for name, cmd := range commands {
c.AddCommandOutput(ModuleName+"/"+name, cmd[0], cmd[1:]...)
}
}
21 changes: 21 additions & 0 deletions modules/keepalived/collector_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package keepalived

import (
"bytes"
"github.com/NETWAYS/support-collector/pkg/collection"
"github.com/NETWAYS/support-collector/pkg/obfuscate"
"github.com/NETWAYS/support-collector/pkg/util"
"testing"
)

func TestCollect(t *testing.T) {
c := collection.New(&bytes.Buffer{})

Collect(c)
}

func TestObfuscators(t *testing.T) {
util.AssertObfuscationExample(t, obfuscators, obfuscate.KindFile, "/etc/keepalived/keepalived.conf")

util.AssertAllObfuscatorsTested(t, obfuscators)
}
14 changes: 14 additions & 0 deletions modules/keepalived/testdata/etc/keepalived/keepalived.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 255
advert_int 1
authentication {
auth_type PASS
auth_pass pwd123!
}
virtual_ipaddress {
192.168.122.200/24
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 255
advert_int 1
authentication {
auth_type PASS
<HIDDEN> <HIDDEN>
}
virtual_ipaddress {
192.168.122.200/24
}
}