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 #12941] Append arguments in command templates/objects #499

Closed
icinga-migration opened this issue Oct 18, 2016 · 6 comments
Closed
Labels
Milestone

Comments

@icinga-migration
Copy link

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

Created by leeclemens on 2016-10-18 17:14:51 +00:00

Assignee: tgelf
Status: Resolved (closed on 2016-11-15 17:00:03 +00:00)
Target Version: 1.3.0
Last Update: 2016-11-15 17:00:03 +00:00 (in Redmine)


I specifically used NotificationCommand templates and an object, but the limitation may apply to other Command types.

When creating multiple templates, the arguments are replaced (as Markus Frosch pointed out).
There doesn't appear to be a way in Director to append them, although they import each other properly.

Example:

template NotificationCommand "Email Template" {
    import "plugin-notification-command"
    arguments = {
        "--host-address" = {
            required = true
            value = "$host.address$"
        }
        "--host-display-name" = {
            required = true
            value = "$host.display_name$"
        }
        "--host-name" = {
            required = true
            value = "$host.name$"
        }
        "--notification-author" = {
            required = true
            value = "$notification.author$"
        }
        "--notification-comment" = {
            required = true
            value = "$notification.comment$"
        }
        "--notification-type" = {
            required = true
            value = "$notification.type$"
        }
        "--user-email" = {
            required = true
            value = "$user.email$"
        }
    }
}



template NotificationCommand "Email Host Template" {
    import "plugin-notification-command"
    import "Email Template"

    command = [ "/etc/icinga2/scripts/mail-host.py" ]
    arguments = {
        "--host-output" = {
            required = true
            value = "$host.output$"
        }
        "--host-state" = {
            required = true
            value = "$host.state$"
        }
    }
}


object NotificationCommand "Standard Email Host" {
    import "plugin-notification-command"
    import "Email Host Template"

}

[2016-10-17 12:38:02 -0400] warning/PluginNotificationTask: Notification command for object 'hostname.example.com' (PID: 8596, arguments: '/etc/icinga2/scripts/mail-host.py' '--host-output' 'PING CRITICAL - Packet loss = 100%' '--host-state' 'DOWN') terminated with exit code 2, output: usage: mail-host.py [-h] --host-name HOST_NAME --host-address HOST_ADDRESS 

Markus' response:

What you should do: ( += )

    arguments += {
        "--host-output" = {
            required = true
            value = "$host.output$"
        }
        "--host-state" = {
            required = true
            value = "$host.state$"
        }
    }

It may be safe to always use += instead of = ? But I haven't tested it (or there could be other issues caused).
Maybe a new option on the Argument tab(s) to "Append"?

References:
https://lists.icinga.org/pipermail/icinga-users/2016-October/011413.html
https://lists.icinga.org/pipermail/icinga-users/2016-October/011415.html

Changesets

2016-11-15 16:57:02 +00:00 by tgelf d5131f7

Arguments: always render += instead of =

This allows to extend existing arguments

fixes #12941

Relations:

@icinga-migration
Copy link
Author

Updated by mfrosch on 2016-10-25 09:14:59 +00:00

We should probably always do:

arguments += {
}

It will overwrite any pre-existing argument with the same name

@icinga-migration
Copy link
Author

Updated by mfrosch on 2016-10-25 09:19:24 +00:00

  • Relates set to 12978

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-10-25 11:48:43 +00:00

While fixing all variants of this would add quite some noise to GUI and code, what about rendering arguments += always when rendering a command object? Would satisfy most needs I guess. There would initially be no -=, but that's something one can easily work around.

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-10-25 11:52:09 +00:00

mfrosch wrote:

We should probably always do:

[...]

It will overwrite any pre-existing argument with the same name

:D Didn't read this, sorry :p Ok, we'll go for this. For all commands of object_type = object and at least one import.

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-11-15 16:56:45 +00:00

  • Status changed from New to Assigned
  • Assigned to set to tgelf
  • Target Version set to 1.3.0

@icinga-migration
Copy link
Author

Updated by tgelf on 2016-11-15 17:00:03 +00:00

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

Applied in changeset d5131f7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant