This is a simple Python program, intended to be used with cron (daily). It reads the file /var/log/messages and computes the number of connections to the Internet and the total duration used in the last few days.
Download it here: inettime.txt.
Note that this requires that you have a working Python interpreter and a working sendmail or other MTA working on your system. These are, however, found in almost all common Linux distributions.
Before use, you might want to make minor modifications in it. You don't need to know Python however. You only have to specify the recipient's email address in the first few lines of the programs by changing EMAIL="root@localhost" to whatever e-mail address you want the report to be sent. Also, you may wish to change the name of SMTPSERV to your system's name. However, in most situations, you would not need to make these changes.
To use it, simply put it in an easily accessible directory (like your home directory), and give it permissions of 755 by using the command chmod 755 inettime.py. Then, just execute it to have it mail the information. You can also add an option "-a" to make it read all of your message files (messages.1, messages.2 etc.) to get a more detailed report. The best idea would be to get a daily report. After performing the above steps and checking that it works, add the following file inettimeto the /etc/cron.daily/ directory:
#!/bin/sh /path/to/installed/directory/inettime.py -a
Change the /path/to/installed/directory/ to the directory in which you have placed inettime.py. The "-a" is optional. This file must also have permissions +x.
Please do send me your comments on this software.
Last modified: Tue Jul 20 17:47:40 IST 2004