auanasgheps/snapraid-aio-script

Errors posted at end of email.

gderf opened this issue · 11 comments

gderf commented

I've been seeing this and just ignoring it. But since I see no mention of it I thought you should know about it.

At the very end of the emailed message sent on script completion I see the following few lines:

All jobs ended. [Fri Nov 10 09:24:59 EST 2023]
awk: cmd. line:1: BEGIN {exit !( < 0)}
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: BEGIN {exit !( < 0)}
awk: cmd. line:1: ^ syntax error

Hi, looks like it only happens when there's a warning, like the file threshold. If the scripts runs normally without an exception, this error doesn't show up.

I've got to look into it.

aodtcr commented

Hi @auanasgheps,

I rarely have any warning messages, so this is the first time that I am noticing the same message at the end of the email. The same is in the outputted log file.

All jobs ended. [Sun 07 Jan 2024 04:00:46 AM CET]
awk: cmd. line:1: BEGIN {exit !( < 0)}
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: BEGIN {exit !( < 0)}
awk: cmd. line:1: ^ syntax error

As it is at the very end of the email or log file, it seems to me that it is in the two awk lines of the prepare_mail function. However, the script runs fine otherwise, this would only parse the threshold violation messages. Useful, but not essential.

Please let me know if you need any further details. Thank you for an amazing script!

What are the values set for $ADD_DEL_THRESHOLD and $ADD_DEL_RATIO in the config?

gderf commented

I have:

ADD_DEL_THRESHOLD=0

I don't have:

ADD_DEL_RATIO

Sorry ADD_DEL_RATIO is calculated in the script, I misremembered where that came from.

This is an odd one, that error is likely from this line, elif awk "BEGIN {exit !($ADD_DEL_THRESHOLD > 0)}";, but I'm not sure why you're getting it. It doesn't show up for me, maybe try reinstalling awk

aodtcr commented

What are the values set for $ADD_DEL_THRESHOLD and $ADD_DEL_RATIO in the config?

I have the standard $ADD_DEL_THRESHOLD of 0 and $DEL_THRESHOLD of 500. Today, the $DEL_THRESHOLD was triggered and this is when I saw the warning. I have since checked deleted files and performed a manual sync, so it should not pop up anymore.

Currently I am running GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0), there is no updated package available for my Ubuntu Server 20.04 LTS. I guess I will have to see about updating the OS anyway.

Hi, as I said earlier, this issue happens only when there's a WARNING, which triggers some awk commands.
The way these commands are written cause the errors you see. These are harmless as they are still doing their job.

I had a look at this but could not (yet) figure out how to rewrite them correctly. You'll be updated here once it happens.

Finally on my way to fix it!

I will replace all awk commands with bc, it is way more reliable. News to come soon :)

You can test the dev channel if you like to see this issue fixed.
bc is a new dependency that must be installed.
I'm working on a way to auto install dependencies (at least on debian-based/ apt distros

Edit: implemented in dev too

Note to myself:
With the latest changes there's a new error at the end of the email when the WARNING Forced sync with deleted files is issued.

/usr/sbin/snapraid.custom/snapraid-aio-script.sh: line 770: [: : integer expression expected

I know how to fix it, writing here for tracking purposes.

Finally: done!