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 @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/NETWAYS/support-collector/modules/ansible"
"github.com/NETWAYS/support-collector/modules/base"
"github.com/NETWAYS/support-collector/modules/corosync"
"github.com/NETWAYS/support-collector/modules/grafana"
"github.com/NETWAYS/support-collector/modules/graphite"
"github.com/NETWAYS/support-collector/modules/icinga2"
Expand Down Expand Up @@ -51,6 +52,7 @@ var modules = map[string]func(*collection.Collection){
"icinga2": icinga2.Collect,
"icingaweb2": icingaweb2.Collect,
"icinga-director": icingadirector.Collect,
"corosync": corosync.Collect,
"keepalived": keepalived.Collect,
"mysql": mysql.Collect,
"influxdb": influxdb.Collect,
Expand All @@ -69,6 +71,7 @@ var (
"icingaweb2",
"icinga-director",
"icingadb",
"corosync",
"keepalived",
"mysql",
"influxdb",
Expand Down
58 changes: 58 additions & 0 deletions modules/corosync/collector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package corosync

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

const ModuleName = "corosync"

var relevantPaths = []string{
"/etc/corosync/service.d",
}

var possibleDaemons = []string{
"/lib/systemd/system/corosync.service",
"/usr/lib/systemd/system/corosync.service",
}

var files = []string{
"/etc/corosync/corosync.conf",
"/var/lib/pacemaker/cib/cib.xml",
}

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

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 corosync")
return
}

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

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

for _, file := range possibleDaemons {
c.AddFilesIfFound(ModuleName, file)
}

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

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

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

Collect(c)
}
31 changes: 31 additions & 0 deletions modules/corosync/testdata/etc/corosync/corosync.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
totem {
version: 2
cluster_name: lbcluster
transport: udpu
interface {
ringnumber: 0
bindnetaddr: 127.0.0.1
broadcast: yes
mcastport: 5405
}
}

quorum {
provider: corosync_votequorum
two_node: 1
}

nodelist {
node {
ring0_addr: 127.0.0.1
name: primary
nodeid: 1
}
}

logging {
to_logfile: yes
logfile: /var/log/corosync/corosync.log
to_syslog: yes
timestamp: on
}
4 changes: 4 additions & 0 deletions modules/corosync/testdata/etc/corosync/service.d/pcmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
service {
name: pacemaker
ver: 1
}
21 changes: 21 additions & 0 deletions modules/corosync/testdata/var/lib/pacemaker/cib/cib.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<cib crm_feature_set="3.0.9" validate-with="pacemaker-2.3" have-quorum="1" dc-uuid="4">
<configuration>
<crm_config>
<cluster_property_set id="cib-bootstrap-options">
<nvpair id="cib-bootstrap-options-have-watchdog" name="have-watchdog" value="false"/>
<nvpair id="cib-bootstrap-options-no-quorum-policy" name="no-quorum-policy" value="freeze"/>
</cluster_property_set>
</crm_config>
<nodes>
<node id="1" uname="foo"/>
</nodes>
<resources>
<clone id="dlm-clone">
</clone>
</resources>
<constraints>
<rsc_order first="dlm-clone" first-action="start" id="order-dlm-clone-clvmd-clone-mandatory" then="clvmd-clone" then-action="start"/>
<rsc_colocation id="colocation-clvmd-clone-dlm-clone-INFINITY" rsc="clvmd-clone" score="INFINITY" with-rsc="dlm-clone"/>
</constraints>
</configuration>
</cib>