How to add custom vars while creating a command

  • Director version (System - About): 1.7.2
  • Icinga Web 2 version and modules (System - About): 2.8.2
  • Icinga 2 version (icinga2 --version):2.12.4-1
  • Operating System and version: RHEL 8.4 4.18.0-305.19.1.el8_4.x86_64
  • Webserver, PHP versions: Apache 2.4.37-39 , PHP 7.2.24

I am trying to create a couple of new notification commands (to be exact I am trying to add the PagerDuty commands so I can use them the same way as mail-host-notification and mail-service-notification under Icinga Director. This is the conf file: https://raw.githubusercontent.com/PagerDuty/pdagent-integrations/master/conf.d/pagerduty-icinga2.conf).

If I were to create a new command under Icinga Director, how do I add vars similar to vars.notification_address, vars.notification_address6, etc defined in mail-host-notification?

In the PagerDuty case, how could I get
vars.f_args = [
“SERVICEDESC=$service.name$”,
“SERVICEDISPLAYNAME=$service.display_name$”,
“HOSTNAME=$host.name$”,
“HOSTSTATE=$host.state$”,
“HOSTDISPLAYNAME=$host.display_name$”,
“SERVICESTATE=$service.state$”,
“SERVICEPROBLEMID=$service.state_id$”,
“SERVICEOUTPUT=$service.output$”
]

added to the command?

create a datafield in icingaweb2/director/define data field → name =f_args type=array
add this data field as a field to the command
click on command you will see the field f_args
put in each line without the " "
save
the preview will show you something like this:

zones.d/director-global/commands.conf
object CheckCommand "test" {
    import "plugin-check-command"
    command = [ PluginDir + "/dummy" ]
    vars.f_args = [ "SERVICEDESC=$service.name$", "HOSTSTATE=$host.state$" ]
}