6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include "statcommon.h"
27
28 #include <sys/types.h>
29 #include <stdlib.h>
30 #include <ctype.h>
31 #include <stdio.h>
32 #include <bsm/audit.h>
33 #include <bsm/libbsm.h>
34 #include <unistd.h>
35 #include <locale.h>
36
37 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
38 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it isn't */
39 #endif
40
41
42 /*
43 * Display header every HEADER_MOD lines printed
44 */
45 #define DFLT_HEADER_MOD (20)
101 if (!(flags & IFLG))
102 exit(0);
103
104 /* CSTYLED */
105 for (i = 0;; i++) {
106 eauditon(A_GETSTAT, (caddr_t)&s, NULL);
107 if (timestamp_fmt != NODATE)
108 print_timestamp(timestamp_fmt);
109 display_stats(&s, i);
110 if ((flags & CFLG) && count)
111 if (i == count - 1)
112 break;
113 (void) sleep(interval);
114 }
115
116 return (0);
117 }
118
119
120 static void
121 display_stats(s, cnt)
122 au_stat_t *s;
123 {
124 int offset[12]; /* used to line the header up correctly */
125 char buf[512];
126
127 (void) sprintf(buf,
128 "%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u%n",
129 s->as_generated, &(offset[0]),
130 s->as_nonattrib, &(offset[1]),
131 s->as_kernel, &(offset[2]),
132 s->as_audit, &(offset[3]),
133 s->as_auditctl, &(offset[4]),
134 s->as_enqueue, &(offset[5]),
135 s->as_written, &(offset[6]),
136 s->as_wblocked, &(offset[7]),
137 s->as_rblocked, &(offset[8]),
138 s->as_dropped, &(offset[9]),
139 s->as_totalsize / ONEK, &(offset[10]),
140 s->as_memused / ONEK, &(offset[11]));
141
142 /* print a properly aligned header every HEADER_MOD lines */
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2018, Joyent, Inc.
28 */
29
30 #include "statcommon.h"
31
32 #include <sys/types.h>
33 #include <stdlib.h>
34 #include <ctype.h>
35 #include <stdio.h>
36 #include <bsm/audit.h>
37 #include <bsm/libbsm.h>
38 #include <unistd.h>
39 #include <locale.h>
40
41 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
42 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it isn't */
43 #endif
44
45
46 /*
47 * Display header every HEADER_MOD lines printed
48 */
49 #define DFLT_HEADER_MOD (20)
105 if (!(flags & IFLG))
106 exit(0);
107
108 /* CSTYLED */
109 for (i = 0;; i++) {
110 eauditon(A_GETSTAT, (caddr_t)&s, NULL);
111 if (timestamp_fmt != NODATE)
112 print_timestamp(timestamp_fmt);
113 display_stats(&s, i);
114 if ((flags & CFLG) && count)
115 if (i == count - 1)
116 break;
117 (void) sleep(interval);
118 }
119
120 return (0);
121 }
122
123
124 static void
125 display_stats(au_stat_t *s, int cnt)
126 {
127 int offset[12]; /* used to line the header up correctly */
128 char buf[512];
129
130 (void) sprintf(buf,
131 "%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u %n%4u%n",
132 s->as_generated, &(offset[0]),
133 s->as_nonattrib, &(offset[1]),
134 s->as_kernel, &(offset[2]),
135 s->as_audit, &(offset[3]),
136 s->as_auditctl, &(offset[4]),
137 s->as_enqueue, &(offset[5]),
138 s->as_written, &(offset[6]),
139 s->as_wblocked, &(offset[7]),
140 s->as_rblocked, &(offset[8]),
141 s->as_dropped, &(offset[9]),
142 s->as_totalsize / ONEK, &(offset[10]),
143 s->as_memused / ONEK, &(offset[11]));
144
145 /* print a properly aligned header every HEADER_MOD lines */
|