Icinga Web 2 2.7.0: "icingacli migrate dashboard sections --verbose" throws error

Hello there :slight_smile:

I updated to Icinga Web 2 2.7.0.
I previously had to rename some entries in the dashboard.ini files due to the translation issue.

When I now run the command line from the upgrading docs I get an error:

icingacli migrate dashboard sections --verbose
Migrating dashboard config: /etc/icingaweb2/dashboards/username/dashboard.ini
ERROR: Icinga\Exception\IcingaException in /usr/share/php/Icinga/Util/Translator.php:181 with message: Cannot set locale 'ar_SA' for category 'LC_ALL'

Locales look like this:

# locale
LANG=de_DE.UTF-8
LANGUAGE=
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

Tried setting the LC_ALL variable to de_DE.UTF-8 with export LC_ALL="de_DE.UTF-8" but that didn’t help.

Contents of the dashboard.ini

# cat /etc/icingaweb2/dashboards/username/dashboard.ini
[Aktuelle Vorfälle.Checks xyz-Dienste]
url = "monitoring/list/services?(service=%2ABusiness%2A|service_display_name=%2ABusiness%2A)"
title = "Checks xyz-Dienste"

[xyz-Dienste]
title = "xyz-Dienste"

[xyz-Dienste.Internet-FR]
url = "businessprocess/process/show?config=Internet%20Connectivity%20Dort"
title = "Internet-FR"

[xyz-Dienste.E-Mail]
url = "businessprocess/process/show?config=E-Mail"
title = "E-Mail"

[xyz-Dienste.Citrix]
url = "businessprocess/process/show?config=Citrix"
title = "Citrix"

[xyz-Dienste.LAN-FR]
url = "businessprocess/process/show?config=Core%20Infrastruktur%20Dort"
title = "LAN-FR"

[xyz-Dienste.LAN-OL]
url = "businessprocess/process/show?config=Core%20Infrastruktur%20Hier"
title = "LAN-OL"

[xyz-Dienste.Internet-OL]
url = "businessprocess/process/show?config=Internet%20Connectivity%20Hier"
title = "Internet-OL"

[xyz-Dienste.Serverinfrastruktur-FR]
url = "businessprocess/process/show?config=Server%20Infrastruktur%20Dort"
title = "Serverinfrastruktur-FR"

[xyz-Dienste.Serverinfrastruktur-OL]
url = "businessprocess/process/show?config=Server%20Infrastruktur%20Hier"
title = "Serverinfrastruktur-OL"

[xyz-Dienste.SQl-Server]
url = "businessprocess/process/show?config=SQL%20Server"
title = "SQl-Server"

[xyz-Dienste.Ticketsystem]
url = "businessprocess/process/show?config=Ticket%20System"
title = "Ticketsystem"

[xyz-Dienste.Telefonie]
url = "businessprocess/process/show?config=Telefonie"
title = "Telefonie"

[xyz-Dienste.VPN-Verbindung xyz-OPS für Kunden-VPN]
url = "businessprocess/process/show?config=VPNs%20Dort"
title = "VPN-Verbindung xyz-OPS für Kunden-VPN"

[xyz-Dienste.Support-xyz-OPS]
url = "businessprocess/process/show?config=Support-Umgebung%20xyz-OPS"
title = "Support-xyz-OPS"

[xyz-Dienste.Serverinfrastruktur-UC]
url = "businessprocess/process/show?config=Server%20Infrastruktur%20UC"
title = "Serverinfrastruktur-UC"

The “problematic” script part is:

/**
     * Set the locale to use
     *
     * @param   string  $localeName     The name of the locale to use
     *
     * @throws  IcingaException         In case the locale's name is invalid
     */
    public static function setupLocale($localeName)
    {
        if (setlocale(LC_ALL, $localeName . '.UTF-8') === false && setlocale(LC_ALL, $localeName) === false) {
            setlocale(LC_ALL, 'C'); // C == "use whatever is hardcoded"
            if ($localeName !== self::DEFAULT_LOCALE) {
                throw new IcingaException(
                    'Cannot set locale \'%s\' for category \'LC_ALL\'',
                    $localeName
                );
            }
        } else {
            $locale = setlocale(LC_ALL, 0);
            putenv('LC_ALL=' . $locale); // Failsafe, Win and Unix
            putenv('LANG=' . $locale); // Windows fix, untested

            // https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html
            putenv('LANGUAGE=' . $localeName . ':' . getenv('LANGUAGE'));
        }
    }

Anyone has an idea what the problem is?

:wave:

Ouch. Seems that the command requires every single locale installed Icinga Web 2 supports. Try this:

1 Like

Thanks, that did fix the error!

Though the dashboard is not really useable afterwards :smiley:
I suspect this function is just usable for the default dashboards?

Outcome:

[Current Incidents.Host Problems]
url = "monitoring/list/hosts?host_problem=1&sort=host_severity"
title = "Host-Probleme"
disabled = "1"

[Current Incidents.Recently Recovered Services]
url = "monitoring/list/services?service_state=0&limit=10&sort=service_last_state_change&dir=desc"
title = "Vor kurzem erholte Services"
disabled = "1"

[Muted]
url = "businessprocess/process/show?config=OPS-VPN-OL"
title = "VPN-Verbindung xyz-OPS OL"

What exactly is wrong here? Seems fine to me, sections are english, titles are not.

The listings I added manually to the dashboard are gone. I have a dashboard.ini I was trying to convert in the first post.
And the dashboard only consist of the Service problems listing. No Host problem, no recently recovered services.

:face_with_raised_eyebrow: :thinking: :worried: :anguished: :scream: :weary: :expressionless: :angry: :face_with_symbols_over_mouth: :triumph: :unamused: :disappointed_relieved:

^ Me when reading your reply, glancing at the code and realizing it’s messing up user dashboards.

Updated the PR. I hope everyone has either a staging environment for updates, a proper backup solution or doesn’t live near Nuremberg. :roll_eyes:

2 Likes

:rofl::sweat_smile:

No worries, this time I was intelligent enough do backup the dashboards first :wink:

The update PR works like a charm, looks like before now :slight_smile: