Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #11851] Downtime notifications do not pass author and comment #4239

Closed
icinga-migration opened this issue May 28, 2016 · 8 comments

Comments

Projects
None yet
1 participant
@icinga-migration
Copy link
Member

commented May 28, 2016

This issue has been migrated from Redmine: https://dev.icinga.com/issues/11851

Created by sru on 2016-05-28 05:19:59 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2016-08-10 14:05:06 +00:00)
Target Version: 2.5.0
Last Update: 2016-08-10 14:05:06 +00:00 (in Redmine)

Icinga Version: 2.4.10
Backport?: Not yet backported
Include in Changelog: 1

From the gui, planned static downtime with comment "missing comment".
In the email, that is not present:

***** Icinga  *****

Notification Type: DOWNTIMESTART

Service: Aircondition
Host: devsv1
Address: 127.0.0.1
State: OK

Date/Time: 2016-05-28 06:28:47 +0200

Additional Info: CLIMA OK: Door=running, Cabinet=running

Comment: [] 

icinga2.log and debug.log show that it has been accepted:

icinga2.log:[2016-05-28 06:37:35 +0200] information/ExternalCommandListener: Executing external command: [1464410255] SCHEDULE_SVC_DOWNTIME;devsv1;Aircondition;1464410219;1464410459;1;0;0;root;missing comment

