From 9eff41359aaef7ea537fac4d9dd796970ecadec7 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Thu, 10 Oct 2019 10:12:20 +0200 Subject: [PATCH] Fix runtime updates --- configobject/configsync/configsync.go | 12 ++++++------ configobject/objecttypes/actionurl/actionurl.go | 2 +- .../objecttypes/checkcommand/checkcommand.go | 2 +- .../checkcommandargument/checkcommandargument.go | 2 +- .../checkcommandcustomvar/checkcommandcustomvar.go | 2 +- .../checkcommandenvvar/checkcommandenvvar.go | 2 +- configobject/objecttypes/customvar/customvar.go | 2 +- .../customvar/customvarflat/customvarflat.go | 2 +- configobject/objecttypes/endpoint/endpoint.go | 2 +- .../objecttypes/eventcommand/eventcommand.go | 2 +- .../eventcommandargument/eventcommandargument.go | 2 +- .../eventcommandcustomvar/eventcommandcustomvar.go | 2 +- .../eventcommandenvvar/eventcommandenvvar.go | 2 +- configobject/objecttypes/host/host.go | 2 +- .../objecttypes/host/hostcomment/hostcomment.go | 2 +- .../objecttypes/host/hostcustomvar/hostcustomvar.go | 2 +- .../objecttypes/host/hostdowntime/hostdowntime.go | 2 +- configobject/objecttypes/host/hoststate/hoststate.go | 2 +- configobject/objecttypes/hostgroup/hostgroup.go | 2 +- .../hostgroupcustomvar/hostgroupcustomvar.go | 2 +- .../hostgroup/hostgroupmember/hostgroupmember.go | 2 +- configobject/objecttypes/iconimage/iconimage.go | 2 +- configobject/objecttypes/notesurl/notesurl.go | 2 +- .../objecttypes/notification/notification.go | 2 +- .../notificationcustomvar/notificationcustomvar.go | 2 +- .../notificationuser/notificationuser.go | 2 +- .../notificationusergroup/notificationusergroup.go | 2 +- .../notificationcommand/notificationcommand.go | 2 +- .../notificationcommandargument.go | 2 +- .../notificationcommandcustomvar.go | 2 +- .../notificationcommandenvvar.go | 2 +- configobject/objecttypes/service/service.go | 2 +- .../service/servicecomment/servicecomment.go | 2 +- .../service/servicecustomvar/servicecustomvar.go | 2 +- .../service/servicedowntime/servicedowntime.go | 2 +- .../objecttypes/service/servicestate/servicestate.go | 2 +- .../objecttypes/servicegroup/servicegroup.go | 2 +- .../servicegroupcustomvar/servicegroupcustomvar.go | 2 +- .../servicegroupmember/servicegroupmember.go | 2 +- configobject/objecttypes/timeperiod/timeperiod.go | 2 +- .../timeperiodcustomvar/timeperiodcustomvar.go | 2 +- .../timeperiodoverrideexclude.go | 2 +- .../timeperiodoverrideinclude.go | 2 +- .../timeperiod/timeperiodrange/timeperiodrange.go | 2 +- configobject/objecttypes/user/user.go | 2 +- .../objecttypes/user/usercustomvar/usercustomvar.go | 2 +- configobject/objecttypes/usergroup/usergroup.go | 2 +- .../usergroupcustomvar/usergroupcustomvar.go | 2 +- .../usergroup/usergroupmember/usergroupmember.go | 2 +- configobject/objecttypes/zone/zone.go | 2 +- connection/mysql_utils.go | 4 ++-- 51 files changed, 57 insertions(+), 57 deletions(-) diff --git a/configobject/configsync/configsync.go b/configobject/configsync/configsync.go index ee2cdf52..a6b1edbb 100644 --- a/configobject/configsync/configsync.go +++ b/configobject/configsync/configsync.go @@ -100,7 +100,7 @@ func Operator(super *supervisor.Supervisor, chHA chan int, objectInformation *co go UpdatePrepWorker(super, objectInformation, done, chUpdate, chUpdateBack) go UpdateExecWorker(super, objectInformation, done, chUpdateBack, wgUpdate, updateCounter) - go RuntimeUpdateWorker(super, objectInformation, done, chInsert, chDelete, wgInsert, wgDelete) + go RuntimeUpdateWorker(super, objectInformation, done, chUpdate, chDelete, wgUpdate, wgDelete) waitOrKill := func(wg *sync.WaitGroup, done chan struct{}) (kill bool) { waitDone := make(chan bool) @@ -426,7 +426,7 @@ func UpdateExecWorker(super *supervisor.Supervisor, objectInformation *configobj } } -func RuntimeUpdateWorker(super *supervisor.Supervisor, objectInformation *configobject.ObjectInformation, done chan struct{}, chInsert chan []string, chDelete chan []string, wgInsert *sync.WaitGroup, wgDelete *sync.WaitGroup) { +func RuntimeUpdateWorker(super *supervisor.Supervisor, objectInformation *configobject.ObjectInformation, done chan struct{}, chUpdate chan []string, chDelete chan []string, wgUpdate *sync.WaitGroup, wgDelete *sync.WaitGroup) { subscription := super.Rdbw.Subscribe() defer subscription.Close() if err := subscription.Subscribe("icinga:config:delete", "icinga:config:update"); err != nil { @@ -459,19 +459,19 @@ func RuntimeUpdateWorker(super *supervisor.Supervisor, objectInformation *config objectId := data[2] switch msg.Channel { case "icinga:config:update": - wgInsert.Add(1) - chInsert <- []string{objectId} + wgUpdate.Add(1) + chUpdate <- []string{objectId} log.WithFields(log.Fields{ "type": objectInformation.ObjectType, "action": "runtime insert/update", - }).Infof("Inserting 1 %v on runtime update", objectInformation.ObjectType) + }).Infof("Inserting 1 %v on runtime update (%s)", objectInformation.ObjectType, objectId) case "icinga:config:delete": wgDelete.Add(1) chDelete <- []string{objectId} log.WithFields(log.Fields{ "type": objectInformation.ObjectType, "action": "runtime delete", - }).Infof("Deleting 1 %v on runtime update", objectInformation.ObjectType) + }).Infof("Deleting 1 %v on runtime update (%s)", objectInformation.ObjectType, objectId) } } } diff --git a/configobject/objecttypes/actionurl/actionurl.go b/configobject/objecttypes/actionurl/actionurl.go index d6c91f43..1508a5b1 100644 --- a/configobject/objecttypes/actionurl/actionurl.go +++ b/configobject/objecttypes/actionurl/actionurl.go @@ -65,7 +65,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewActionUrl, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), } diff --git a/configobject/objecttypes/checkcommand/checkcommand.go b/configobject/objecttypes/checkcommand/checkcommand.go index 4c32d11a..c9911090 100644 --- a/configobject/objecttypes/checkcommand/checkcommand.go +++ b/configobject/objecttypes/checkcommand/checkcommand.go @@ -84,7 +84,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewCheckCommand, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "checkcommand", diff --git a/configobject/objecttypes/checkcommand/checkcommandargument/checkcommandargument.go b/configobject/objecttypes/checkcommand/checkcommandargument/checkcommandargument.go index 8a2c5b40..de7b5886 100644 --- a/configobject/objecttypes/checkcommand/checkcommandargument/checkcommandargument.go +++ b/configobject/objecttypes/checkcommand/checkcommandargument/checkcommandargument.go @@ -94,7 +94,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewCheckCommandArgument, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "checkcommand", diff --git a/configobject/objecttypes/checkcommand/checkcommandcustomvar/checkcommandcustomvar.go b/configobject/objecttypes/checkcommand/checkcommandcustomvar/checkcommandcustomvar.go index 9b13a6f1..bc20bdcf 100644 --- a/configobject/objecttypes/checkcommand/checkcommandcustomvar/checkcommandcustomvar.go +++ b/configobject/objecttypes/checkcommand/checkcommandcustomvar/checkcommandcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewCheckCommandCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "checkcommand", diff --git a/configobject/objecttypes/checkcommand/checkcommandenvvar/checkcommandenvvar.go b/configobject/objecttypes/checkcommand/checkcommandenvvar/checkcommandenvvar.go index 55390b62..c1d863fb 100644 --- a/configobject/objecttypes/checkcommand/checkcommandenvvar/checkcommandenvvar.go +++ b/configobject/objecttypes/checkcommand/checkcommandenvvar/checkcommandenvvar.go @@ -73,7 +73,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewCheckCommandEnvvar, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "checkcommand", diff --git a/configobject/objecttypes/customvar/customvar.go b/configobject/objecttypes/customvar/customvar.go index 33b7f538..ae12a944 100644 --- a/configobject/objecttypes/customvar/customvar.go +++ b/configobject/objecttypes/customvar/customvar.go @@ -71,7 +71,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), } diff --git a/configobject/objecttypes/customvar/customvarflat/customvarflat.go b/configobject/objecttypes/customvar/customvarflat/customvarflat.go index 24011408..0a4f30a8 100644 --- a/configobject/objecttypes/customvar/customvarflat/customvarflat.go +++ b/configobject/objecttypes/customvar/customvarflat/customvarflat.go @@ -154,7 +154,7 @@ func init() { PrimaryMySqlField: "customvar_id", Factory: NewCustomvarFlat, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "customvar_id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), } diff --git a/configobject/objecttypes/endpoint/endpoint.go b/configobject/objecttypes/endpoint/endpoint.go index 97740cbe..3b575395 100644 --- a/configobject/objecttypes/endpoint/endpoint.go +++ b/configobject/objecttypes/endpoint/endpoint.go @@ -78,7 +78,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewEndpoint, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "endpoint", diff --git a/configobject/objecttypes/eventcommand/eventcommand.go b/configobject/objecttypes/eventcommand/eventcommand.go index d1679bac..31209589 100644 --- a/configobject/objecttypes/eventcommand/eventcommand.go +++ b/configobject/objecttypes/eventcommand/eventcommand.go @@ -84,7 +84,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewEventCommand, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "eventcommand", diff --git a/configobject/objecttypes/eventcommand/eventcommandargument/eventcommandargument.go b/configobject/objecttypes/eventcommand/eventcommandargument/eventcommandargument.go index d5d766ac..747fd074 100644 --- a/configobject/objecttypes/eventcommand/eventcommandargument/eventcommandargument.go +++ b/configobject/objecttypes/eventcommand/eventcommandargument/eventcommandargument.go @@ -94,7 +94,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewEventCommandArgument, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "eventcommand", diff --git a/configobject/objecttypes/eventcommand/eventcommandcustomvar/eventcommandcustomvar.go b/configobject/objecttypes/eventcommand/eventcommandcustomvar/eventcommandcustomvar.go index f8b9bc3a..7c6dcb32 100644 --- a/configobject/objecttypes/eventcommand/eventcommandcustomvar/eventcommandcustomvar.go +++ b/configobject/objecttypes/eventcommand/eventcommandcustomvar/eventcommandcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewEventCommandCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "eventcommand", diff --git a/configobject/objecttypes/eventcommand/eventcommandenvvar/eventcommandenvvar.go b/configobject/objecttypes/eventcommand/eventcommandenvvar/eventcommandenvvar.go index 0a63e1f4..956554f8 100644 --- a/configobject/objecttypes/eventcommand/eventcommandenvvar/eventcommandenvvar.go +++ b/configobject/objecttypes/eventcommand/eventcommandenvvar/eventcommandenvvar.go @@ -73,7 +73,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewEventCommandEnvvar, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "eventcommand", diff --git a/configobject/objecttypes/host/host.go b/configobject/objecttypes/host/host.go index 09254b3d..002347e7 100644 --- a/configobject/objecttypes/host/host.go +++ b/configobject/objecttypes/host/host.go @@ -180,7 +180,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewHost, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "host", diff --git a/configobject/objecttypes/host/hostcomment/hostcomment.go b/configobject/objecttypes/host/hostcomment/hostcomment.go index 70cec212..40e5c9b7 100644 --- a/configobject/objecttypes/host/hostcomment/hostcomment.go +++ b/configobject/objecttypes/host/hostcomment/hostcomment.go @@ -96,7 +96,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewHostComment, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "hostcomment", diff --git a/configobject/objecttypes/host/hostcustomvar/hostcustomvar.go b/configobject/objecttypes/host/hostcustomvar/hostcustomvar.go index af39ec85..03eea6e8 100644 --- a/configobject/objecttypes/host/hostcustomvar/hostcustomvar.go +++ b/configobject/objecttypes/host/hostcustomvar/hostcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewHostCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "host", diff --git a/configobject/objecttypes/host/hostdowntime/hostdowntime.go b/configobject/objecttypes/host/hostdowntime/hostdowntime.go index 528eb61f..97a1d759 100644 --- a/configobject/objecttypes/host/hostdowntime/hostdowntime.go +++ b/configobject/objecttypes/host/hostdowntime/hostdowntime.go @@ -107,7 +107,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewHostDowntime, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "hostdowntime", diff --git a/configobject/objecttypes/host/hoststate/hoststate.go b/configobject/objecttypes/host/hoststate/hoststate.go index ab7f37dc..1ad90d18 100644 --- a/configobject/objecttypes/host/hoststate/hoststate.go +++ b/configobject/objecttypes/host/hoststate/hoststate.go @@ -137,7 +137,7 @@ func init() { PrimaryMySqlField: "host_id", Factory: NewHostState, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "host_id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "host_id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "host", diff --git a/configobject/objecttypes/hostgroup/hostgroup.go b/configobject/objecttypes/hostgroup/hostgroup.go index 0e4dcfae..a7a987c0 100644 --- a/configobject/objecttypes/hostgroup/hostgroup.go +++ b/configobject/objecttypes/hostgroup/hostgroup.go @@ -84,7 +84,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewHostgroup, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "hostgroup", diff --git a/configobject/objecttypes/hostgroup/hostgroupcustomvar/hostgroupcustomvar.go b/configobject/objecttypes/hostgroup/hostgroupcustomvar/hostgroupcustomvar.go index a0aaa558..3f38855b 100644 --- a/configobject/objecttypes/hostgroup/hostgroupcustomvar/hostgroupcustomvar.go +++ b/configobject/objecttypes/hostgroup/hostgroupcustomvar/hostgroupcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewHostgroupCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "hostgroup", diff --git a/configobject/objecttypes/hostgroup/hostgroupmember/hostgroupmember.go b/configobject/objecttypes/hostgroup/hostgroupmember/hostgroupmember.go index ed30af15..83a7b415 100644 --- a/configobject/objecttypes/hostgroup/hostgroupmember/hostgroupmember.go +++ b/configobject/objecttypes/hostgroup/hostgroupmember/hostgroupmember.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewHostgroupMember, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "host", diff --git a/configobject/objecttypes/iconimage/iconimage.go b/configobject/objecttypes/iconimage/iconimage.go index a1a2a61c..4c624076 100644 --- a/configobject/objecttypes/iconimage/iconimage.go +++ b/configobject/objecttypes/iconimage/iconimage.go @@ -65,7 +65,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewIconImage, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), } diff --git a/configobject/objecttypes/notesurl/notesurl.go b/configobject/objecttypes/notesurl/notesurl.go index 04ccdd65..f9ded354 100644 --- a/configobject/objecttypes/notesurl/notesurl.go +++ b/configobject/objecttypes/notesurl/notesurl.go @@ -65,7 +65,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotesUrl, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), } diff --git a/configobject/objecttypes/notification/notification.go b/configobject/objecttypes/notification/notification.go index 11d50adb..6e78d614 100644 --- a/configobject/objecttypes/notification/notification.go +++ b/configobject/objecttypes/notification/notification.go @@ -114,7 +114,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotification, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "notification", diff --git a/configobject/objecttypes/notification/notificationcustomvar/notificationcustomvar.go b/configobject/objecttypes/notification/notificationcustomvar/notificationcustomvar.go index fe501cf7..837aaa29 100644 --- a/configobject/objecttypes/notification/notificationcustomvar/notificationcustomvar.go +++ b/configobject/objecttypes/notification/notificationcustomvar/notificationcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotificationCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "notification", diff --git a/configobject/objecttypes/notification/notificationuser/notificationuser.go b/configobject/objecttypes/notification/notificationuser/notificationuser.go index e4d2a7ac..5846fef5 100644 --- a/configobject/objecttypes/notification/notificationuser/notificationuser.go +++ b/configobject/objecttypes/notification/notificationuser/notificationuser.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotificationUser, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "notification", diff --git a/configobject/objecttypes/notification/notificationusergroup/notificationusergroup.go b/configobject/objecttypes/notification/notificationusergroup/notificationusergroup.go index 24eb9314..a75b8b73 100644 --- a/configobject/objecttypes/notification/notificationusergroup/notificationusergroup.go +++ b/configobject/objecttypes/notification/notificationusergroup/notificationusergroup.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotificationUsergroup, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "notification", diff --git a/configobject/objecttypes/notificationcommand/notificationcommand.go b/configobject/objecttypes/notificationcommand/notificationcommand.go index 310e6fd6..f20a350b 100644 --- a/configobject/objecttypes/notificationcommand/notificationcommand.go +++ b/configobject/objecttypes/notificationcommand/notificationcommand.go @@ -84,7 +84,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotificationCommand, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "notificationcommand", diff --git a/configobject/objecttypes/notificationcommand/notificationcommandargument/notificationcommandargument.go b/configobject/objecttypes/notificationcommand/notificationcommandargument/notificationcommandargument.go index 55687916..68ea3e36 100644 --- a/configobject/objecttypes/notificationcommand/notificationcommandargument/notificationcommandargument.go +++ b/configobject/objecttypes/notificationcommand/notificationcommandargument/notificationcommandargument.go @@ -94,7 +94,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotificationCommandArgument, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "notificationcommand", diff --git a/configobject/objecttypes/notificationcommand/notificationcommandcustomvar/notificationcommandcustomvar.go b/configobject/objecttypes/notificationcommand/notificationcommandcustomvar/notificationcommandcustomvar.go index da200b0d..8a7d60ae 100644 --- a/configobject/objecttypes/notificationcommand/notificationcommandcustomvar/notificationcommandcustomvar.go +++ b/configobject/objecttypes/notificationcommand/notificationcommandcustomvar/notificationcommandcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotificationCommandCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "notificationcommand", diff --git a/configobject/objecttypes/notificationcommand/notificationcommandenvvar/notificationcommandenvvar.go b/configobject/objecttypes/notificationcommand/notificationcommandenvvar/notificationcommandenvvar.go index 7cb4a3eb..97ad874c 100644 --- a/configobject/objecttypes/notificationcommand/notificationcommandenvvar/notificationcommandenvvar.go +++ b/configobject/objecttypes/notificationcommand/notificationcommandenvvar/notificationcommandenvvar.go @@ -73,7 +73,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewNotificationCommandEnvvar, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "notificationcommand", diff --git a/configobject/objecttypes/service/service.go b/configobject/objecttypes/service/service.go index 584b5883..161c9253 100644 --- a/configobject/objecttypes/service/service.go +++ b/configobject/objecttypes/service/service.go @@ -171,7 +171,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewService, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "service", diff --git a/configobject/objecttypes/service/servicecomment/servicecomment.go b/configobject/objecttypes/service/servicecomment/servicecomment.go index 66fdcdb7..60812387 100644 --- a/configobject/objecttypes/service/servicecomment/servicecomment.go +++ b/configobject/objecttypes/service/servicecomment/servicecomment.go @@ -96,7 +96,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewServiceComment, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "servicecomment", diff --git a/configobject/objecttypes/service/servicecustomvar/servicecustomvar.go b/configobject/objecttypes/service/servicecustomvar/servicecustomvar.go index e6c0f6ba..7fe9f47d 100644 --- a/configobject/objecttypes/service/servicecustomvar/servicecustomvar.go +++ b/configobject/objecttypes/service/servicecustomvar/servicecustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewServiceCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "service", diff --git a/configobject/objecttypes/service/servicedowntime/servicedowntime.go b/configobject/objecttypes/service/servicedowntime/servicedowntime.go index bf712a57..665fcd04 100644 --- a/configobject/objecttypes/service/servicedowntime/servicedowntime.go +++ b/configobject/objecttypes/service/servicedowntime/servicedowntime.go @@ -107,7 +107,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewServiceDowntime, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "servicedowntime", diff --git a/configobject/objecttypes/service/servicestate/servicestate.go b/configobject/objecttypes/service/servicestate/servicestate.go index 5f831c09..fbee60bc 100644 --- a/configobject/objecttypes/service/servicestate/servicestate.go +++ b/configobject/objecttypes/service/servicestate/servicestate.go @@ -137,7 +137,7 @@ func init() { PrimaryMySqlField: "service_id", Factory: NewServiceState, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "service_id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "service_id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "service", diff --git a/configobject/objecttypes/servicegroup/servicegroup.go b/configobject/objecttypes/servicegroup/servicegroup.go index 1773aec4..7d38c327 100644 --- a/configobject/objecttypes/servicegroup/servicegroup.go +++ b/configobject/objecttypes/servicegroup/servicegroup.go @@ -84,7 +84,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewServicegroup, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "servicegroup", diff --git a/configobject/objecttypes/servicegroup/servicegroupcustomvar/servicegroupcustomvar.go b/configobject/objecttypes/servicegroup/servicegroupcustomvar/servicegroupcustomvar.go index 4fc6cc60..2c11eac3 100644 --- a/configobject/objecttypes/servicegroup/servicegroupcustomvar/servicegroupcustomvar.go +++ b/configobject/objecttypes/servicegroup/servicegroupcustomvar/servicegroupcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewServicegroupCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "servicegroup", diff --git a/configobject/objecttypes/servicegroup/servicegroupmember/servicegroupmember.go b/configobject/objecttypes/servicegroup/servicegroupmember/servicegroupmember.go index fc51fe10..2241caa1 100644 --- a/configobject/objecttypes/servicegroup/servicegroupmember/servicegroupmember.go +++ b/configobject/objecttypes/servicegroup/servicegroupmember/servicegroupmember.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewServicegroupMember, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "service", diff --git a/configobject/objecttypes/timeperiod/timeperiod.go b/configobject/objecttypes/timeperiod/timeperiod.go index 8f90ee34..55da40fd 100644 --- a/configobject/objecttypes/timeperiod/timeperiod.go +++ b/configobject/objecttypes/timeperiod/timeperiod.go @@ -84,7 +84,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewTimeperiod, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "timeperiod", diff --git a/configobject/objecttypes/timeperiod/timeperiodcustomvar/timeperiodcustomvar.go b/configobject/objecttypes/timeperiod/timeperiodcustomvar/timeperiodcustomvar.go index 88d9a19e..1f110c3a 100644 --- a/configobject/objecttypes/timeperiod/timeperiodcustomvar/timeperiodcustomvar.go +++ b/configobject/objecttypes/timeperiod/timeperiodcustomvar/timeperiodcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewTimeperiodCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "timeperiod", diff --git a/configobject/objecttypes/timeperiod/timeperiodoverrideexclude/timeperiodoverrideexclude.go b/configobject/objecttypes/timeperiod/timeperiodoverrideexclude/timeperiodoverrideexclude.go index f5d21ad1..3b0cae59 100644 --- a/configobject/objecttypes/timeperiod/timeperiodoverrideexclude/timeperiodoverrideexclude.go +++ b/configobject/objecttypes/timeperiod/timeperiodoverrideexclude/timeperiodoverrideexclude.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewTimeperiodOverrideExclude, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "timeperiod", diff --git a/configobject/objecttypes/timeperiod/timeperiodoverrideinclude/timeperiodoverrideinclude.go b/configobject/objecttypes/timeperiod/timeperiodoverrideinclude/timeperiodoverrideinclude.go index d96f5201..2cd8850f 100644 --- a/configobject/objecttypes/timeperiod/timeperiodoverrideinclude/timeperiodoverrideinclude.go +++ b/configobject/objecttypes/timeperiod/timeperiodoverrideinclude/timeperiodoverrideinclude.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewTimeperiodOverrideInclude, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "timeperiod", diff --git a/configobject/objecttypes/timeperiod/timeperiodrange/timeperiodrange.go b/configobject/objecttypes/timeperiod/timeperiodrange/timeperiodrange.go index 264c4875..aedc27d2 100644 --- a/configobject/objecttypes/timeperiod/timeperiodrange/timeperiodrange.go +++ b/configobject/objecttypes/timeperiod/timeperiodrange/timeperiodrange.go @@ -70,7 +70,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewTimeperiodRange, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "timeperiod", diff --git a/configobject/objecttypes/user/user.go b/configobject/objecttypes/user/user.go index c4b28c90..4cd9bebe 100644 --- a/configobject/objecttypes/user/user.go +++ b/configobject/objecttypes/user/user.go @@ -105,7 +105,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewUser, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "user", diff --git a/configobject/objecttypes/user/usercustomvar/usercustomvar.go b/configobject/objecttypes/user/usercustomvar/usercustomvar.go index 12126be0..3c0ac26d 100644 --- a/configobject/objecttypes/user/usercustomvar/usercustomvar.go +++ b/configobject/objecttypes/user/usercustomvar/usercustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewUserCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "user", diff --git a/configobject/objecttypes/usergroup/usergroup.go b/configobject/objecttypes/usergroup/usergroup.go index 7a7993c1..f0bc53fe 100644 --- a/configobject/objecttypes/usergroup/usergroup.go +++ b/configobject/objecttypes/usergroup/usergroup.go @@ -84,7 +84,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewUsergroup, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "usergroup", diff --git a/configobject/objecttypes/usergroup/usergroupcustomvar/usergroupcustomvar.go b/configobject/objecttypes/usergroup/usergroupcustomvar/usergroupcustomvar.go index 97ecb89c..5605ccca 100644 --- a/configobject/objecttypes/usergroup/usergroupcustomvar/usergroupcustomvar.go +++ b/configobject/objecttypes/usergroup/usergroupcustomvar/usergroupcustomvar.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewUsergroupCustomvar, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "usergroup", diff --git a/configobject/objecttypes/usergroup/usergroupmember/usergroupmember.go b/configobject/objecttypes/usergroup/usergroupmember/usergroupmember.go index 43efe08e..b60a0a38 100644 --- a/configobject/objecttypes/usergroup/usergroupmember/usergroupmember.go +++ b/configobject/objecttypes/usergroup/usergroupmember/usergroupmember.go @@ -67,7 +67,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewUsergroupMember, HasChecksum: false, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "user", diff --git a/configobject/objecttypes/zone/zone.go b/configobject/objecttypes/zone/zone.go index 5910eb3e..39a83c54 100644 --- a/configobject/objecttypes/zone/zone.go +++ b/configobject/objecttypes/zone/zone.go @@ -87,7 +87,7 @@ func init() { PrimaryMySqlField: "id", Factory: NewZone, HasChecksum: true, - BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"), + BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields), BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"), BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields), NotificationListenerType: "zone", diff --git a/connection/mysql_utils.go b/connection/mysql_utils.go index 7a843943..58d0e8ea 100644 --- a/connection/mysql_utils.go +++ b/connection/mysql_utils.go @@ -376,11 +376,11 @@ type BulkInsertStmt struct { NumField int } -func NewBulkInsertStmt(table string, fields []string, primaryKey string) *BulkInsertStmt { +func NewBulkInsertStmt(table string, fields []string) *BulkInsertStmt { numField := len(fields) placeholder := fmt.Sprintf("(%s)", strings.TrimSuffix(strings.Repeat("?, ", numField), ", ")) stmt := BulkInsertStmt{ - Format: fmt.Sprintf("INSERT INTO %s (%s) VALUES %s ON DUPLICATE KEY UPDATE %s = %s", table, strings.Join(fields, ", "), "%s", primaryKey, primaryKey), + Format: fmt.Sprintf("REPLACE INTO %s (%s) VALUES %s", table, strings.Join(fields, ", "), "%s"), Fields: fields, Placeholder: placeholder, NumField: numField,