Yea, I suppose there are a lot more advanced things you could do, especially with a server box.
Actually, for anyone trying to keep it simple and whose information being sent is not sensitive, you can get get a free mailbox that doesn't* require SSL (e.g. gmx.com). Set up gmail to do pop3 retrieval and you shouldn't ever have to login to the other account to keep it active. The address itself won't matter since you won't be corresponding with anyone and will just be sending yourself these notifications.
Last edited by tc23emp on Thu Aug 26, 2010 14:44; edited 1 time in total
Very interesting post guys. I wonder if this script could be tuned to just run hourly from say 6AM to 11.59PM and send a mail stating the last hour ul/dl triggered if a ul/dl threshold is reached within this hour.
The top would be it wouldn't need external storage or another box for a mail server. _________________ ): FoReVeR nEwB
PS: instead of using the word "bandwidth" (whose unit is Mb/s) in this thread, we should rather use "traffic" (MB), isn't it? _________________ ): FoReVeR nEwB
Slightly off topic, but based on the same principal of sending an e-mail notification-
Is there any way for a script to know when a new host associates with the wireless? I would like to combine scripts so that when someone successfully authenticates with my wireless AP, an e-mail is generated.
Additionally- It seems that the Micro version of DD-WRT does not support the "sendmail" command, can anyone verify?
@Bib, Explain the common usage of bandwidth cap, even if its name should be something else. Traffic usually implies you are looking at more than just bandwidth/bit usage, but it all depends, use whatever term suits you.
Regarding hourly reports, it sounds entirely possible, but like dellsweig said, more advanced reporting calls for the use of a server running netflow or similar to communicate with the built-in SNMP, rflow, or MACupd daemons.
If you want a simple script solution, the shell scripting needed is not much more complicated than what is already in the current example. External storage is not needed because the temporary filesystem persists as long as the router doesn't reboot. If it does, that hour of reporting will be lost unless you use nvram to store a little bit of additional data. Although, I don't know how safe it is to frequently write to flash or if nvram is automatically committed before a reboot. Also, most people should be able to find a mail server besides gmail that will support non-encrypted SMTP. It is only a special case where your own mail server is needed.
I'm not quite following. This would be used if someone also had some other script to schedule? Also, what do you mean about easier to edit?
BTW, I noticed that when you save traffic, the script is written out with it. That caught me by surprise. The Save button must look for "traff-" and save everything with it. Not much to be done about that, and it's easy to remember to edit it out before restoring.
It's just that the script is written out (in the web interface) where you can edit it in it's true form rather than being enclosed in the original echo/pipe statement. Making the custom script field re-usable was just a bonus.
What do you mean by save traffic? Maybe there is a way to avoid that.
I meant the Save feature in Status/WAN, where you can save/restore your traffic. The code behind that must grab everything with "traff-" in it, which your script probably unavoidably must also invoke because it's interested in the same data. You can run this in telnet to see, or save traffic in Status/WAN:
nvram show | grep traff-
I'm not receiving any e-mails either, verified the logon data multiple times. I'm trying to just run the command from a laptop running ubuntu to see if the server is returning any errors, but sendmail itself is saying "illegal option - - S". Captital "S" is the SMTP argument, so I don't see how that could be wrong.
The sendmail arguments are specific to the DD-WRT busybox version of sendmail. The rest should be generic.
On a side note, if you look at my wiki page, you will see I switched from using startup crontab to cron_jobs. The crontab file mysteriously reset on me without the router rebooting, so this other cron method may be more reliable.
Totals for Month to Date
Incoming: 0 MB
Outgoing: 3 MB
[0:3]
There was normal bandwidth on the 31st, not zero, and I'm not sure why it grabbed the entire string of empty data for the new month. Also, the bottom half appears to be listing the bandwidth totals for the new month, when it should be for August, right? I'm not sure why it has [0:3] at the bottom when there's normally nothing after the Outgoing line. Lots of fun things!