mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Add host and service downtimes and comments
This commit is contained in:
parent
ca3992fab6
commit
2161ce88fa
5 changed files with 420 additions and 0 deletions
97
configobject/objecttypes/host/hostcomment/hostcomment.go
Normal file
97
configobject/objecttypes/host/hostcomment/hostcomment.go
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
package hostcomment
|
||||
|
||||
import (
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject"
|
||||
"git.icinga.com/icingadb/icingadb-main/connection"
|
||||
"git.icinga.com/icingadb/icingadb-main/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
ObjectInformation configobject.ObjectInformation
|
||||
Fields = []string{
|
||||
"id",
|
||||
"env_id",
|
||||
"host_id",
|
||||
"name_checksum",
|
||||
"properties_checksum",
|
||||
"name",
|
||||
"author",
|
||||
"text",
|
||||
"entry_type",
|
||||
"entry_time",
|
||||
"is_persistent",
|
||||
"expire_time",
|
||||
"zone_id",
|
||||
}
|
||||
)
|
||||
|
||||
type HostComment struct {
|
||||
Id string `json:"id"`
|
||||
EnvId string `json:"env_id"`
|
||||
HostId string `json:"host_id"`
|
||||
NameChecksum string `json:"name_checksum"`
|
||||
PropertiesChecksum string `json:"checksum"`
|
||||
Name string `json:"name"`
|
||||
Author string `json:"author"`
|
||||
Text string `json:"text"`
|
||||
EntryType float64 `json:"entry_type"`
|
||||
EntryTime float64 `json:"entry_time"`
|
||||
IsPersistent bool `json:"is_persistent"`
|
||||
ExpireTime float64 `json:"expire_time"`
|
||||
ZoneId string `json:"zone_id"`
|
||||
}
|
||||
|
||||
func NewHostComment() connection.Row {
|
||||
h := HostComment{}
|
||||
|
||||
return &h
|
||||
}
|
||||
|
||||
func (h *HostComment) InsertValues() []interface{} {
|
||||
v := h.UpdateValues()
|
||||
|
||||
return append([]interface{}{utils.Checksum(h.Id)}, v...)
|
||||
}
|
||||
|
||||
func (h *HostComment) UpdateValues() []interface{} {
|
||||
v := make([]interface{}, 0)
|
||||
|
||||
v = append(
|
||||
v,
|
||||
utils.Checksum(h.EnvId),
|
||||
utils.Checksum(h.HostId),
|
||||
utils.Checksum(h.NameChecksum),
|
||||
utils.Checksum(h.PropertiesChecksum),
|
||||
h.Name,
|
||||
h.Author,
|
||||
h.Text,
|
||||
h.EntryType,
|
||||
h.EntryTime,
|
||||
utils.Bool[h.IsPersistent],
|
||||
h.ExpireTime,
|
||||
utils.Checksum(h.ZoneId),
|
||||
)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (h *HostComment) GetId() string {
|
||||
return h.Id
|
||||
}
|
||||
|
||||
func (h *HostComment) SetId(id string) {
|
||||
h.Id = id
|
||||
}
|
||||
|
||||
func init() {
|
||||
name := "host_comment"
|
||||
ObjectInformation = configobject.ObjectInformation{
|
||||
ObjectType: name,
|
||||
RedisKey: "hostcomment",
|
||||
Factory: NewHostComment,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
}
|
||||
109
configobject/objecttypes/host/hostdowntime/hostdowntime.go
Normal file
109
configobject/objecttypes/host/hostdowntime/hostdowntime.go
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
package hostdowntime
|
||||
|
||||
import (
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject"
|
||||
"git.icinga.com/icingadb/icingadb-main/connection"
|
||||
"git.icinga.com/icingadb/icingadb-main/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
ObjectInformation configobject.ObjectInformation
|
||||
Fields = []string{
|
||||
"id",
|
||||
"env_id",
|
||||
"host_id",
|
||||
"name_checksum",
|
||||
"properties_checksum",
|
||||
"name",
|
||||
"author",
|
||||
"comment",
|
||||
"entry_time",
|
||||
"scheduled_start_time",
|
||||
"scheduled_end_time",
|
||||
"duration",
|
||||
"is_fixed",
|
||||
"is_in_effect",
|
||||
"actual_start_time",
|
||||
"actual_end_time",
|
||||
"zone_id",
|
||||
}
|
||||
)
|
||||
|
||||
type HostDowntime struct {
|
||||
Id string `json:"id"`
|
||||
EnvId string `json:"env_id"`
|
||||
HostId string `json:"host_id"`
|
||||
NameChecksum string `json:"name_checksum"`
|
||||
PropertiesChecksum string `json:"checksum"`
|
||||
Name string `json:"name"`
|
||||
Author string `json:"author"`
|
||||
Comment string `json:"comment"`
|
||||
EntryTime float64 `json:"entry_time"`
|
||||
ScheduledStartTime float64 `json:"scheduled_start_time"`
|
||||
ScheduledEndTime float64 `json:"scheduled_end_time"`
|
||||
Duration float64 `json:"duration"`
|
||||
IsFixed bool `json:"is_fixed"`
|
||||
IsInEffect bool `json:"is_in_effect"`
|
||||
ActualStartTime float64 `json:"actual_start_time"`
|
||||
ActualEndTime float64 `json:"actual_end_time"`
|
||||
ZoneId string `json:"zone_id"`
|
||||
}
|
||||
|
||||
func NewHostDowntime() connection.Row {
|
||||
h := HostDowntime{}
|
||||
|
||||
return &h
|
||||
}
|
||||
|
||||
func (h *HostDowntime) InsertValues() []interface{} {
|
||||
v := h.UpdateValues()
|
||||
|
||||
return append([]interface{}{utils.Checksum(h.Id)}, v...)
|
||||
}
|
||||
|
||||
func (h *HostDowntime) UpdateValues() []interface{} {
|
||||
v := make([]interface{}, 0)
|
||||
|
||||
v = append(
|
||||
v,
|
||||
utils.Checksum(h.EnvId),
|
||||
utils.Checksum(h.HostId),
|
||||
utils.Checksum(h.NameChecksum),
|
||||
utils.Checksum(h.PropertiesChecksum),
|
||||
h.Name,
|
||||
h.Author,
|
||||
h.Comment,
|
||||
h.EntryTime,
|
||||
h.ScheduledStartTime,
|
||||
h.ScheduledEndTime,
|
||||
h.Duration,
|
||||
utils.Bool[h.IsFixed],
|
||||
utils.Bool[h.IsInEffect],
|
||||
h.ActualStartTime,
|
||||
h.ActualEndTime,
|
||||
utils.Checksum(h.ZoneId),
|
||||
)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (h *HostDowntime) GetId() string {
|
||||
return h.Id
|
||||
}
|
||||
|
||||
func (h *HostDowntime) SetId(id string) {
|
||||
h.Id = id
|
||||
}
|
||||
|
||||
func init() {
|
||||
name := "host_downtime"
|
||||
ObjectInformation = configobject.ObjectInformation{
|
||||
ObjectType: name,
|
||||
RedisKey: "hostdowntime",
|
||||
Factory: NewHostDowntime,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package servicecomment
|
||||
|
||||
import (
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject"
|
||||
"git.icinga.com/icingadb/icingadb-main/connection"
|
||||
"git.icinga.com/icingadb/icingadb-main/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
ObjectInformation configobject.ObjectInformation
|
||||
Fields = []string{
|
||||
"id",
|
||||
"env_id",
|
||||
"service_id",
|
||||
"name_checksum",
|
||||
"properties_checksum",
|
||||
"name",
|
||||
"author",
|
||||
"text",
|
||||
"entry_type",
|
||||
"entry_time",
|
||||
"is_persistent",
|
||||
"expire_time",
|
||||
"zone_id",
|
||||
}
|
||||
)
|
||||
|
||||
type ServiceComment struct {
|
||||
Id string `json:"id"`
|
||||
EnvId string `json:"env_id"`
|
||||
ServiceId string `json:"service_id"`
|
||||
NameChecksum string `json:"name_checksum"`
|
||||
PropertiesChecksum string `json:"checksum"`
|
||||
Name string `json:"name"`
|
||||
Author string `json:"author"`
|
||||
Text string `json:"text"`
|
||||
EntryType float64 `json:"entry_type"`
|
||||
EntryTime float64 `json:"entry_time"`
|
||||
IsPersistent bool `json:"is_persistent"`
|
||||
ExpireTime float64 `json:"expire_time"`
|
||||
ZoneId string `json:"zone_id"`
|
||||
}
|
||||
|
||||
func NewServiceComment() connection.Row {
|
||||
s := ServiceComment{}
|
||||
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s *ServiceComment) InsertValues() []interface{} {
|
||||
v := s.UpdateValues()
|
||||
|
||||
return append([]interface{}{utils.Checksum(s.Id)}, v...)
|
||||
}
|
||||
|
||||
func (s *ServiceComment) UpdateValues() []interface{} {
|
||||
v := make([]interface{}, 0)
|
||||
|
||||
v = append(
|
||||
v,
|
||||
utils.Checksum(s.EnvId),
|
||||
utils.Checksum(s.ServiceId),
|
||||
utils.Checksum(s.NameChecksum),
|
||||
utils.Checksum(s.PropertiesChecksum),
|
||||
s.Name,
|
||||
s.Author,
|
||||
s.Text,
|
||||
s.EntryType,
|
||||
s.EntryTime,
|
||||
utils.Bool[s.IsPersistent],
|
||||
s.ExpireTime,
|
||||
utils.Checksum(s.ZoneId),
|
||||
)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (s *ServiceComment) GetId() string {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *ServiceComment) SetId(id string) {
|
||||
s.Id = id
|
||||
}
|
||||
|
||||
func init() {
|
||||
name := "service_comment"
|
||||
ObjectInformation = configobject.ObjectInformation{
|
||||
ObjectType: name,
|
||||
RedisKey: "servicecomment",
|
||||
Factory: NewServiceComment,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
package servicedowntime
|
||||
|
||||
import (
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject"
|
||||
"git.icinga.com/icingadb/icingadb-main/connection"
|
||||
"git.icinga.com/icingadb/icingadb-main/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
ObjectInformation configobject.ObjectInformation
|
||||
Fields = []string{
|
||||
"id",
|
||||
"env_id",
|
||||
"service_id",
|
||||
"name_checksum",
|
||||
"properties_checksum",
|
||||
"name",
|
||||
"author",
|
||||
"comment",
|
||||
"entry_time",
|
||||
"scheduled_start_time",
|
||||
"scheduled_end_time",
|
||||
"duration",
|
||||
"is_fixed",
|
||||
"is_in_effect",
|
||||
"actual_start_time",
|
||||
"actual_end_time",
|
||||
"zone_id",
|
||||
}
|
||||
)
|
||||
|
||||
type ServiceDowntime struct {
|
||||
Id string `json:"id"`
|
||||
EnvId string `json:"env_id"`
|
||||
ServiceId string `json:"service_id"`
|
||||
NameChecksum string `json:"name_checksum"`
|
||||
PropertiesChecksum string `json:"checksum"`
|
||||
Name string `json:"name"`
|
||||
Author string `json:"author"`
|
||||
Comment string `json:"comment"`
|
||||
EntryTime float64 `json:"entry_time"`
|
||||
ScheduledStartTime float64 `json:"scheduled_start_time"`
|
||||
ScheduledEndTime float64 `json:"scheduled_end_time"`
|
||||
Duration float64 `json:"duration"`
|
||||
IsFixed bool `json:"is_fixed"`
|
||||
IsInEffect bool `json:"is_in_effect"`
|
||||
ActualStartTime float64 `json:"actual_start_time"`
|
||||
ActualEndTime float64 `json:"actual_end_time"`
|
||||
ZoneId string `json:"zone_id"`
|
||||
}
|
||||
|
||||
func NewServiceDowntime() connection.Row {
|
||||
s := ServiceDowntime{}
|
||||
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s *ServiceDowntime) InsertValues() []interface{} {
|
||||
v := s.UpdateValues()
|
||||
|
||||
return append([]interface{}{utils.Checksum(s.Id)}, v...)
|
||||
}
|
||||
|
||||
func (s *ServiceDowntime) UpdateValues() []interface{} {
|
||||
v := make([]interface{}, 0)
|
||||
|
||||
v = append(
|
||||
v,
|
||||
utils.Checksum(s.EnvId),
|
||||
utils.Checksum(s.ServiceId),
|
||||
utils.Checksum(s.NameChecksum),
|
||||
utils.Checksum(s.PropertiesChecksum),
|
||||
s.Name,
|
||||
s.Author,
|
||||
s.Comment,
|
||||
s.EntryTime,
|
||||
s.ScheduledStartTime,
|
||||
s.ScheduledEndTime,
|
||||
s.Duration,
|
||||
utils.Bool[s.IsFixed],
|
||||
utils.Bool[s.IsInEffect],
|
||||
s.ActualStartTime,
|
||||
s.ActualEndTime,
|
||||
utils.Checksum(s.ZoneId),
|
||||
)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (s *ServiceDowntime) GetId() string {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *ServiceDowntime) SetId(id string) {
|
||||
s.Id = id
|
||||
}
|
||||
|
||||
func init() {
|
||||
name := "service_downtime"
|
||||
ObjectInformation = configobject.ObjectInformation{
|
||||
ObjectType: name,
|
||||
RedisKey: "servicedowntime",
|
||||
Factory: NewServiceDowntime,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
}
|
||||
8
main.go
8
main.go
|
|
@ -17,7 +17,9 @@ import (
|
|||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/eventcommand/eventcommandcustomvar"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/eventcommand/eventcommandenvvar"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/host"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/host/hostcomment"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/host/hostcustomvar"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/host/hostdowntime"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/hostgroup"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/hostgroup/hostgroupcustomvar"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/hostgroup/hostgroupmember"
|
||||
|
|
@ -32,7 +34,9 @@ import (
|
|||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/notificationcommand/notificationcommandcustomvar"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/notificationcommand/notificationcommandenvvar"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/service"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/service/servicecomment"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/service/servicecustomvar"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/service/servicedowntime"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/servicegroup"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/servicegroup/servicegroupcustomvar"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/objecttypes/servicegroup/servicegroupmember"
|
||||
|
|
@ -119,9 +123,13 @@ func startConfigSyncOperators(super *supervisor.Supervisor, haInstance *ha.HA) {
|
|||
objectTypes := []*configobject.ObjectInformation{
|
||||
&host.ObjectInformation,
|
||||
&hostcustomvar.ObjectInformation,
|
||||
&hostdowntime.ObjectInformation,
|
||||
&hostcomment.ObjectInformation,
|
||||
|
||||
&service.ObjectInformation,
|
||||
&servicecustomvar.ObjectInformation,
|
||||
&servicedowntime.ObjectInformation,
|
||||
&servicecomment.ObjectInformation,
|
||||
|
||||
&hostgroup.ObjectInformation,
|
||||
&hostgroupcustomvar.ObjectInformation,
|
||||
|
|
|
|||
Loading…
Reference in a new issue