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 #11445] Allow strings in state/type filters #4061

Closed
icinga-migration opened this issue Mar 24, 2016 · 15 comments
Closed

[dev.icinga.com #11445] Allow strings in state/type filters #4061

icinga-migration opened this issue Mar 24, 2016 · 15 comments
Labels
area/configuration DSL, parser, compiler, error handling enhancement New feature or request
Milestone

Comments

@icinga-migration
Copy link

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

Created by mfriedrich on 2016-03-24 09:58:01 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2016-06-23 14:05:03 +00:00)
Target Version: 2.5.0
Last Update: 2016-06-24 12:19:07 +00:00 (in Redmine)

Backport?: Not yet backported
Include in Changelog: 1

That way we can pass strings in JSON requests from the API or the configuration attributes.

  • Notification/User states and types

Check where this might be necessary as well.

Attachments

Changesets

2016-06-21 15:40:48 +00:00 by mfriedrich 86699ec

WIP: Allow strings in state and type filters (config, API)

refs #11445

2016-06-22 14:10:54 +00:00 by mfriedrich 729202d

Allow strings in state and type filters (config, API)

refs #11445

2016-06-22 14:43:22 +00:00 by mfriedrich 7e3c9b2

Change DB IDO 'categories' attribute to Array notation

Example:
    categories = [ "DbCatProgramStatus", "DbCatState" ]

The old method with constants and OR is still supported but deprecated.

refs #11445
refs #12024

2016-06-23 12:52:45 +00:00 by mfriedrich 14fdb79

Allow strings in state and type filters (config, API)

fixes #11445

2016-06-23 12:55:01 +00:00 by mfriedrich 091274e

Change DB IDO 'categories' attribute to Array notation

Example:
    categories = [ "DbCatProgramStatus", "DbCatState" ]

The old method with constants and OR is still supported but deprecated.

refs #11445
fixes #12024

2016-06-24 12:17:24 +00:00 by mfriedrich ab4ba18

Allow strings in Dependency states filter

refs #11445

Relations:

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-03-24 09:58:39 +00:00

  • Relates set to 11434

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-16 08:20:11 +00:00

  • Status changed from New to Assigned
  • Assigned to set to mfriedrich

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-21 15:39:21 +00:00

Possible changes for tests:

  • API - /v1/objects/{notifications,users} - GET and PUT requests
  • Notification logging and matching the filters
  • DB IDO / Icinga Web 2 - contact filters for notifications

TODO

  • NotificationFilterToString replacement - Utility::NaturalJoin expects std::vector, we provide Array with Value types.

Test Config

object Host "11445-host" {
  check_command = "dummy"
}

object User "11445-user" {
  states = [ Up, Down, Critical, OK ]
  types = [ Problem, Recovery ]
}

apply Notification "11445-host-notification" to Host {
  command = "mail-host-notification"

  users = [ "11445-user" ]

  states = [ Up, Down ]
  types = [ "Problem", "Recovery" ]
  assign where host.name == "11445-host"
}

DB IDO User

-> there is a Bug in Icinga Web 2 which always adds "Downtime" to service notifications. So this is the backend.

*************************** 35. row ***************************
                   contact_id: 35
                  instance_id: 1
                  config_type: 1
            contact_object_id: 157073
                        alias: 11445-user
                email_address:
                pager_address:
    host_timeperiod_object_id: 0
 service_timeperiod_object_id: 0
   host_notifications_enabled: 1
service_notifications_enabled: 1
          can_submit_commands: 1
      notify_service_recovery: 1
       notify_service_warning: 0
       notify_service_unknown: 0
      notify_service_critical: 1
      notify_service_flapping: 0
      notify_service_downtime: 0
         notify_host_recovery: 1
             notify_host_down: 1
      notify_host_unreachable: 0
         notify_host_flapping: 0
         notify_host_downtime: 0
35 rows in set (0.00 sec)

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-21 15:39:41 +00:00

  • Description updated

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-21 15:40:23 +00:00

  • Documentation update

@icinga-migration
Copy link
Author

Updated by gbeutner on 2016-06-22 06:50:55 +00:00

TODO:

  • IDO categories

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-22 12:28:17 +00:00

  • Relates set to 12020

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-22 14:41:21 +00:00

I'm splitting the IDO categories into a new issue since it contains changes/deprecation notes.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-22 14:43:03 +00:00

  • Relates set to 12024

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-23 13:13:05 +00:00

  • File added icinga2_11445_api_notification.png
  • File added icinga2_11445_api_user.png

Documentation updates are targeted with #12020.

Both methods for state/type filters (constants or string values) provide the correct "states" and "types" array values inside the REST API.

notification
icinga2_11445_api_notification.png

user
icinga2_11445_api_user.png

