@@ -620,17 +620,15 @@ func convertNotificationRows(
620
620
// migrated data itself via the history ID as object name, i.e. one "virtual object" per sent notification.
621
621
name := strconv .FormatUint (row .NotificationId , 10 )
622
622
623
- nt := convertNotificationType (row .NotificationReason , row .State )
624
-
625
- ntEnum , err := nt .Value ()
623
+ notificationType , err := convertNotificationType (row .NotificationReason , row .State )
626
624
if err != nil {
627
625
continue
628
626
}
629
627
630
628
ts := convertTime (row .EndTime .Int64 , row .EndTimeUsec )
631
629
tsMilli := float64 (ts .Time ().UnixMilli ())
632
- notificationHistoryId := hashAny ([]interface {}{env , name , ntEnum , tsMilli })
633
- id := hashAny ([]interface {}{env , "notification" , name , ntEnum , tsMilli })
630
+ notificationHistoryId := hashAny ([]interface {}{env , name , notificationType , tsMilli })
631
+ id := hashAny ([]interface {}{env , "notification" , name , notificationType , tsMilli })
634
632
typ := objectTypes [row .ObjecttypeId ]
635
633
hostId := calcObjectId (env , row .Name1 )
636
634
serviceId := calcServiceId (env , row .Name1 , row .Name2 )
@@ -702,30 +700,30 @@ func convertNotificationRows(
702
700
//
703
701
// [1]: https://github.com/Icinga/icinga2/blob/32c7f7730db154ba0dff5856a8985d125791c/lib/db_ido/dbevents.cpp#L1507-L1524
704
702
// [2]: https://github.com/Icinga/icingadb/blob/8f31ac143875498797725adb9bfacf3d4/pkg/types/notification_type.go#L53-L61
705
- func convertNotificationType (notificationReason , state uint8 ) icingadbTypes. NotificationType {
703
+ func convertNotificationType (notificationReason , state uint8 ) ( string , error ) {
706
704
switch notificationReason {
707
705
case 0 : // state
708
706
if state == 0 {
709
- return 64 // recovery
707
+ return " recovery" , nil
710
708
} else {
711
- return 32 // problem
709
+ return " problem" , nil
712
710
}
713
- case 1 : // acknowledgement
714
- return 16
715
- case 2 : // flapping start
716
- return 128
717
- case 3 : // flapping end
718
- return 256
719
- case 5 : // downtime start
720
- return 1
721
- case 6 : // downtime end
722
- return 2
723
- case 7 : // downtime removed
724
- return 4
725
- case 8 : // custom
726
- return 8
727
- default : // bad notification type
728
- return 0
711
+ case 1 :
712
+ return "acknowledgement" , nil
713
+ case 2 :
714
+ return "flapping_start" , nil
715
+ case 3 :
716
+ return "flapping_end" , nil
717
+ case 5 :
718
+ return "downtime_start" , nil
719
+ case 6 :
720
+ return "downtime_end" , nil
721
+ case 7 :
722
+ return "downtime_removed" , nil
723
+ case 8 :
724
+ return "custom" , nil
725
+ default :
726
+ return "" , fmt . Errorf ( "bad notification type: %#v" , notificationReason )
729
727
}
730
728
}
731
729
0 commit comments