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