Deleted Added
full compact
throughput.c (49447) throughput.c (49582)
1/*-
2 * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: throughput.c,v 1.10 1999/08/05 10:32:15 brian Exp $
26 * $Id: throughput.c,v 1.11 1999/08/06 01:34:03 brian Exp $
27 */
28
29#include <sys/types.h>
30
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34#include <termios.h>

--- 61 unchanged lines hidden (view full) ---

96 prompt_Printf(prompt, "Connect time: %d:%02d:%02d", secs_up / 3600,
97 (secs_up / 60) % 60, secs_up % 60);
98 if (t->downtime)
99 prompt_Printf(prompt, " - down at %s", ctime(&t->downtime));
100 else
101 prompt_Printf(prompt, "\n");
102
103 divisor = secs_up ? secs_up : 1;
27 */
28
29#include <sys/types.h>
30
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34#include <termios.h>

--- 61 unchanged lines hidden (view full) ---

96 prompt_Printf(prompt, "Connect time: %d:%02d:%02d", secs_up / 3600,
97 (secs_up / 60) % 60, secs_up % 60);
98 if (t->downtime)
99 prompt_Printf(prompt, " - down at %s", ctime(&t->downtime));
100 else
101 prompt_Printf(prompt, "\n");
102
103 divisor = secs_up ? secs_up : 1;
104 prompt_Printf(prompt, "%qu octets in, %qu octets out\n",
104 prompt_Printf(prompt, "%llu octets in, %llu octets out\n",
105 t->OctetsIn, t->OctetsOut);
106 if (t->rolling) {
107 prompt_Printf(prompt, " overall %6qu bytes/sec\n",
108 (t->OctetsIn + t->OctetsOut) / divisor);
109 prompt_Printf(prompt, " %s %6qu bytes/sec (over the last"
110 " %d secs)\n", t->downtime ? "average " : "currently",
111 t->OctetsPerSecond,
112 secs_up > t->SamplePeriod ? t->SamplePeriod : secs_up);
113 prompt_Printf(prompt, " peak %6qu bytes/sec on %s",
114 t->BestOctetsPerSecond, ctime(&t->BestOctetsPerSecondTime));
115 } else
105 t->OctetsIn, t->OctetsOut);
106 if (t->rolling) {
107 prompt_Printf(prompt, " overall %6qu bytes/sec\n",
108 (t->OctetsIn + t->OctetsOut) / divisor);
109 prompt_Printf(prompt, " %s %6qu bytes/sec (over the last"
110 " %d secs)\n", t->downtime ? "average " : "currently",
111 t->OctetsPerSecond,
112 secs_up > t->SamplePeriod ? t->SamplePeriod : secs_up);
113 prompt_Printf(prompt, " peak %6qu bytes/sec on %s",
114 t->BestOctetsPerSecond, ctime(&t->BestOctetsPerSecondTime));
115 } else
116 prompt_Printf(prompt, "Overall %qu bytes/sec\n",
116 prompt_Printf(prompt, "Overall %llu bytes/sec\n",
117 (t->OctetsIn + t->OctetsOut) / divisor);
118}
119
120
121void
122throughput_log(struct pppThroughput *t, int level, const char *title)
123{
124 if (t->uptime) {
125 int secs_up;
126
127 secs_up = throughput_uptime(t);
128 if (title)
117 (t->OctetsIn + t->OctetsOut) / divisor);
118}
119
120
121void
122throughput_log(struct pppThroughput *t, int level, const char *title)
123{
124 if (t->uptime) {
125 int secs_up;
126
127 secs_up = throughput_uptime(t);
128 if (title)
129 log_Printf(level, "%s: Connect time: %d secs: %qu octets in, %qu octets"
129 log_Printf(level, "%s: Connect time: %d secs: %llu octets in, %llu octets"
130 " out\n", title, secs_up, t->OctetsIn, t->OctetsOut);
131 else
130 " out\n", title, secs_up, t->OctetsIn, t->OctetsOut);
131 else
132 log_Printf(level, "Connect time: %d secs: %qu octets in,"
133 " %qu octets out\n", secs_up, t->OctetsIn, t->OctetsOut);
132 log_Printf(level, "Connect time: %d secs: %llu octets in,"
133 " %llu octets out\n", secs_up, t->OctetsIn, t->OctetsOut);
134 if (secs_up == 0)
135 secs_up = 1;
136 if (t->rolling)
134 if (secs_up == 0)
135 secs_up = 1;
136 if (t->rolling)
137 log_Printf(level, " total %qu bytes/sec, peak %qu bytes/sec on %s",
137 log_Printf(level, " total %llu bytes/sec, peak %llu bytes/sec on %s",
138 (t->OctetsIn + t->OctetsOut) / secs_up, t->BestOctetsPerSecond,
139 ctime(&t->BestOctetsPerSecondTime));
140 else
138 (t->OctetsIn + t->OctetsOut) / secs_up, t->BestOctetsPerSecond,
139 ctime(&t->BestOctetsPerSecondTime));
140 else
141 log_Printf(level, " total %qu bytes/sec\n",
141 log_Printf(level, " total %llu bytes/sec\n",
142 (t->OctetsIn + t->OctetsOut) / secs_up);
143 }
144}
145
146static void
147throughput_sampler(void *v)
148{
149 struct pppThroughput *t = (struct pppThroughput *)v;

--- 128 unchanged lines hidden ---
142 (t->OctetsIn + t->OctetsOut) / secs_up);
143 }
144}
145
146static void
147throughput_sampler(void *v)
148{
149 struct pppThroughput *t = (struct pppThroughput *)v;

--- 128 unchanged lines hidden ---