mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Merge branch 'feature/notification_history_use_enum_for_types'
This commit is contained in:
commit
2ed6cbd52c
3 changed files with 17 additions and 6 deletions
|
|
@ -70,7 +70,7 @@ func notificationHistoryWorker(super *supervisor.Supervisor) {
|
|||
utils.DecodeHexIfNotNil(values["host_id"]),
|
||||
utils.DecodeHexIfNotNil(values["service_id"]),
|
||||
utils.EncodeChecksum(values["notification_id"].(string)),
|
||||
values["type"],
|
||||
utils.NotificationTypesToDbEnumString[values["type"].(string)],
|
||||
values["event_time"],
|
||||
values["state"],
|
||||
values["previous_hard_state"],
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ CREATE TABLE notification_history (
|
|||
service_id binary(20) NULL DEFAULT NULL COMMENT 'service.id',
|
||||
notification_id binary(20) NOT NULL COMMENT 'notification.id',
|
||||
|
||||
type smallint(3) unsigned NOT NULL,
|
||||
type enum('downtime_start', 'downtime_end', 'downtime_removed', 'custom', 'acknowledgement', 'problem', 'recovery', 'flapping_start', 'flapping_end') NOT NULL,
|
||||
event_time bigint(20) unsigned NOT NULL,
|
||||
state tinyint(1) unsigned NOT NULL,
|
||||
previous_hard_state tinyint(1) unsigned NOT NULL,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ var (
|
|||
true: "y",
|
||||
false: "n",
|
||||
}
|
||||
NotificationStates = map[string]int{
|
||||
NotificationStatesToInt = map[string]int{
|
||||
"OK": 1,
|
||||
"Warning": 2,
|
||||
"Critical": 4,
|
||||
|
|
@ -19,7 +19,7 @@ var (
|
|||
"Up": 16,
|
||||
"Down": 32,
|
||||
}
|
||||
NotificationTypes = map[string]int{
|
||||
NotificationTypesToInt = map[string]int{
|
||||
"DowntimeStart": 1,
|
||||
"DowntimeEnd": 2,
|
||||
"DowntimeRemoved": 4,
|
||||
|
|
@ -30,6 +30,17 @@ var (
|
|||
"FlappingStart": 128,
|
||||
"FlappingEnd": 256,
|
||||
}
|
||||
NotificationTypesToDbEnumString = map[string]string{
|
||||
"1": "downtime_start",
|
||||
"2": "downtime_end",
|
||||
"4": "downtime_removed",
|
||||
"8": "custom",
|
||||
"16": "acknowledgement",
|
||||
"32": "problem",
|
||||
"64": "recovery",
|
||||
"128": "flapping_start",
|
||||
"256": "flapping_end",
|
||||
}
|
||||
CommentEntryTypes = map[string]string{
|
||||
"1": "comment",
|
||||
"2": "downtime",
|
||||
|
|
@ -73,7 +84,7 @@ func DecodeChecksum(c []byte) string {
|
|||
func NotificationStatesToBitMask(states []string) int {
|
||||
mask := 0
|
||||
for _, s := range states {
|
||||
mask += NotificationStates[s]
|
||||
mask += NotificationStatesToInt[s]
|
||||
}
|
||||
return mask
|
||||
}
|
||||
|
|
@ -82,7 +93,7 @@ func NotificationStatesToBitMask(states []string) int {
|
|||
func NotificationTypesToBitMask(types []string) int {
|
||||
mask := 0
|
||||
for _, t := range types {
|
||||
mask += NotificationTypes[t]
|
||||
mask += NotificationTypesToInt[t]
|
||||
}
|
||||
return mask
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue