Using custom variables in Slack notification scripts

Hi Icinga2 Community

A few weeks ago I have built my own Slack Notification script.
Now I would like to extend my script, since now various Slack Channels are to be addressed.

Now I would like to integrate a variable which is located on the notification (Slack WebHook URL) into the script.

Can someone help me that I can call the custom variable in the script or pass the value to the script?

Attached you find my Slack Script. My goal is to use the custom variable to dynamically define line 4 with the Slack WebHook URL.
host-by-slack.txt (2.7 KB)
I am looking forward to your help :slight_smile:

Greetings Flavio

hi,

you are using getopts in your script. Why you don’t want to use this bash-function for your custom vars?

Hi @stevie-sy
Thanks for your reply.
Which bash-function for custom vars do you mean? Maybe there are other way’s to solve my problem :slight_smile:
I’m always open to new things.

Line 27 to 49. There is the function “getopts”. With this you can pass parameters to your script.
Take a look here: https://www.shellscript.sh/tips/getopts/

Can I pass custom parameters (variables) from Notification (not NotificationCommand)?

It works, I have added a new getopts parameter :slight_smile:

great, sounds good :ok_hand: