Deleted Added
full compact
main.c (216370) main.c (240605)
1/*-
2 * Copyright (c) 1980, 1992, 1993
3 * The Regents of the University of California. 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

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

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31
1/*-
2 * Copyright (c) 1980, 1992, 1993
3 * The Regents of the University of California. 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

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

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31
32__FBSDID("$FreeBSD: head/usr.bin/systat/main.c 216370 2010-12-11 08:32:16Z joel $");
32__FBSDID("$FreeBSD: head/usr.bin/systat/main.c 240605 2012-09-17 13:36:47Z melifaro $");
33
34#ifdef lint
35static const char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
36#endif
37
38#ifndef lint
39static const char copyright[] =
40"@(#) Copyright (c) 1980, 1992, 1993\n\

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

59#include "extern.h"
60
61static int dellave;
62
63kvm_t *kd;
64sig_t sigtstpdfl;
65double avenrun[3];
66int col;
33
34#ifdef lint
35static const char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
36#endif
37
38#ifndef lint
39static const char copyright[] =
40"@(#) Copyright (c) 1980, 1992, 1993\n\

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

59#include "extern.h"
60
61static int dellave;
62
63kvm_t *kd;
64sig_t sigtstpdfl;
65double avenrun[3];
66int col;
67int naptime = 5;
67unsigned int delay = 5000000; /* in microseconds */
68int verbose = 1; /* to report kvm read errs */
69struct clockinfo clkinfo;
70double hertz;
71char c;
72char *namp;
73char hostname[MAXHOSTNAMELEN];
74WINDOW *wnd;
75int CMDLINE;
76int use_kvm = 1;
77
78static WINDOW *wload; /* one line window for load average */
79
80int
81main(int argc, char **argv)
82{
83 char errbuf[_POSIX2_LINE_MAX], dummy;
84 size_t size;
68int verbose = 1; /* to report kvm read errs */
69struct clockinfo clkinfo;
70double hertz;
71char c;
72char *namp;
73char hostname[MAXHOSTNAMELEN];
74WINDOW *wnd;
75int CMDLINE;
76int use_kvm = 1;
77
78static WINDOW *wload; /* one line window for load average */
79
80int
81main(int argc, char **argv)
82{
83 char errbuf[_POSIX2_LINE_MAX], dummy;
84 size_t size;
85 double t;
85
86 (void) setlocale(LC_ALL, "");
87
88 argc--, argv++;
89 while (argc > 0) {
90 if (argv[0][0] == '-') {
91 struct cmdtab *p;
92
93 p = lookup(&argv[0][1]);
94 if (p == (struct cmdtab *)-1)
95 errx(1, "%s: ambiguous request", &argv[0][1]);
96 if (p == (struct cmdtab *)0)
97 errx(1, "%s: unknown request", &argv[0][1]);
98 curcmd = p;
99 } else {
86
87 (void) setlocale(LC_ALL, "");
88
89 argc--, argv++;
90 while (argc > 0) {
91 if (argv[0][0] == '-') {
92 struct cmdtab *p;
93
94 p = lookup(&argv[0][1]);
95 if (p == (struct cmdtab *)-1)
96 errx(1, "%s: ambiguous request", &argv[0][1]);
97 if (p == (struct cmdtab *)0)
98 errx(1, "%s: unknown request", &argv[0][1]);
99 curcmd = p;
100 } else {
100 naptime = atoi(argv[0]);
101 if (naptime <= 0)
102 naptime = 5;
101 t = strtod(argv[0], NULL) * 1000000.0;
102 if (t > 0 && t < (double)UINT_MAX)
103 delay = (unsigned int)t;
103 }
104 argc--, argv++;
105 }
106 kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
107 if (kd != NULL) {
108 /*
109 * Try to actually read something, we may be in a jail, and
110 * have /dev/null opened as /dev/mem.

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

161 }
162 hertz = clkinfo.stathz;
163 (*curcmd->c_init)();
164 curcmd->c_flags |= CF_INIT;
165 labels();
166
167 dellave = 0.0;
168
104 }
105 argc--, argv++;
106 }
107 kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
108 if (kd != NULL) {
109 /*
110 * Try to actually read something, we may be in a jail, and
111 * have /dev/null opened as /dev/mem.

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

162 }
163 hertz = clkinfo.stathz;
164 (*curcmd->c_init)();
165 curcmd->c_flags |= CF_INIT;
166 labels();
167
168 dellave = 0.0;
169
169 signal(SIGALRM, display);
170 display(0);
170 display();
171 noecho();
172 crmode();
173 keyboard();
174 /*NOTREACHED*/
175
176 return EXIT_SUCCESS;
177}
178

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

187 (*curcmd->c_label)();
188#ifdef notdef
189 mvprintw(21, 25, "CPU usage on %s", hostname);
190#endif
191 refresh();
192}
193
194void
171 noecho();
172 crmode();
173 keyboard();
174 /*NOTREACHED*/
175
176 return EXIT_SUCCESS;
177}
178

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

187 (*curcmd->c_label)();
188#ifdef notdef
189 mvprintw(21, 25, "CPU usage on %s", hostname);
190#endif
191 refresh();
192}
193
194void
195display(int signo __unused)
195display()
196{
197 int i, j;
198
199 /* Get the load average over the last minute. */
200 (void) getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0]));
201 (*curcmd->c_fetch)();
202 if (curcmd->c_flags & CF_LOADAV) {
203 j = 5.0*avenrun[0] + 0.5;

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

218 wprintw(wload, " %4.1f", avenrun[0]);
219 }
220 (*curcmd->c_refresh)();
221 if (curcmd->c_flags & CF_LOADAV)
222 wrefresh(wload);
223 wrefresh(wnd);
224 move(CMDLINE, col);
225 refresh();
196{
197 int i, j;
198
199 /* Get the load average over the last minute. */
200 (void) getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0]));
201 (*curcmd->c_fetch)();
202 if (curcmd->c_flags & CF_LOADAV) {
203 j = 5.0*avenrun[0] + 0.5;

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

218 wprintw(wload, " %4.1f", avenrun[0]);
219 }
220 (*curcmd->c_refresh)();
221 if (curcmd->c_flags & CF_LOADAV)
222 wrefresh(wload);
223 wrefresh(wnd);
224 move(CMDLINE, col);
225 refresh();
226 alarm(naptime);
227}
228
229void
230load(void)
231{
232
233 (void) getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
234 mvprintw(CMDLINE, 0, "%4.1f %4.1f %4.1f",

--- 58 unchanged lines hidden ---
226}
227
228void
229load(void)
230{
231
232 (void) getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
233 mvprintw(CMDLINE, 0, "%4.1f %4.1f %4.1f",

--- 58 unchanged lines hidden ---