ElectricEel-24.10.1 Issue

Here is Beta 6 of Multi-Report.

I still have a lot of cleanup to do, update the quick-start guide, etc. I expect that unless there are more issues with email, I should have the final version of v3.1 out next weekend. It just takes time to go though and clean up my mess.

When you run the script for the first time, it will download the new python script for sending emails. I need to work on identifying updates should there need to be any.

This would not be possible without @oxyde help.

The CRON setup should be like my example (full path to script && ./script_name), run as root or privileged account:

Beta 6
multi_report_v3.1Beta6_2025_01_11.txt (520.4 KB)

P.S. I wish Elon Musk would quit sending me emails about selling me a magazine subscription, I’d be fine with some cash in my pocket instead. Okay, it is some jerk posing as Elon Musk, but I’d still like the cash donation :slight_smile:

5 Likes

If you have an email problem (yes, still one person for certain has it), please drop me an email or message here on the forums and include the following data:
midclt call mail.config | jq
And in your script directory will be a new folder called mrlog, please attach the most current file. Do not post this file in the general forums, it will contain your email address, which as you know, I never share without explicit permission. to day, never shared any.

EDIT: Please remove your password from the mail.config file. If you do not, I will redact it and slightly modify any email address as well for you before sharing the data with @oxyde. I believe in security and privacy.

Hi Joe, I’m one of them. It looks like the script doesn’t like the domains with .stream or .email - logs sent.


File /mnt/Orac/Scripts/mrlog/20250112_085253.txt successfully generated                                                                                                                            
2 totals file log                                                                                                                                                                                  
0 totals attachment                                                                                                                                                                                
trying read mail.config                                                                                                                                                                            
read mail.config successfully                                                                                                                                                                      
Switching for the right provider                                                                                                                                                                   
** SMTP Version **                                                                                                                                                                                 
parsing smtp config                                                                                                                                                                                
parsing html content                                                                                                                                                                               
body is a file                                                                                                                                                                                     
check for attachements...                                                                                                                                                                          
establing connection...                                                                                                                                                                            
KO: (553, b'Invalid domain name')

Beta 6 looking good in the Philippines! :smile:

ElectricEel-24.10.1

1 Like

– removed v 0.03 –

Can you try if the change made to this version fix the issue?
Thanks!

It still doesn’t like recipients or senders that are .stream addresses.

.stream recipient


File /mnt/Orac/Scripts/mrlog/20250112_085253.txt successfully generated                                                                                                                            
2 totals file log                                                                                                                                                                                  
0 totals attachment                                                                                                                                                                                
trying read mail.config                                                                                                                                                                            
read mail.config successfully                                                                                                                                                                      
Switching for the right provider                                                                                                                                                                   
** SMTP Version **                                                                                                                                                                                 
parsing smtp config                                                                                                                                                                                
parsing html content                                                                                                                                                                               
body is a file                                                                                                                                                                                     
check for attachements...                                                                                                                                                                          
establing connection...                                                                                                                                                                            
KO: (553, b'Invalid domain name')

.net recipient


File /mnt/Orac/Scripts/mrlog/20250112_161526.txt successfully generated                                                                                                                            
3 totals file log                                                                                                                                                                                  
0 totals attachment                                                                                                                                                                                
trying read mail.config                                                                                                                                                                            
read mail.config successfully                                                                                                                                                                      
Switching for the right provider                                                                                                                                                                   
** SMTP Version **                                                                                                                                                                                 
parsing smtp config                                                                                                                                                                                
parsing html content                                                                                                                                                                               
body is a file                                                                                                                                                                                     
check for attachements...                                                                                                                                                                          
get hostname
hostname: Orac.
establing connection based on security level set on TN: PLAIN                                                                                                                                      
entered PLAIN path

Neither had me receiving emails. Temporarily have changed to gmail and that works.

The first log seems the output of the previous version of the script (it should have logged more info before give the KO), the second one just stop without grabbing anything else, nor the sent and the except :thinking: did Joe give to you my email address? Can you share with me some more info in private?

@Vollans don’t know if you still need, but i pushed a new version on GitHub, the v 0.04, use that instead the one i posted above because i’m quite sure will fix your issue, and if not, will log more step for a better troubleshooting (the log interrupted too should be fixed now)

1 Like

First off, Thank you to everyone that got this up and working again. I have been using this script for quite some time.

When I run the update it creates new files (config.txt and multi_report.sh) that I have to rename to get the script working again. Is this the intended behavior or am I missing something?

Seems the beta pattern, you should move back to the stable branch.
In case just hook the latest files directly from GitHub, and rerun the script. Give a look into guide before, there are some little changes to make

