Environments for all check commands

Hi,

I’d like to set an environment variable (LANG=“en_US.UTF-8”) for all check commands in order to handle non ascii characters within with python2 checks.

There is the import “plugin-check-command” statement in all of my custom commands, so I would except it makes sense to put it in there. Unfortunately I cannot find the configuration for plugin-check-command.

Is there a recommended may to set environment variables for all commands?

System Information

icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: 2.13.2-1)

Copyright (c) 2012-2022 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later https://gnu.org/licenses/gpl2.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

System information:
Platform: Red Hat Enterprise Linux Server
Platform version: 7.9 (Maipo)
Kernel: Linux
Kernel version: 3.10.0-1160.53.1.el7.x86_64
Architecture: x86_64

Build information:
Compiler: GNU 4.8.5
Build host: runner-hh8q3bz2-project-322-concurrent-0
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017

Application information:

General paths:
Config directory: /etc/icinga2
Data directory: /var/lib/icinga2
Log directory: /var/log/icinga2
Cache directory: /var/cache/icinga2
Spool directory: /var/spool/icinga2
Run directory: /run/icinga2

Old paths (deprecated):
Installation root: /usr
Sysconf directory: /etc
Run directory (base): /run
Local state directory: /var

Internal paths:
Package data directory: /usr/share/icinga2
State path: /var/lib/icinga2/icinga2.state
Modified attributes path: /var/lib/icinga2/modified-attributes.conf
Objects path: /var/cache/icinga2/icinga2.debug
Vars path: /var/cache/icinga2/icinga2.vars
PID path: /run/icinga2/icinga2.pid

icinga2 feature list
Disabled features: compatlog debuglog elasticsearch gelf icingadb influxdb influxdb2 livestatus opentsdb perfdata statusdata syslog
Enabled features: api checker command graphite ido-pgsql mainlog notificatio

Icinga is running as standalone server (no satellites, no agents)

template CheckCommand default {
  env.LANG = "en_US.UTF-8"
}

Hi,

thank you. It works.

For my specific use case I had to use:

template CheckCommand “utf8_python” default {
env.PYTHONIOENCODING = “UTF-8”
}