The NotificationFilterToString() method has been fixed. Furthermore I've tested various state and filter types with notifications and backend logging. This unveiled a bug in Web2, fix sent upstream.

Notification and User with Acknowledgement filter

[2016-06-23 15:08:51 +0200] information/ExternalCommandListener: Executing external command: [1466687331] ACKNOWLEDGE_HOST_PROBLEM;11445-host;2;1;0;icingaadmin;dgdfgdfgd
[2016-06-23 15:08:51 +0200] notice/ExternalCommandProcessor: Setting acknowledgement for host '11445-host'
[2016-06-23 15:08:51 +0200] information/ConfigCompiler: Compiling config file: /usr/local/icinga2/var/lib/icinga2/api/packages/_api/mbmif.int.netways.de-1442309540-1/conf.d/comments/11445-host!mbmif.int.netways.de-1466687331-0.conf
[2016-06-23 15:08:51 +0200] debug/ConfigItem: Activating object '11445-host!mbmif.int.netways.de-1466687331-0' of type 'Comment'
[2016-06-23 15:08:51 +0200] debug/ApiListener: Sent update for object '11445-host!mbmif.int.netways.de-1466687331-0': {"config":"object Comment \"mbmif.int.netways.de-1466687331-0\" ignore_on_error {\n\tauthor = \"icingaadmin\"\n\tentry_time = 1466687331.266693\n\tentry_type = 4.000000\n\texpire_time = 0.000000\n\thost_name = \"11445-host\"\n\ttext = \"dgdfgdfgd\"\n\tversion = 1466687331.266935\n}\n","modified_attributes":{},"name":"11445-host!mbmif.int.netways.de-1466687331-0","original_attributes":[],"type":"Comment","version":1466687331.2669351101}
[2016-06-23 15:08:51 +0200] notice/Comment: Added comment '11445-host!mbmif.int.netways.de-1466687331-0'.
[2016-06-23 15:08:51 +0200] information/Checkable: Checking for configured notifications for object '11445-host'
[2016-06-23 15:08:51 +0200] debug/Checkable: Checkable '11445-host' has 1 notification(s).
[2016-06-23 15:08:51 +0200] notice/Notification: Attempting to send notifications for notification object '11445-host!11445-host-notification'.
[2016-06-23 15:08:51 +0200] information/Notification: Sending notification '11445-host!11445-host-notification' for user '11445-user'
[2016-06-23 15:08:51 +0200] debug/DbEvents: add notification history for '11445-host'
[2016-06-23 15:08:51 +0200] debug/DbEvents: add contact notification history for service '11445-host' and user '11445-user'.
[2016-06-23 15:08:51 +0200] debug/DbEvents: add acknowledgement for '11445-host'
[2016-06-23 15:08:51 +0200] debug/DbEvents: add acknowledgement history for '11445-host'
[2016-06-23 15:08:51 +0200] debug/DbEvents: add log entry history for '11445-host'
[2016-06-23 15:08:51 +0200] information/Notification: Completed sending notification '11445-host!11445-host-notification' for checkable '11445-host' and user '11445-user'.

User without Acknowledgement filter:

[2016-06-23 15:01:04 +0200] information/ExternalCommandListener: Executing external command: [1466686864] ACKNOWLEDGE_HOST_PROBLEM;11445-host;2;1;0;icingaadmin;ffgdfgd
[2016-06-23 15:01:04 +0200] notice/ExternalCommandProcessor: Setting acknowledgement for host '11445-host'
[2016-06-23 15:01:04 +0200] information/ConfigCompiler: Compiling config file: /usr/local/icinga2/var/lib/icinga2/api/packages/_api/mbmif.int.netways.de-1442309540-1/conf.d/comments/11445-host!mbmif.int.netways.de-1466686864-0.conf
[2016-06-23 15:01:04 +0200] debug/ConfigItem: Activating object '11445-host!mbmif.int.netways.de-1466686864-0' of type 'Comment'
[2016-06-23 15:01:04 +0200] debug/ApiListener: Sent update for object '11445-host!mbmif.int.netways.de-1466686864-0': {"config":"object Comment \"mbmif.int.netways.de-1466686864-0\" ignore_on_error {\n\tauthor = \"icingaadmin\"\n\tentry_time = 1466686864.134508\n\tentry_type = 4.000000\n\texpire_time = 0.000000\n\thost_name = \"11445-host\"\n\ttext = \"ffgdfgd\"\n\tversion = 1466686864.135161\n}\n","modified_attributes":{},"name":"11445-host!mbmif.int.netways.de-1466686864-0","original_attributes":[],"type":"Comment","version":1466686864.135160923}
[2016-06-23 15:01:04 +0200] notice/Comment: Added comment '11445-host!mbmif.int.netways.de-1466686864-0'.
[2016-06-23 15:01:04 +0200] information/Checkable: Checking for configured notifications for object '11445-host'
[2016-06-23 15:01:04 +0200] debug/Checkable: Checkable '11445-host' has 1 notification(s).
[2016-06-23 15:01:04 +0200] notice/Notification: Attempting to send notifications for notification object '11445-host!11445-host-notification'.
[2016-06-23 15:01:04 +0200] notice/Notification: Not sending notifications for notification object '11445-host!11445-host-notification and user '11445-user': type 'Acknowledgement' does not match type filter: Problem and Recovery.
[2016-06-23 15:01:04 +0200] notice/Notification: Notification filters for user '11445-user' not matched. Not sending notification.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-23 14:00:37 +00:00

  • File added icinga2_11445_object_list_notification.png
  • File added icinga2_11445_object_list_user.png

