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

Resolves #9 SD card utilisation locale fix #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hailigsblechle
Copy link

Resolves issue with different locale when using "grep -v Used". The suggestion is based on only querying the sd card utilization on root file level and then uses the only available stats line with relying on 'tail'.

Resolves #9

Resolves issue with different locale when using "grep -v Used". The suggestion is based on only querying the sd card utilization on root file level and then uses the only available stats line with relying on 'tail'.
@sberl
Copy link

sberl commented May 13, 2022

Looking at your fix and incorporating it into my new version of this plugin, now called signalk-rpi-monitor.
I'd like to understand the problem you were having. Is the issue that the word "Used" does not appear in the header line when local is set to some values?

Looking at the man page for the df command on raspberry pi bullseye release, the -m option to df is not mentioned. It also doesn't appear to be needed to get the percentage of free space available.

I like your idea of requesting just the / file system and using tail -1 to get rid of the header line.

I see the --output=pcent option to return only the percent of space used, on a line by itself. But still need to get rid of the % symbol.

So I propose the following command:
df --output=pcent / | tail -1 | awk 'gsub("%","")'

What do you think? Will this work in your local? Do you see any problems with this strategy?

According to discussion in nmostovoy#10.

Removed the unnecessary"-m" parameter and added the parameter "--output=pcent" according to idea from @sberl.
@hailigsblechle
Copy link
Author

Thanks for having a look at it and for the quick response.

I'd like to understand the problem you were having. Is the issue that the word "Used" does not appear in the header line when local is set to some values?

The word "Used" does not appear in my locale "de". Instead the word "Verw" appears which is the abbreviation of "Verwendet", the german word for "Used". Other locales might have their own description too.

This it what is shown when executing "df /":

$ df /
Dateisystem    1K-Blöcke  Benutzt Verfügbar Verw% Eingehängt auf
/dev/root       14991820 10155084   4171172   71% /

Looking at the man page for the df command on raspberry pi bullseye release, the -m option to df is not mentioned. It also doesn't appear to be needed to get the percentage of free space available.

You are right the parameter "-m" is currently not documented (anymore?). While analysing the absolute disk space, I used the parameter "-m" to get a more human readable output (which is using 1048576-byte (1-Mbyte) blocks rather than the default). I agree it is unnecessary in this relative (%) context.

$ df -m /
Dateisystem    1M-Blöcke Benutzt Verfügbar Verw% Eingehängt auf
/dev/root          14641    9919      4072   71% /

I see the --output=pcent option to return only the percent of space used, on a line by itself. But still need to get rid of the % symbol.

So I propose the following command:
df --output=pcent / | tail -1 | awk 'gsub("%","")'

What do you think? Will this work in your local? Do you see any problems with this strategy?

I like your adjustment, as this simplifies the command even more. This is also working well in my locale:

$ df --output=pcent / | tail -1 | awk 'gsub("%","")'
  71

I included this in my latest commit if this is ok with you.

@sberl
Copy link

sberl commented May 13, 2022 via email

@hailigsblechle
Copy link
Author

hailigsblechle commented May 14, 2022 via email

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.

SD card utilisation returns NaN
2 participants