Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please enforce a LANG as needed for printf "%.0f\n" "$RAMGB" in storage-benchmark #80

Closed
pcfe opened this issue Jul 11, 2022 · 4 comments

Comments

@pcfe
Copy link

pcfe commented Jul 11, 2022

this bit in storage-benchmark:

RAMGB=`grep MemTotal /proc/meminfo  | awk '{s+=$2} END {print s / 1000000}'`
# Convert to integer
RAMGB=`printf "%.0f\n" "$RAMGB"`

does not work with some LANG setings (e.g. en_DK.UTF-8)

example:

[root@satellite ~]# echo $LANG
en_DK.UTF-8
[root@satellite ~]# ./storage-benchmark /var/lib/pulp/fio-testing/
./storage-benchmark: line 79: printf: 26.48: invalid number
[root@satellite ~]# LANG=en_US.UTF-8 ./storage-benchmark /var/lib/pulp/fio-testing/
This test creates a test file that is double (2X) the size of this system's
RAM in GB. This benchmark will create a test file of size.. 

52 Gigabytes

.. in the: [/var/lib/pulp/fio-testing//storage-benchmark] location. This is to ensure that the test utilizes
a combination of cached and non-cached data during the test.

**** WARNING! Please verify you have enough free space to create a 52 GB
file in this location before proceeding. 

Do you wish to proceed? (Y/N) 
@andreamtp
Copy link

Same problem here: pushed PR #82 to fix it.

@pablomh
Copy link
Collaborator

pablomh commented Mar 25, 2024

Hi @pcfe and @andreamtp,

Would you be OK with the approach suggested in https://github.com/RedHatSatellite/satellite-support/pull/88/files#r1532703028? In my testing it covers the en_DK.UTF-8 usecase, but I'd love confirmation.

@pablomh
Copy link
Collaborator

pablomh commented Mar 25, 2024

This is what I'd like to commit:

RAMGB=$(awk '/^MemTotal:/ {printf "%d\n", $2 / 1024 / 1024}' /proc/meminfo)

@pcfe
Copy link
Author

pcfe commented Apr 2, 2024

Would you be OK with the approach suggested in https://github.com/RedHatSatellite/satellite-support/pull/88/files#r1532703028? In my testing it covers the en_DK.UTF-8 usecase, but I'd love confirmation.

Because the planet has so many languages and I only speak a few, I asked to set LANG explicitly in your script to meet the needs of the script.
While the suggestion from last week¹ sounds sane to me, that does not mean it will cover any LANG setting a user can have

If you are confident your awk construct works in any language, sure use what you suggested.
But TBH I fail to grok why you do not simply set the language in your script to ensure the calculation always works.

¹ https://github.com/RedHatSatellite/satellite-support/pull/88/files#r1537771032

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

No branches or pull requests

3 participants