icinga2 object list

icinga2_11445_object_list_notification.png

icinga2_11445_object_list_user.png

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-23 14:05:03 +00:00

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

Applied in changeset 14fdb79.

@icinga-migration
Copy link
Author

Updated by tobiasvdk on 2016-06-24 11:57:05 +00:00

For a service dependency I get the following:

critical/config: Error: Validation failed for object 'XXX!service-to-nrpe' of type 'Dependency'; Attribute 'states': Array element 'OK' of type 'String' is not valid here; expected type 'Number'.
Location: in /var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf: 4:5-4:19
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(2):     parent_service_name = "nrpe"
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(3):
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(4):     states = [ OK ]
                                                                                                                 ^^^^^^^^^^^^^^^
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(5):     disable_checks = true
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(6):     disable_notifications = true

I also tried states = [ "OK" ] with the same result

critical/config: Error: Validation failed for object 'vpn01.pb.local!processes-d-state!service-to-nrpe' of type 'Dependency'; Attribute 'states': Array element 'OK' of type 'String' is not valid here; expected type 'Number'.
Location: in /var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf: 4:5-4:21
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(2):     parent_service_name = "nrpe"
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(3): 
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(4):     states = [ "OK" ]
                                                                                                                 ^^^^^^^^^^^^^^^^^
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(5):     disable_checks = true
/var/lib/icinga2/api/zones/shared/_etc/dependencies/to-nrpe.conf(6):     disable_notifications = true

Config:

apply Dependency "service-to-nrpe" to Service {
    parent_service_name = "nrpe"

    states = [ OK ]
    disable_checks = true
    disable_notifications = true
    ignore_soft_states = false

    assign where match("*nrpe", service.check_command)
    ignore where service.name == "nrpe"
}

$ sudo icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: r2.4.10-502-g1451a0e)

Copyright (c) 2012-2016 Icinga Development Team (https://www.icinga.org/)
License GPLv2+: GNU GPL version 2 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Application information:
  Installation root: /usr
  Sysconf directory: /etc
  Run directory: /run
  Local state directory: /var
  Package data directory: /usr/share/icinga2
  State path: /var/lib/icinga2/icinga2.state
  Modified attributes path: /var/lib/icinga2/modified-attributes.conf
  Objects path: /var/cache/icinga2/icinga2.debug
  Vars path: /var/cache/icinga2/icinga2.vars
  PID path: /run/icinga2/icinga2.pid

System information:
  Platform: Debian GNU/Linux
  Platform version: 8 (jessie)
  Kernel: Linux
  Kernel version: 4.5.0-0.bpo.2-amd64
  Architecture: x86_64

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-24 12:18:01 +00:00

Shit. Many thanks!

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2016-06-24 12:19:07 +00:00

Fixed in git master.

Updated test config.

object Host "11445-host" {
  check_command = "dummy"
  max_check_attempts = 1
  check_interval = 5m
  retry_interval = 4m
}

object User "11445-user" {
  states = [ Up, Down, Critical, OK ]
  types = [ Problem, Recovery, Acknowledgement ]
  //types = [ Problem, Recovery ]
}

apply Notification "11445-host-notification" to Host {
  command = "mail-host-notification"

  users = [ "11445-user" ]

  states = [ Up, Down ]
  types = [ "Problem", "Recovery", "Acknowledgement" ]
  //types = [ Problem, Recovery, Acknowledgement ]
  assign where host.name == "11445-host"
}


object Host "11445-host-parent" {
  check_command = "dummy"
}

apply Dependency "11445" to Host {
  parent_host_name = "11445-host-parent"
  states = [ "Up" ]
  assign where host.name == "11445-host"
}

@icinga-migration icinga-migration added enhancement New feature or request area/configuration DSL, parser, compiler, error handling labels Jan 17, 2017
@icinga-migration icinga-migration added this to the 2.5.0 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration DSL, parser, compiler, error handling enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant