*New 11.4 series Release:
2020-07-03: XigmaNAS 11.4.0.4.7633 - released!

*New 12.1 series Release:
2020-04-17: XigmaNAS 12.1.0.4.7542 - released


We really need "Your" help on XigmaNAS https://translations.launchpad.net/xigmanas translations. Please help today!

Producing and hosting XigmaNAS costs money. Please consider donating for our project so that we can continue to offer you the best.
We need your support! eg: PAYPAL

email report?

XigmaNAS Scripts and shell tips
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
User avatar
saciorlux
NewUser
NewUser
Posts: 5
Joined: 02 Feb 2013 20:41
Status: Offline

email report?

#1

Post by saciorlux »

Sorry for my English
I use rsync and DeltaCopy use in windows.
In the email report option can not send logs rsync-client, Rsync Log appears.
How I can do to send the Rsync-client log to see the files and folders that have been copied or failed?

User avatar
juddyjacob
Starter
Starter
Posts: 48
Joined: 07 Sep 2012 03:01
Location: Leonardo New Jersey
Contact:
Status: Offline

Re: email report?

#2

Post by juddyjacob »

You need to create a script to capture the log files then email them to you. Try something like this, save it as filename.sh , and setup your cron job under system / advanced / cron

#!/bin/bash

PRINTF=/usr/bin/printf
MSMTP=/usr/local/bin/msmtp
MSMTPCONF=/var/etc/msmtp.conf

FROM="person@domain.com"
TO="person@domain.com"
SUBJECT=" Rsync Log"
Body=

BODY="$(cat /var/log/rsync_client.log)"

cat dev/null > /mnt/var/log/rsync_client.log

$PRINTF "From:$FROM\nTo:$TO\nSubject:$SUBJECT\n\n$BODY" | $MSMTP --file=$MSMTPCONF -t



Only problem you might have is that if your log file is large you will get an argument list too long error. To do this properly you need to attach the log file as a attachment. However to my knowlege there is no MIME support built in to nas4free and you will have to install a package such as mutt to build the email and attachment to send it. This is were I am stuck but hopefully this will help you.
x64-full on Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz : Supermicro X10SRL-F : 130926MiB ECC Ram: 8x4TB RZ2 : 19TB Usable

User avatar
saciorlux
NewUser
NewUser
Posts: 5
Joined: 02 Feb 2013 20:41
Status: Offline

Re: email report?

#3

Post by saciorlux »

thanks

cpcnw
Starter
Starter
Posts: 26
Joined: 11 Sep 2012 19:37
Status: Offline

Re: email report?

#4

Post by cpcnw »

Realise this is an old thread but its an issue I came across myself just recently and wanted to create a record of what I found.

Once your log file exceeds somewhere between 3000 and 4000 lines [not exactly sure where] the printf function will complain and refuse to deal with that amount of data. This doesn't seem to bear resemblance to the output of;

Code: Select all

sysctl kern.argmax
which on my system outputs 262144

So I searched for ages trying to find a way of using msmtp to send the log file as an attachment as well as including the subject/date/to/from fields. The search ended with me finding this post right here on the forums as well as another tip here;

viewtopic.php?t=7047

which resulted in me modifying my original script as follows

Code: Select all

#!/bin/bash
# Filename: mailrsynclog.sh
# Purpose: Email the output of an rsync task
# Last Update: 06/05/17

PRINTF=/usr/bin/printf
MSMTP=/usr/local/bin/msmtp
MSMTPCONF=/var/etc/msmtp.conf

LOGFILE="/var/log/rsync.log"
LINES="$(/usr/bin/wc -l < $LOGFILE)"
MAXLINES="3000"

FROM="sysadmin@myn4f.box"
TO="sysadmin@mysupport.box"

DATE="$(/bin/date +'%a, %d %b %Y %H:%M:%S %z')"
SUBJECT="Backup Log - $DATE"

if [ "$LINES" -le "$MAXLINES" ];

then
# Log is less than MAXLINES so send entire log
BODY="$(/bin/cat $LOGFILE)"

else
# Log is more than MAXLINES so truncate the log
TOP="$(/usr/bin/head -n 1500 $LOGFILE)"
TAIL="$(/usr/bin/tail -n 1500 $LOGFILE)"
BODY="$TOP $TAIL"

fi

# Send the mail

$PRINTF "From:$FROM\nTo:$TO\nDate:$DATE\nSubject:$SUBJECT\n\n$BODY" | $MSMTP --file=$MSMTPCONF -t

# Notes
# -----
# Append the following to your rsync task inc the chevron but not the hash :)
#
# > /var/log/rsync.log
#
# also add the -v flag to your rsync task to show verbose output
# 
# 06/05/17 Added check to prevent 'Argument list too long' error
Hope that someone might find this useful. Would also like to see any improvements or variations on the above. Or indeed any alternative solutions.

Post Reply

Return to “Scripts and shell tips”