I upgraded from 23.10.x to 24.10.2 today, and ran into the same sendmail issue.

I only came across this post after I had already fixed it on my end, so sharing for posterity (though realize not everyone will be comfortable with doing the same):

install-dev-tools # amongst other things, this will enable dpkg
dpkg-reconfigure exim4-config # change mail server type to 'Internet site', leave everything else as-is

Your existing sendmail-based scripts will look something like

sendmail -t -oi < "${logfile}"

Change that to

exim "${email}" < "${logfile}"

This ā€˜fix’ will only last until the next system upgrade, but that does not bother me. ā€˜install-dev-tools’ is the first thing I do after an upgrade anyway.

Please be sure to read the official documentation to fully understand the consequences of enabling the developer mode that @qmcb23YR brought up.

5 Likes

Another solution that worked for me, without enabling developer mode, and without using exim, is simply to go grab the Python script that TrueNAS shipped as sendmail in older releases.

You don’t need it to be setuid for admin or root users to be able to use it, which is all I needed. It’s not clear to me why they felt the need to remove it entirely.

@oxyde I’m trying to use your script to send an email at shutdown.

Specifically I want the OS to generate an email alert when a shutdown/reboot is requested. What I’m finding is the network is down before the script completes. By network I mean the active wireguard tunnel and networking service.

It would seem the script (or commandline) needs to fire before any of these services are terminated. TN (24.10.2) is lightning fast to shut things down.

Any thoughts or suggestions how to implement this? Thanks

Honestly, i don’t have an answer for this.
Don’t think i can perform anything in my script to compensate the bad timing in this use case, and i don’t have direct experience with shutdown scripts at all (btw from GUI don’t seems there are many fancy customization option).
Anyway the use case Is interesting, i will try It too, just to see if the result will be the same

Thanks for your reply.

Some more context. I want to deploy a TN box at a remote location (neighbor’s house). While I will generally be able to access it, it would be nice to know if it’s there are unscheduled reboots or shut downs.

Generating an email works just fine on startup - with a 10-20s sleep delay preceding sending of the email. I think shutdown/reboot not due to power failure is just as important.

Here i am after some tests.
I’m using a dumb VM with Fangtooth, last not-already-released version of my script, connected with an outlook account (the slower to send email, it takes at least 2-3 times more than other provider)… and is working.
I receive an email nor shutting down from gui and terminal.
I have wrapped the actions in a script instead of using a command (not working for me), really simple (after have checked passwordless sudo):

#!/bin/bash

sudo su <<EOF
cd /mnt/Test/Script
python3 multireport_sendemail.py --subject "VM poweroff" --to_address "***@gmail.com" --mail_body_html "<h1>TEST</h1><p>shutdown script</p>"
EOF

I understand that my setup is minimal, but i neither needed to put higher timeouts or ā€œsleepā€ā€¦ can you try as i do with this setup?

That’s about what my script looks like, mainly just calling the sendmail.py with appropriate parameters.

I tried calling it via the init/shutdown functions, and as a service. The former doesn’t work at all, middleware is downed before the python script finishes. Same with running it as a service.

As a service works when testing on local lan, but not remotely. My remote connection is established by connecting the test truenas box via ethernet to another router, then wireguard to my pfsense (as a peer). That other router gets internet from an ethernet tethered phone using mobile data. So from one extreme to the other. Pings between the two end points can be as high as 300ms (mobile data service sucks around here).

I think the goal to making this work is to figure out how to ensure the sendmail.py completes fully before TN shuts down all its services.

For the service I had

[Unit]
Description=Shutdown Email Notification Process
#DefaultDependencies=no
#Before=shutdown.target
#After=middlewared.service network.target
#Requires=network.target

Before=shutdown.target reboot.target
#Requires=middlewared.service wg-quick@wg0.service
Requires=wg-quick@wg0.service

# This works because it is installed in the target and will be
#   executed before the target state is entered
# Also consider kexec.target

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/root/util/shutdownemail.sh
TimeoutSec=30


[Install]
WantedBy=multi-user.target
#WantedBy=halt.target reboot.target shutdown.target

For the script

#!/bin/sh

uptime=$(awk '{print $1}' /proc/uptime)
uptime=$(echo $uptime | awk '{ printf "%d\n",$1 }'  )

if [ "$uptime" -lt "30" ]  ;

then
     exit
else

     /usr/bin/python3 /root/sendmail.py --subject "Remote Nas Shutdown on $(date)" --to_address user@domain.com --mail_body_html "Shutdown or reboot occurred on $(date)"

fi

I admit i’m not so confident on those things, but I found this and this, maybe Is the After on the wg that Is need to do the trick?