summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/icingadb-migrate/convert.go33
-rw-r--r--cmd/icingadb-migrate/misc.go3
-rw-r--r--cmd/icingadb/main.go17
3 files changed, 17 insertions, 36 deletions
diff --git a/cmd/icingadb-migrate/convert.go b/cmd/icingadb-migrate/convert.go
index e14746e..5cfa7bd 100644
--- a/cmd/icingadb-migrate/convert.go
+++ b/cmd/icingadb-migrate/convert.go
@@ -150,19 +150,9 @@ func convertCommentRows(
},
AckHistoryUpserter: history.AckHistoryUpserter{ClearTime: clearTime},
SetTime: setTime,
- Author: icingadbTypes.String{
- NullString: sql.NullString{
- String: row.AuthorName,
- Valid: true,
- },
- },
- Comment: icingadbTypes.String{
- NullString: sql.NullString{
- String: row.CommentData,
- Valid: true,
- },
- },
- ExpireTime: convertTime(row.ExpirationTime, 0),
+ Author: icingadbTypes.MakeString(row.AuthorName),
+ Comment: icingadbTypes.MakeString(row.CommentData),
+ ExpireTime: convertTime(row.ExpirationTime, 0),
IsPersistent: icingadbTypes.Bool{
Bool: row.IsPersistent != 0,
Valid: true,
@@ -656,13 +646,8 @@ func convertNotificationRows(
SendTime: ts,
State: row.State,
PreviousHardState: previousHardState,
- Text: icingadbTypes.String{
- NullString: sql.NullString{
- String: text,
- Valid: true,
- },
- },
- UsersNotified: row.ContactsNotified,
+ Text: icingadbTypes.MakeString(text),
+ UsersNotified: row.ContactsNotified,
})
allHistory = append(allHistory, &history.HistoryNotification{
@@ -739,8 +724,8 @@ type stateRow = struct {
StateTimeUsec uint32
State uint8
StateType uint8
- CurrentCheckAttempt uint16
- MaxCheckAttempts uint16
+ CurrentCheckAttempt uint32
+ MaxCheckAttempts uint32
LastState uint8
LastHardState uint8
Output sql.NullString
@@ -813,10 +798,10 @@ func convertStateRows(
HardState: row.LastHardState,
PreviousSoftState: row.LastState,
PreviousHardState: previousHardState,
- CheckAttempt: uint8(row.CurrentCheckAttempt),
+ CheckAttempt: row.CurrentCheckAttempt,
Output: icingadbTypes.String{NullString: row.Output},
LongOutput: icingadbTypes.String{NullString: row.LongOutput},
- MaxCheckAttempts: uint32(row.MaxCheckAttempts),
+ MaxCheckAttempts: row.MaxCheckAttempts,
CheckSource: icingadbTypes.String{NullString: row.CheckSource},
})
diff --git a/cmd/icingadb-migrate/misc.go b/cmd/icingadb-migrate/misc.go
index f1db20c..b8d358f 100644
--- a/cmd/icingadb-migrate/misc.go
+++ b/cmd/icingadb-migrate/misc.go
@@ -4,7 +4,6 @@ import (
"context"
"crypto/sha1"
"github.com/icinga/icingadb/pkg/contracts"
- "github.com/icinga/icingadb/pkg/driver"
"github.com/icinga/icingadb/pkg/icingadb"
"github.com/icinga/icingadb/pkg/icingadb/objectpacker"
icingadbTypes "github.com/icinga/icingadb/pkg/types"
@@ -110,7 +109,7 @@ func sliceIdoHistory[Row any](
args["checkpoint"] = checkpoint
args["bulk"] = 20000
- if ht.snapshot.DriverName() != driver.MySQL {
+ if ht.snapshot.DriverName() != icingadb.MySQL {
query = strings.ReplaceAll(query, " USE INDEX (PRIMARY)", "")
}
diff --git a/cmd/icingadb/main.go b/cmd/icingadb/main.go
index 77ce577..4e165eb 100644
--- a/cmd/icingadb/main.go
+++ b/cmd/icingadb/main.go
@@ -3,7 +3,7 @@ package main
import (
"context"
"fmt"
- "github.com/go-redis/redis/v8"
+ "github.com/icinga/icingadb/internal"
"github.com/icinga/icingadb/internal/command"
"github.com/icinga/icingadb/pkg/common"
"github.com/icinga/icingadb/pkg/icingadb"
@@ -16,6 +16,7 @@ import (
"github.com/icinga/icingadb/pkg/utils"
"github.com/okzk/sdnotify"
"github.com/pkg/errors"
+ "github.com/redis/go-redis/v9"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"os"
@@ -55,11 +56,7 @@ func run() int {
logger := logs.GetLogger()
defer logger.Sync()
- if warn := cmd.Config.DecodeWarning; warn != nil {
- logger.Warnf("ignoring unknown config option, this will become a fatal error in Icinga DB v1.2:\n\n%v", warn)
- }
-
- logger.Info("Starting Icinga DB")
+ logger.Infof("Starting Icinga DB daemon (%s)", internal.Version.Version)
db, err := cmd.Database(logs.GetChildLogger("database"))
if err != nil {
@@ -165,8 +162,8 @@ func run() int {
hactx, cancelHactx := context.WithCancel(ctx)
for hactx.Err() == nil {
select {
- case <-ha.Takeover():
- logger.Info("Taking over")
+ case takeoverReason := <-ha.Takeover():
+ logger.Infow("Taking over", zap.String("reason", takeoverReason))
go func() {
for hactx.Err() == nil {
@@ -327,8 +324,8 @@ func run() int {
}
}
}()
- case <-ha.Handover():
- logger.Warn("Handing over")
+ case handoverReason := <-ha.Handover():
+ logger.Warnw("Handing over", zap.String("reason", handoverReason))
cancelHactx()
case <-hactx.Done():