If you want to use environmental variables in you bash (or python) script makes sure
enable_environment_macros=1
in etc/nagios/cfg
Otherwise you can pass it as an argument on the command line.