Daily email with the previous day's bandwidth usage?

Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> General Questions
Goto page Previous  1, 2, 3 ... 10, 11, 12
Author Message
Drats
DD-WRT User


Joined: 01 Feb 2007
Posts: 138
Location: Wherever the boat takes me.

PostPosted: Fri Jun 23, 2017 14:14    Post subject: Reply with quote
To tell you the truth, I have not really looked at this script for years. The one I use now had this for the base, but has been changed many times. Right now, it does not work with the latest BusyBox and I don't have the time to play with it, so I just use a pre February revision of DD-WRT.

You could also remove this code since you are not checking and re-sending on a failed attempt:
Code:
if [ "$(cat $logfile | grep 221 | awk '{print $1}')" = "221" ]; then break;fi

echo -e "\nSend Count = $x" >> /tmp/bwmsg.txt

cat $logfile | grep -v 250 | grep -v 334 | grep -v 235 | grep -v 354 | \
grep -v 220 | grep -v 221 >> /tmp/bwmsg.txt



Thanks for verifying that you only have to remove the " -d option " to make it work, I will keep this in mind.


Ray
Sponsor
rocky13
DD-WRT User


Joined: 25 Apr 2008
Posts: 158

PostPosted: Sun Jun 25, 2017 22:08    Post subject: Reply with quote
Johnb175 wrote:
I did remove the $comcast from the script as I had read the -d option was not needed anymore but it still would not work. From the CLI I ran:

cat /tmp/bwmsg.txt | sendmail -S <my smtp> -f <my from address> > $logfile 2>&1

and I get -sh: can't create : nonexistent directory

now if I run

cat /tmp/bwmsg.txt | sendmail <my to address> -S <my smtp> -f <my from address>

it works fine.

So I had to add <my to address> and remove the > $logfile 2>&1

I'm not really sure why though. If I edit custom.sh with those changes and try and run the whole thing from the CLI via ./custom.sh it never exits and keeps emailing me every two minutes. Any ideas on what's up with this script?


Sorry I have a bunch of projects on the go and won't be able to look at this anytime soon. Going back to the sendmail -d command, I guess you could typically write a code in your script to detect which version busybox is running the add the -d syntax if you are at a certain version. I have done this in some of my scripts in the past.
smeisner
DD-WRT Novice


Joined: 13 Aug 2012
Posts: 5

PostPosted: Sun Jul 02, 2017 16:00    Post subject: Reply with quote
I could not figure out how to search a thread, so I apologize if this has already been discussed.

I found that my Kong build did not have the same implementation of date to determine yesterday's date, so I modified my script and it's working fine so far.

I changed my script to the following to allow using Julian date format:

Quote:
yday=$(date -D %j -d $(( $(date +%j) - 1)) +%d)
ymon=$(date -D %j -d $(( $(date +%j) - 1)) +tr$aff-%m-%Y)


I also changed the sendmail parameters to:
Quote:
sendmail -S"server.MYDOMAIN.net" -dMYDOMAIN.net -f"router@MYDOMAIN.net" steve@MYDOMAIN.net > $logfile 2>&1 <<EOF
Subject: $1
$2
EOF
Johnb175
DD-WRT User


Joined: 08 Oct 2010
Posts: 52

PostPosted: Fri Jan 19, 2018 14:41    Post subject: Reply with quote
My ISP is now requiring SSL and a user/pass. I've been using this script for a while now using port 25 and no auth. How can I modify it to connect to port 465 using SSL and pass the user/pass? Any help would be greatly appreciated.
Johnb175
DD-WRT User


Joined: 08 Oct 2010
Posts: 52

PostPosted: Thu Mar 01, 2018 19:52    Post subject: Reply with quote
I finally achieved sending with both TLS and user/pass working in the script. I added two new variables at the top called my_user and my_pass. I changed the sendmail line in the script to the following:

sendmail -H"exec openssl s_client -quiet -connect $my_smtp -tls1 -starttls smtp" -f"$my_mail_addr" -au"$my_user" -ap"$my_pass" $my_mail_to

Hopefully this helps someone who runs into the same issue.
ThePie
DD-WRT Novice


Joined: 08 Dec 2014
Posts: 26

PostPosted: Fri May 01, 2020 8:02    Post subject: Reply with quote
Is there a adaptation of this script that uploads the current days incoming and outgoing total traffic to a SQL database or something similar?

I would like to get the current days data every hour, replacing the current days with the new data until the next day, and upload the data to a SQL DB that is on the network.
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Fri Jun 03, 2022 17:52    Post subject: Reply with quote
Locked since no one is looking at this anymore as observed for lack of replies and to prevent further such situations.
_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
Goto page Previous  1, 2, 3 ... 10, 11, 12 Display posts from previous:    Page 12 of 12
Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum