auanasgheps / snapraid-aio-script

The definitive all-in-one SnapRAID script on Linux. Diff, sync, scrub are things of the past. Manage SnapRAID and much, much more!
GNU General Public License v3.0
225 stars 36 forks source link

Errors posted at end of email. #74

Closed gderf closed 5 months ago

gderf commented 8 months ago

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

auanasgheps commented 8 months ago

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 6 months ago

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!

tehniemer commented 6 months ago

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

gderf commented 6 months ago

I have:

ADD_DEL_THRESHOLD=0

I don't have:

ADD_DEL_RATIO

tehniemer commented 6 months ago

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 6 months ago

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.

auanasgheps commented 6 months ago

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.

auanasgheps commented 6 months ago

Finally on my way to fix it!

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

auanasgheps commented 6 months ago

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

auanasgheps commented 5 months ago

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.

auanasgheps commented 5 months ago

Finally: done!