Skip to content

Commit

Permalink
Use newest apputils (#13)
Browse files Browse the repository at this point in the history
paramite authored Nov 2, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5bea370 commit 7e7ce6e
Showing 7 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ env:
RABBITMQ_VERSION: 3.7.24
QDROUTERD_VERSION: 1.12.0
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
on: push
on: [push, pull_request]

jobs:
test-framework:
2 changes: 1 addition & 1 deletion ci/run_ci.sh
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ sleep 5

export COLLECTD_SENSUBILITY_CONFIG=$PWD/ci/mocks/sensu/collectd-sensubility.conf
touch sensubility-ci.log
collectd-sensubility --debug --log sensubility-ci.log &
collectd-sensubility --debug --log=sensubility-ci.log &

python3 ci/mocks/sensu/sensu_verify.py --timeout 120
EXIT_CODE=$?
2 changes: 1 addition & 1 deletion formats/sg.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (
"strings"
"time"

"github.com/infrawatch/apputils/connector"
connector "github.com/infrawatch/apputils/connector/sensu"
"github.com/infrawatch/collectd-sensubility/sensu"
)

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ require (
github.com/apache/qpid-proton v0.0.0-20210222174104-6353ad99c23d
github.com/creack/pty v1.1.11 // indirect
github.com/go-ini/ini v1.62.0
github.com/infrawatch/apputils v0.0.0-20210223194306-28412c8e501c
github.com/infrawatch/apputils v0.0.0-20210809211320-3573b2937d14 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/streadway/amqp v1.0.0
18 changes: 10 additions & 8 deletions main/main.go
Original file line number Diff line number Diff line change
@@ -8,14 +8,16 @@ import (
"os"

"github.com/infrawatch/apputils/config"
"github.com/infrawatch/apputils/connector"
"github.com/infrawatch/apputils/connector/amqp10"
connector "github.com/infrawatch/apputils/connector/sensu"
"github.com/infrawatch/apputils/logging"
"github.com/infrawatch/collectd-sensubility/formats"
"github.com/infrawatch/collectd-sensubility/sensu"
)

//Default values for various functions
const (
DefaultLogPath = "/var/log/collectd/sensubility.log"
DefaultConfigPath = "/etc/collectd-sensubility.conf"
DefaultHostname = "localhost.localdomain"
DefaultIP = "127.0.0.1"
@@ -50,7 +52,7 @@ func GetAgentConfigMetadata() map[string][]config.Parameter {
config.Parameter{
Name: "log_file",
Tag: "",
Default: "/var/log/collectd/sensubility.log",
Default: "",
Validators: []config.Validator{},
},
config.Parameter{
@@ -174,7 +176,7 @@ func main() {
debug := flag.Bool("debug", false, "enables debugging logs")
verbose := flag.Bool("verbose", false, "enables informational logs")
silent := flag.Bool("silent", false, "disables all logs except fatal errors")
logpath := flag.String("log", "/var/log/collectd/sensubility.log", "path to log file")
logpath := flag.String("log", DefaultLogPath, "path to log file")
flag.Parse()

// set logging
@@ -208,8 +210,8 @@ func main() {

// recreate logger according to values in config file
logFile, err := cfg.GetOption("default/log_file")
if err == nil && len(logFile.GetString()) > 0 {
log, err = logging.NewLogger(level, logFile)
if err == nil && logFile.GetString() != "" {
log, err = logging.NewLogger(level, logFile.GetString())
if err != nil {
fmt.Printf("Failed to open log file %s.\n", logFile)
os.Exit(2)
@@ -257,11 +259,11 @@ func main() {

reportAmqp := false
amqpAddr := "collectd/events"
amqpConnector := &connector.AMQP10Connector{}
amqpConnector := &amqp10.AMQP10Connector{}
if sect, ok := cfg.Sections["amqp1"]; ok {
if opt, ok := sect.Options["connection"]; ok {
if len(opt.GetString()) > 0 {
amqpConnector, err = connector.ConnectAMQP10(cfg, log)
amqpConnector, err = amqp10.ConnectAMQP10(cfg, log)
if err != nil {
log.Metadata(map[string]interface{}{"error": err, "connection": opt.GetString()})
log.Error("Failed to spawn AMQP1.0 connector.")
@@ -343,7 +345,7 @@ func main() {
log.Error("Failed to marshal check result.")
continue
}
msg := connector.AMQP10Message{
msg := amqp10.AMQP10Message{
Address: *amqpAddr,
Body: string(body),
}
2 changes: 1 addition & 1 deletion sensu/executor.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"time"

"github.com/infrawatch/apputils/config"
"github.com/infrawatch/apputils/connector"
connector "github.com/infrawatch/apputils/connector/sensu"
"github.com/infrawatch/apputils/logging"
)

2 changes: 1 addition & 1 deletion sensu/scheduler.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"time"

"github.com/infrawatch/apputils/config"
"github.com/infrawatch/apputils/connector"
connector "github.com/infrawatch/apputils/connector/sensu"
"github.com/infrawatch/apputils/logging"
)

0 comments on commit 7e7ce6e

Please sign in to comment.