debuglog:
[2016-05-28 06:37:35 +0200] information/ExternalCommandListener: Executing external command: [1464410255] SCHEDULE_SVC_DOWNTIME;devsv1;Aircondition;1464410219;1464410459;1;0;0;root;missing comment
[2016-05-28 06:37:35 +0200] debug/DbEvents: add external command history
[2016-05-28 06:37:35 +0200] notice/ExternalCommandProcessor: Creating downtime for service devsv1!Aircondition
[2016-05-28 06:37:35 +0200] information/ConfigCompiler: Compiling config file: /var/lib/icinga2/api/packages/_api/devsv1.mydomain.com-1455584002-1/conf.d/downtimes/devsv1!Aircondition!devsv1.mydomain.com-1464410255-0.conf
[2016-05-28 06:37:35 +0200] information/ConfigItem: Committing config items
[2016-05-28 06:37:35 +0200] warning/ApplyRule: Apply rule 'satellite-host' (in /etc/icinga2/local.conf.d/satellite.conf: 29:1-29:41) for type 'Dependency' does not match anywhere!
[2016-05-28 06:37:35 +0200] warning/ApplyRule: Apply rule 'telnet-anchor' (in /etc/icinga2/local.conf.d/services.conf: 97:1-97:43) for type 'Dependency' does not match anywhere!
[2016-05-28 06:37:35 +0200] warning/ApplyRule: Apply rule 'ping4' (in /etc/icinga2/local.conf.d/services.conf: 37:1-37:21) for type 'Service' does not match anywhere!
[2016-05-28 06:37:35 +0200] warning/ApplyRule: Apply rule 'ping6' (in /etc/icinga2/local.conf.d/services.conf: 45:1-45:21) for type 'Service' does not match anywhere!
[2016-05-28 06:37:35 +0200] warning/ApplyRule: Apply rule 'users' (in /etc/icinga2/local.conf.d/services.conf: 237:1-237:21) for type 'Service' does not match anywhere!
[2016-05-28 06:37:35 +0200] warning/ApplyRule: Apply rule 'passivedummy' (in /etc/icinga2/local.conf.d/services.conf: 250:1-250:28) for type 'Service' does not match anywhere!
[2016-05-28 06:37:35 +0200] information/ConfigItem: Instantiated 1 Downtime.
[2016-05-28 06:37:35 +0200] information/ConfigItem: Triggering Start signal for config items
[2016-05-28 06:37:35 +0200] information/ConfigItem: Activated all objects.
[2016-05-28 06:37:35 +0200] notice/ApiListener: Relaying 'config::UpdateObject' message
[2016-05-28 06:37:35 +0200] notice/Downtime: Added downtime 'devsv1!Aircondition!devsv1.mydomain.com-1464410255-0' between '2016-05-28 06:36:59' and '2016-05-28 06:40:59'.
[2016-05-28 06:37:36 +0200] debug/IdoMysqlConnection: Query: INSERT INTO icinga_externalcommands (command_args, command_name, command_type, endpoint_object_id, entry_time, instance_id) VALUES ('devsv1;Aircondition;1464410219;1464410459;1;0;0;root;missing comment', 'SCHEDULE_SVC_DOWNTIME', '56', 424, FROM_UNIXTIME
(1464410255), 1)
[2016-05-28 06:37:36 +0200] debug/IdoMysqlConnection: Query: DELETE FROM icinga_scheduleddowntime WHERE instance_id = 1 AND internal_downtime_id = '3' AND object_id = 657
[2016-05-28 06:37:36 +0200] debug/IdoMysqlConnection: Query: UPDATE icinga_downtimehistory SET actual_end_time = FROM_UNIXTIME(1464410255),  actual_end_time_usec = '875483',  is_in_effect = '0',  was_cancelled = '0' WHERE entry_time = FROM_UNIXTIME(1464410255) AND instance_id = 1 AND internal_downtime_id = '3' AND object_id = 657
[2016-05-28 06:37:36 +0200] debug/IdoMysqlConnection: Query: UPDATE icinga_servicestatus SET scheduled_downtime_depth = '1' WHERE instance_id = 1 AND service_object_id = 657
[2016-05-28 06:37:36 +0200] debug/IdoMysqlConnection: Query: INSERT INTO icinga_scheduleddowntime (author_name, comment_data, downtime_type, duration, endpoint_object_id, entry_time, instance_id, internal_downtime_id, is_fixed, is_in_effect, name, object_id, scheduled_end_time, scheduled_start_time, was_started) VALUES ('root', 'missing comment', '1', '0', 424, FROM_UNIXTIME(1464410255), 1, '3', '1', '1', 'devsv1!Aircondition!devsv1.mydomain.com-1464410255-0', 657, FROM_UNIXTIME(1464410459), FROM_UNIXTIME(1464410219), '1')
[[2016-05-28 06:37:36 +0200] debug/IdoMysqlConnection: Query: UPDATE icinga_servicestatus SET scheduled_downtime_depth = '1' WHERE instance_id = 1 AND service_object_id = 657
[2016-05-28 06:37:36 +0200] debug/IdoMysqlConnection: Query: INSERT INTO icinga_downtimehistory (author_name, comment_data, downtime_type, duration, endpoint_object_id, entry_time, instance_id, internal_downtime_id, is_fixed, is_in_effect, name, object_id, scheduled_end_time, scheduled_start_time, was_started) VALUES ('root', 'missing comment', '1', '0', 424, FROM_UNIXTIME(1464410255), 1, '3', '1', '1', 'devsv1!Aircondition!devsv1.mydomain.com-1464410255-0', 657, FROM_UNIXTIME(1464410459), FROM_UNIXTIME(1464410219), '1')
[2016-05-28 06:37:36 +0200] debug/IdoMysqlConnection: Query: COMMIT

Notification template used:

template Notification "mail-service-notification" {
  command = "mail-service-notification"

  states = [ OK, Warning, Critical, Unknown ]
  types = [ Problem, Recovery, Custom,
            DowntimeStart,DowntimeEnd,
            FlappingStart, FlappingEnd ]

  times = {
    begin = 0m
    end = 90m
  }

  period = "24x7"
}

Notification command:

object NotificationCommand "mail-service-notification" {
  import "plugin-notification-command"

  command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]

  env = {
    NOTIFICATIONTYPE = "$notification.type$"
    SERVICEDESC = "$service.name$"
    HOSTALIAS = "$host.display_name$"
    HOSTADDRESS = "$address$"
    SERVICESTATE = "$service.state$"
    LONGDATETIME = "$icinga.long_date_time$"
    SERVICEOUTPUT = "$service.output$"
    NOTIFICATIONAUTHORNAME = "$notification.author$"
    NOTIFICATIONCOMMENT = "$notification.comment$"
    HOSTDISPLAYNAME = "$host.display_name$"
    SERVICEDISPLAYNAME = "$service.display_name$"
    USEREMAIL = "$user.email$"
  }
}

