Skip to content

Fix Ping check on non-English Windows - #3075

Merged
dkirov-dd merged 5 commits into
masterfrom
nasir.thomas/ping-utf-fix
Jul 29, 2026
Merged

Fix Ping check on non-English Windows#3075
dkirov-dd merged 5 commits into
masterfrom
nasir.thomas/ping-utf-fix

Conversation

@ddog-nasirthomas

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the Ping check on non-English Windows. Windows prints ping's output in the system language, and the check couldn't handle that:

  • On German (and other non-English) output it crashed with 'utf-8' codec can't decode byte 0x81.
  • Even when it didn't crash, it looked for the English word time to read the response time, which Windows translates (e.g. German Zeit) — so it reported reachable hosts as down.

The check now reads the output as UTF-8 and finds the response time by its ms unit instead of the English word, so it works in any language.

Motivation

Customers were seeing this error 'utf-8' codec can't decode byte 0x81 for customers that were utilizing non-english hosts.

Review checklist

  • PR has a meaningful title or PR has the no-changelog label attached
  • Feature or bugfix has tests
  • Git history is clean
  • If PR impacts documentation, docs team has been notified or an issue has been opened on the documentation repo
  • If this PR includes a log pipeline, please add a description describing the remappers and processors.

Additional Notes

Anything else we should know when reviewing?

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 23, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 80.00%
Overall Coverage: 89.09% (+3.81%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2b87752 | Docs | Datadog PR Page | Give us feedback!

@ddog-nasirthomas
ddog-nasirthomas marked this pull request as ready for review July 23, 2026 21:02

@dkirov-dd dkirov-dd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but I have one blocker

Comment thread ping/datadog_checks/ping/ping.py Outdated
lines = self._exec_ping(timeout, host)
regex = re.compile(r"time[<=]((\d|\.)*)")
# Match on the untranslated "ms" unit, since ping localizes the "time" label (e.g. German "Zeit=")
regex = re.compile(r"[<=]\s*([\d.]+)\s*ms")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request
I'd keep this only as a fallback, keeping the old regex as the primary one.
Unless we are absolutely certain that there is no way another time unit is returned by the command (e.g. s, µs, etc.)

@dkirov-dd
dkirov-dd enabled auto-merge July 29, 2026 15:31
@dkirov-dd
dkirov-dd added this pull request to the merge queue Jul 29, 2026
Merged via the queue into master with commit 41f3408 Jul 29, 2026
36 of 38 checks passed
@dkirov-dd
dkirov-dd deleted the nasir.thomas/ping-utf-fix branch July 29, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants