Page 1 of 2

Email,SMS notification

Posted: Fri Aug 30, 2019 6:48 pm
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

Re: Email,SMS notification

Posted: Sun Sep 01, 2019 5:12 pm
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.

Re: Email,SMS notification

Posted: Sun Sep 01, 2019 5:44 pm
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

Re: Email,SMS notification

Posted: Mon Sep 09, 2019 3:56 pm
by splinter02
Anyone?

Re: Email,SMS notification

Posted: Wed Jan 22, 2020 8:35 am
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

Re: Email,SMS notification

Posted: Fri Feb 21, 2020 5:43 pm
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.

Re: Email,SMS notification

Posted: Fri Feb 21, 2020 6:40 pm
by Lantis
Nice, that's pretty cool!

EmailSMS notification

Posted: Fri Mar 13, 2020 1:09 pm
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

Re: Email,SMS notification

Posted: Mon Mar 21, 2022 9:28 am
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.

Re: Email,SMS notification

Posted: Mon Mar 21, 2022 9:55 pm
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.