In the shell script, redirected the environment using "set > /tmp/nocomment.log".
Relevant parts of that:

HOSTADDRESS=127.0.0.1
HOSTALIAS=devsv1
HOSTDISPLAYNAME=devsv1
HOSTNAME=devsv1.mydomain.com
HOSTTYPE=x86_64
MACHTYPE=x86_64-redhat-linux-gnu
NOTIFICATIONAUTHORNAME=
NOTIFICATIONCOMMENT=
NOTIFICATIONTYPE=DOWNTIMESTART
OSTYPE=linux-gnu
SERVICEDESC=Aircondition
SERVICEDISPLAYNAME=Aircondition
SERVICEOUTPUT='CLIMA OK: Door=running, Cabinet=running'
SERVICESTATE=OK
USEREMAIL=dummy@mydomain.com

Changesets

2016-08-10 14:04:37 +00:00 by mfriedrich 42818ab

Fix downtime notification events and missing author/comment

fixes #12333
fixes #11851

Relations:

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented May 28, 2016

Updated by sru on 2016-05-28 05:22:22 +00:00

# icinga2 object list --type downtime | grep Object
Object 'DGS-1224-3!devsv1.mydomain.com-1464246941-0' of type 'Downtime':
Object 'Workstation02!load!devsv1.mydomain.com-1464276375-1' of type 'Downtime':

#Just created Downtime is missing after we received the notification email.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented May 31, 2016

Updated by mfriedrich on 2016-05-31 08:32:02 +00:00

  • Parent Id set to 11311
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Jun 1, 2016

Updated by dgoetz on 2016-06-01 14:49:15 +00:00

The comment you set by the external command is on the downtime object and not the notification object, but perhaps it is possible to map this internally for notification of type DowntimeStart and DowntimeEnd.

But I would not classify this as bug, because if I remember correct it was never handled so in Icinga 1 and also Icinga 2 before 2.4 (making downtimes an object) would not be capable to do so.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Aug 4, 2016

Updated by mfriedrich on 2016-08-04 15:53:50 +00:00

  • Tracker changed from Bug to Feature
  • Subject changed from _notification scripts get not passed the comment array _ to notification scripts cannot access the downtime comment string ($notification.comment$ macro)
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Aug 4, 2016

Updated by mfriedrich on 2016-08-04 15:54:14 +00:00

  • Parent Id deleted 11311

I agree, that's a feature. Feel free to submit a patch :)

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Aug 10, 2016

Updated by mfriedrich on 2016-08-10 13:00:35 +00:00

  • Tracker changed from Feature to Bug
  • Subject changed from notification scripts cannot access the downtime comment string ($notification.comment$ macro) to Downtime notifications do not pass author and comment
  • Status changed from New to Assigned
  • Assigned to set to mfriedrich
  • Target Version set to 2.5.0
  • Icinga Version set to 2

Hm, I stumbled over that file looking into #12333. I doubt that this is a runtime macro issue itself but the underlaying code which requests a notification does not pass the downtime author and comment. This renders the notification email incomplete.

Sorry for the issue update, this clearly is a bug. Will be fixed together with #12333.

@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Aug 10, 2016

Updated by mfriedrich on 2016-08-10 13:00:52 +00:00

  • Relates set to 12333
@icinga-migration

This comment has been minimized.

Copy link
Member Author

commented Aug 10, 2016

Updated by mfriedrich on 2016-08-10 14:05:06 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset 42818ab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.