Date: Thu, 23 Jan 1997 00:59:29 -0600 From: Lars Fredriksen <fredriks@mcs.com> To: hackers@freebsd.org Subject: Modifications to pppd to make it log connecton times Message-ID: <32E70C51.41C67EA6@mcs.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
Here are context diffs to pppd that makes pppd log the total
time in minutes that it has been connected(similar to what ppp does).
I don't know if I have caught every way pppd can exit(it obviously
doesn't do this if it dumps core or the machine panics) to make sure
the data is printed out, but it does work for the normal cases for sure.
This helps one track online time and you can write scripts to monitor
this so that you don't use over your limit(if your account have such
limits).
Please comment on them, or commit them (if they are deemed appropriate)
or let me know and I can commit them as well.
Sincerely,
Lars
[-- Attachment #2 --]
Index: auth.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pppd/auth.c,v
retrieving revision 1.10
diff -c -r1.10 auth.c
*** auth.c 1997/01/14 07:15:59 1.10
--- auth.c 1997/01/17 05:40:32
***************
*** 131,142 ****
link_terminated(unit)
int unit;
{
if (phase == PHASE_DEAD)
return;
if (logged_in)
ppplogout();
phase = PHASE_DEAD;
! syslog(LOG_NOTICE, "Connection terminated.");
}
/*
--- 131,148 ----
link_terminated(unit)
int unit;
{
+ extern time_t etime, stime;
+ extern int minutes;
+
if (phase == PHASE_DEAD)
return;
if (logged_in)
ppplogout();
phase = PHASE_DEAD;
! etime = time((time_t *) NULL);
! minutes = (etime-stime)/60;
! syslog(LOG_NOTICE, "Connection terminated, connected for %d minutes\n",
! minutes > 1 ? minutes : 1);
}
/*
[-- Attachment #3 --]
Index: main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pppd/main.c,v
retrieving revision 1.8
diff -c -r1.8 main.c
*** main.c 1997/01/14 07:16:16 1.8
--- main.c 1997/01/17 05:40:37
***************
*** 71,76 ****
--- 71,78 ----
static pid_t pid; /* Our pid */
static pid_t pgrpid; /* Process Group ID */
static uid_t uid; /* Our real user-id */
+ time_t etime,stime; /* End and Start time */
+ int minutes; /* connection duration */
int fd = -1; /* Device file descriptor */
***************
*** 221,226 ****
--- 223,229 ----
}
pid = getpid();
p = getlogin();
+ stime = time((time_t *) NULL);
if (p == NULL) {
pw = getpwuid(uid);
if (pw != NULL && pw->pw_name != NULL)
***************
*** 468,474 ****
return;
if (len == 0) {
! syslog(LOG_NOTICE, "Modem hangup");
hungup = 1;
lcp_lowerdown(0); /* serial link is no longer available */
phase = PHASE_DEAD;
--- 471,479 ----
return;
if (len == 0) {
! etime = time((time_t *) NULL);
! minutes = (etime-stime)/60;
! syslog(LOG_NOTICE, "Modem hangup, connected for %d minutes", (minutes >1) ? minutes : 1);
hungup = 1;
lcp_lowerdown(0); /* serial link is no longer available */
phase = PHASE_DEAD;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32E70C51.41C67EA6>
