Email,SMS notification

Report issues relating to bandwith monitoring, bandwidth quotas or QoS in this forum.

Moderator: Moderators

splinter02
Posts: 4
Joined: Fri Aug 30, 2019 6:29 pm

Email,SMS notification

Post by splinter02 »

Hi all,

I was wondering if the email notification could be coded for the quota management? Here is what I would like to accomplish, I have a guest account for a airbnb style rental (Monthly). I include 40 Go a month, which of course shuts off by quota management, but would like to send notification via sms when user reaches 50%, 90%, ect... like the major cell phone providers do. This would be a very nice feature which would put less stress to my life when the phone rings at midnight because they lost internet... Thanks

Lantis
Moderator
Posts: 6735
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: Email,SMS notification

Post by Lantis »

You can roll your own script for this which checks the quote values and then triggers an email if needed.
You can use the "print_quotas" command on a cron schedule, and the email notifications plugin to provide you with the email sending utility.
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

splinter02
Posts: 4
Joined: Fri Aug 30, 2019 6:29 pm

Re: Email,SMS notification

Post by splinter02 »

Thanks, I understand the dynamic side of this, but im not a shell script programmer, if someone could help me out a bit it would be appreciated

splinter02
Posts: 4
Joined: Fri Aug 30, 2019 6:29 pm

Re: Email,SMS notification

Post by splinter02 »

Anyone?

User avatar
ericwong
Posts: 430
Joined: Sat Aug 25, 2012 6:15 am
Location: Melbourne, Australia
Contact:

Re: Email,SMS notification

Post by ericwong »

A few suggestions without writing a script
1) Simply ask them to check the usage from the router page, login not required
2) Throttle their speed, not cut it off when limited is reached
3) Consider changing your quota limit to reset per day/hour/week rather than per month
Eric Wong

PM me if you need to buy Gargoyle router in Australia/NZ, willing to pay me to help you on your Gargoyle configurations or build custom configured ROM with pre-installed app or try to fix your bricked router. Yes, I am looking for job/work.

agrohe21
Posts: 95
Joined: Wed Aug 23, 2017 7:51 pm

Re: Email,SMS notification

Post by agrohe21 »

I have written such a script. Just a few lines really. It emails only when >=99%. I set it to run every 10 min in cron. I dont think the Priority works but left it in there.

Code: Select all

#!/bin/sh

current_date_time=$(date +"%Y-%m-%d-%H-%M-%S")

print_quotas | grep quotaPercents |grep -v "\= \[\];"|grep -v " 0.000," |grep -v "var quotaPercents" |awk '/\]\[/{sub(/.*\]\[ /, "");print}' |awk '{print $1, $5}'| cut -c 2- |sed 's/.$//'|sed 's/"//'| sed 's/"//' | awk '{ if($2 >= 99) { print } }' > quota_email_output.txt

if [ -s quota_email_output.txt ]
then
  cat ../mail_template_quota.txt > "mail_alert_$current_date_time.txt"
   print_quotas |grep quotaPercents |grep -v "\= \[\];"|grep -v " 0.000," |grep -v "var quotaPercents" |awk '/\]\[/{sub(/.*\]\[ /, "");print}' |awk '{print $1, $5}'| cut -c 2- |sed 's/.$//'|sed 's/"//'| sed 's/"//' | awk '{ if($2 >= 99) { print } }' >> mail_alert_$current_date_time.txt
  cat "mail_alert_$current_date_time.txt" | msmtp username@domain.com
fi
Contents of mail_template_quota.txt

Code: Select all

To: user@domain.com
From: user@gmail.com
Subject: Gargoyle Quota Warning
X-Priority:1
User has exceeded their quota
The actual quota group/name and values get append to the end of the email body.
Linksys WRT32x Wired Gateway, Orbi RBK20 Wifi
Linksys WRT32x Wired Gateway, Orbi RBK50 Wifi

Lantis
Moderator
Posts: 6735
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: Email,SMS notification

Post by Lantis »

Nice, that's pretty cool!
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

Keithnot
Posts: 1
Joined: Fri Mar 13, 2020 7:13 am

EmailSMS notification

Post by Keithnot »

Just for reference, I think you went to "Settings", "General", Messaging & Notification where the second option is -Default Thread Subscription Mode -there are 5 options. Off is by default.



ff

pkkrusty
Posts: 45
Joined: Mon Jan 13, 2020 4:41 pm

Re: Email,SMS notification

Post by pkkrusty »

agrohe21 wrote:
Fri Feb 21, 2020 5:43 pm
I have written such a script.
Any quick tips on what I could change with your useful script to just have the COMBINED Day Download/Upload bandwidth data sent? I have a 300gb ISP limit, and I'd like to get an email when I'm within 1gb so I can recharge.

agrohe21
Posts: 95
Joined: Wed Aug 23, 2017 7:51 pm

Re: Email,SMS notification

Post by agrohe21 »

Instead of using print quotas you would need to use the bw_ commands. It that is a non trivial change. Unless your quota is for the whole system.
Linksys WRT32x Wired Gateway, Orbi RBK20 Wifi
Linksys WRT32x Wired Gateway, Orbi RBK50 Wifi

Post Reply