jbennett wrote:I think you're still trying to help me with the method that hhlodge suggested, which isn't what I'm trying to do in this instance.
I was going to take you down the road of creating new notification handlers, but it looks like you will be using the xi handler and notification templates - which do not use notify-*-by-email handlers, but instead uses the xi_*_notification_handlers.
You will need to include/remap the $SERVICENOTES$ macro in the xi_service_notification_handler command. Add the following to the end:
And then you can use the %servicenotes% macro in the template.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
On an aside, this exercise has gotten me to pursue something I've wanted Nagios to do for years and that's to have all the recipients of a notification be in the To: header so people can "reply all" to issues, yet each notification from Nagios only go the one intended recipient ($CONTACTEMAIL) so they don't get multiple messages and their Respond URL is unique. I now have this working well by constructing the message myself with a similar called script I suggested here, looping through the contacts in $NOTIFICATIONRECIPIENTS$ and then piping it all to sendmail/Postfix directly. My last challenge is to parse the config file to get the email field - which goes in the To: header - mapped to the contact_name. I can post the final notification handler and script when I have that working if anyone is interested.
I am running into trouble passing arguments from Nagios to a Korn shell script. Can someone shed some light on these PROBLEM[0-9] values? Is it some sort of limit?
I believe (someone correct me if I am wrong) ksh maxes out at 10 passed parameters ($0-$9). In bash, you can wrap the parameter number in curly braces for parameters over 10 - ie. ${13}.
I think you may have to use "shift" to get more parameters in ksh.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
# cat args.ksh
#!/bin/ksh
echo "Arg1 is: $1"
echo "Arg2 is: $2"
echo "Arg3 is: $3"
echo "Arg4 is: $4"
echo "Arg5 is: $5"
echo "Arg6 is: $6"
echo "Arg7 is: $7"
echo "Arg8 is: $8"
echo "Arg9 is: $9"
echo "Arg10 is: $10"
echo "Arg11 is: $11"
echo "Arg12 is: $12"
echo "Arg13 is: $13"
echo "Arg14 is: $14"
# ./args.ksh 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Arg1 is: 1
Arg2 is: 2
Arg3 is: 3
Arg4 is: 4
Arg5 is: 5
Arg6 is: 6
Arg7 is: 7
Arg8 is: 8
Arg9 is: 9
Arg10 is: 10
Arg11 is: 11
Arg12 is: 12
Arg13 is: 13
Arg14 is: 14
Fair enough. How are you populating the macros in your testing? Using nagios env vars, or did you just hand export these env vars?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
# ./args.ksh "one word" "two more words" "how many here"
Arg1 is: one word
Arg2 is: two more words
Arg3 is: how many here
Arg4 is:
Arg5 is:
Arg6 is:
Arg7 is:
Arg8 is:
Arg9 is:
Arg10 is: one word0
Arg11 is: one word1
Arg12 is: one word2
Arg13 is: one word3
Arg14 is: one word4
I have this working well now but cannot get $SERVICEACTIONURL$ macro to expand. All documents I see say it should be available in a service notification. ??? Here's the command.
A few questions:
1) I presume that you have defined the $SERVICEACTIONURL$ on the object?
2) Could be a shell escaping issue, can you try setting the macro to just alphanumerical characters for a test?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
jbennett wrote:I think you're still trying to help me with the method that hhlodge suggested, which isn't what I'm trying to do in this instance.
I was going to take you down the road of creating new notification handlers, but it looks like you will be using the xi handler and notification templates - which do not use notify-*-by-email handlers, but instead uses the xi_*_notification_handlers.
You will need to include/remap the $SERVICENOTES$ macro in the xi_service_notification_handler command. Add the following to the end: