Converting Commands from Nagios


I have this Nagios notification command which I would like to convert to icinga:

This is the original command:

## 'notify-host-by-sms' command definition
define command {
        command_name    notify-host-by-sms
        command_line    /usr/bin/printf "%b" "**Nagios**\n\nNotification Type: \
                        $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: \
                        $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | \
                        /usr/local/bin/ $CONTACTEMAIL$ \
                        "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"

And this is my attempt to convert it but I fear I have gone wrong somewhere

## 'notify-host-by-sms' command definition
object NotificationComman "notify-host-by-sms" {
        command = [ /usr/local/bin/ $CONTACTEMAIL$ "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" ]
        env =  {  /usr/bin/printf "%b" "**Nagios**\n\n
                HOSTALIAS = "host.display_name$"
                STATE = "$HOSTSTATE$"
                HOSTADDRESS = "$HOSTADDRESS$"
                INFO = "$HOSTOUTPUT$"
                DATE/TIME = "$LONGDATETIME$"

Any help would be great

The problem I am having is working out which part is the Command = and which part is the env =


I’d suggest to use the official scripts we’ve created - they are located in /etc/icinga2/scripts and used inside the example configuration for Notification objects and commands. Look into them how they are done for email notifications, and then copy them for e.g. sms notifications as shell wrapper for calling the perl script (or modify just that).

printf shown in the way you’ve done it won’t work inside the DSL.