Repository navigation
Fix Ping check on Linux with a non-English locale by running ping with LC_ALL=C - #3306
Open
JunShibata-Datadog wants to merge 2 commits into
Open
JunShibata-Datadog wants to merge 2 commits into
JunShibata-Datadog wants to merge 2 commits into
Conversation
…h LC_ALL=C
When the Agent runs with a non-English locale (for example LANG=ja_JP.UTF-8,
which systemd passes to the service from /etc/locale.conf), ping translates
its output, including the "ms" unit ("時間=0.019ミリ秒"). Neither response-time
regex matches, so the check fails with "No response time found" and reports
reachable hosts as down.
Run ping with LC_ALL=C on non-Windows platforms. The Agent replaces the whole
child environment when env is given, so copy os.environ first; the Agent's
own environment is not modified.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JunShibata-Datadog
requested review from
a team and
jstanton617
as code owners
November 26, 2026 07:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Validation ReportAll 11 validations passed. Show details
|
janine-c
approved these changes
Nov 26, 2026
janine-c
left a comment
Contributor
There was a problem hiding this comment.
Looks awesome, just some minor writing suggestions (feel free to ignore if I introduced any inaccuracies!)
|
|
||
| ***Fixed***: | ||
|
|
||
| * Fix the Ping check reporting reachable hosts as down on Linux and macOS when the Agent runs with a non-English locale (for example ``LANG=ja_JP.UTF-8``). ping translated its output, including the ``ms`` unit, so no response time was found. The check now runs ping with ``LC_ALL=C`` ([#3306](https://github.com/DataDog/integrations-extras/pull/3306)). |
Contributor
There was a problem hiding this comment.
Suggested change
| * Fix the Ping check reporting reachable hosts as down on Linux and macOS when the Agent runs with a non-English locale (for example ``LANG=ja_JP.UTF-8``). ping translated its output, including the ``ms`` unit, so no response time was found. The check now runs ping with ``LC_ALL=C`` ([#3306](https://github.com/DataDog/integrations-extras/pull/3306)). | |
| * Fix the ping check so it reports reachable hosts as down on Linux and macOS when the Agent runs with a non-English locale (for example, ``LANG=ja_JP.UTF-8``). It translated the output, including the ``ms`` unit, so it didn't properly report a response time. The check now runs ping with ``LC_ALL=C`` ([#3306](https://github.com/DataDog/integrations-extras/pull/3306)). |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Runs
pingwithLC_ALL=Con Linux and macOS so its output is always untranslated.get_subprocess_outputis now given anenv. The Agent replaces the child's whole environment whenenvis set (cmd.Env = subprocessEnvinpkg/collector/python/util.go), so the check copiesos.environand only overridesLC_ALL. The Agent's own environment is not modified. The Windows path (_exec_ping_windows) is unchanged.Motivation
When the Agent runs with a non-English locale, ping (iputils) translates its output, including the
msunit. For example, withLANG=ja_JP.UTF-8(systemd passes the system locale from/etc/locale.conftodatadog-agent.service):Neither
time[<=]...nor the[<=]\s*([\d.]+)\s*msfallback added in #3075 matches, so the check raisesNo response time foundand reports a reachable host as CRITICAL. The fallback works on Windows because Windows keepsmsuntranslated; Linux does not.Review checklist
no-changeloglabel attachedAdditional Notes
test_unix_ping_runs_with_c_locale. It checks that ping getsLC_ALL=Cwith the rest of the environment kept, and that the Agent's environment is unchanged. It fails without the fix (KeyError: 'env').amazonlinux:2023container withglibc-langpack-jaandLANG=ja_JP.UTF-8:test_integration_response_timefails without the fix and passes with it.🤖 Generated with Claude Code