Page 1 of 1

Macros in host notifications are replaced by $

Posted: Sat Aug 10, 2013 7:45 am
by robinhood
I am using Nagios Core 3.5.0 with Gammu, when I recieving SMS alert there are some $ signs, is there anybody experienced this issue?
--------------------------------------
***Nagios***
Notification Type: RECOVERY
Service: $
Host: Gateway
Address: 192.168.1.1
State: $
Additional Info: $
---------------------------------------
my config for SMS alert is as below:
-----
# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%b" "*** Nagios ***\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDate/Time: $LONGDATETIME$" | /usr/local/bin/gammu --sendsms TEXT $CONTACTPAGER$
}
# 'notify-service-by-sms' command definition
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "*** Nagios ***\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nDate/Time: $LONGDATETIME$\nAdditional Info: $SERVICEOUTPUT$" | /usr/local/bin/gammu --sendsms TEXT $CONTACTPAGER$
}
-----------------------------
Debug log:
----------------------------------
[1375820667.019202] [2048.1] [pid=22474] **** BEGIN MACRO PROCESSING ***********
[1375820667.019211] [2048.1] [pid=22474] Processing: '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nDate/Time: $LONGDATETIME$\nAdditional Info: $SERVICEOUTPUT$" | /usr/local/bin/gammu --sendsms TEXT $CONTACTPAGER$'
[1375820667.019221] [2048.2] [pid=22474] Processing part: '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: '
[1375820667.019231] [2048.2] [pid=22474] Not currently in macro. Running output (57): '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: '
[1375820667.019240] [2048.2] [pid=22474] Processing part: 'NOTIFICATIONTYPE'
[1375820667.019260] [2048.2] [pid=22474] macros[29] (NOTIFICATIONTYPE) match.
[1375820667.019276] [2048.2] [pid=22474] Processed 'NOTIFICATIONTYPE', Clean Options: 0, Free: 0
[1375820667.019286] [2048.2] [pid=22474] Processed 'NOTIFICATIONTYPE', Clean Options: 0, Free: 0
[1375820667.019295] [2048.2] [pid=22474] Cleaning options: global=3, local=0, effective=3
[1375820667.019306] [2048.2] [pid=22474] Cleaned macro. Running output (64): '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: PROBLEM'
[1375820667.019316] [2048.2] [pid=22474] Just finished macro. Running output (64): '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: PROBLEM'
[1375820667.019325] [2048.2] [pid=22474] Processing part: '\nService: '
[1375820667.019342] [2048.2] [pid=22474] Not currently in macro. Running output (75): '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: PROBLEM\nService: '
[1375820667.019352] [2048.2] [pid=22474] Processing part: 'SERVICEDESC'
[1375820667.019362] [2048.2] [pid=22474] macros[3] (SERVICEDESC) match.
[1375820667.019372] [2048.2] [pid=22474] Processed 'SERVICEDESC', Clean Options: 0, Free: 1
[1375820667.019381] [2048.0] [pid=22474] WARNING: An error occurred processing macro 'SERVICEDESC'!
[1375820667.019390] [2048.2] [pid=22474] Non-macro. Running output (75): '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: PROBLEM\nService: '
[1375820667.019400] [2048.2] [pid=22474] Processing part: '\nHost: '
[1375820667.019410] [2048.2] [pid=22474] Not currently in macro. Running output (96): '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: PROBLEM\nService: $SERVICEDESC$\nHost: '
[1375820667.019419] [2048.2] [pid=22474] Processing part: 'HOSTALIAS'
[1375820667.019429] [2048.2] [pid=22474] macros[1] (HOSTALIAS) match.
[1375820667.019440] [2048.2] [pid=22474] Processed 'HOSTALIAS', Clean Options: 0, Free: 1
[1375820667.019449] [2048.2] [pid=22474] Processed 'HOSTALIAS', Clean Options: 0, Free: 1
[1375820667.019458] [2048.2] [pid=22474] Cleaning options: global=3, local=0, effective=3
[1375820667.019469] [2048.2] [pid=22474] Cleaned macro. Running output (104): '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: PROBLEM\nService: $SERVICEDESC$\nHost: Wireless'
[1375820667.019478] [2048.2] [pid=22474] Just finished macro. Running output (104): '/usr/bin/printf "%b" "*** Nagios ***\nNotification Type: PROBLEM\nService: $SERVICEDESC$\nHost: Wireless'
[1375820667.019488] [2048.2] [pid=22474] Processing part: '\nAddress: '
---------------------------------------

Re: Macros in host notifications are replaced by $

Posted: Mon Aug 12, 2013 9:42 am
by robinhood
I have fixed this issue as below:
Wrong config:
------------------------------------
define contact{
name generic-contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-sms
,notify-service-by-email
host_notification_commands notify-service-by-sms
,notify-host-by-email
register 0
}
--------------------------------------------------------------------

Correct config:
---------------------------------------------------------------------------------------
Code:
define contact{
name generic-contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-sms
,notify-service-by-email
host_notification_commands notify-host-by-sms
,notify-host-by-email
register 0
}

Re: Macros in host notifications are replaced by $

Posted: Mon Aug 12, 2013 9:46 am
by slansing
Ah, that would do the trick. Thanks for letting us know how you resolved this.