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 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 /*
29 * rstat service: built with rstat.x
30 */
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <stdarg.h>
35 #include <string.h>
36 #include <signal.h>
37 #include <utmpx.h>
38 #include <nlist.h>
39 #include <fcntl.h>
40 #include <syslog.h>
41 #include <kstat.h>
42
43 #include <rpc/rpc.h>
44
45 #include <sys/socket.h>
46 #include <sys/cpuvar.h>
47 #include <sys/sysinfo.h>
352 CPU_STAT(&cpu_stats_all.sys, "cpu_ticks_idle"));
353 fprintf(stderr, "cp_time: %d %d %d %d\n",
354 stats_s3.cp_time[RSTAT_CPU_USER],
355 stats_s3.cp_time[RSTAT_CPU_NICE],
356 stats_s3.cp_time[RSTAT_CPU_SYS],
357 stats_s3.cp_time[RSTAT_CPU_IDLE]);
358 #endif
359
360 /* current time */
361 gettimeofday((struct timeval *)&stats_s3.curtime, NULL);
362 stats_s4.curtime = stats_s3.curtime;
363
364 stats_s2.v_pgpgin =
365 stats_s3.v_pgpgin =
366 stats_s4.v_pgpgin = CPU_STAT(&cpu_stats_all.vm, "pgpgin");
367 stats_s2.v_pgpgout =
368 stats_s3.v_pgpgout =
369 stats_s4.v_pgpgout = CPU_STAT(&cpu_stats_all.vm, "pgpgout");
370 stats_s2.v_pswpin =
371 stats_s3.v_pswpin =
372 stats_s4.v_pswpin = CPU_STAT(&cpu_stats_all.vm, "pgswapin");
373 stats_s2.v_pswpout =
374 stats_s3.v_pswpout =
375 stats_s4.v_pswpout = CPU_STAT(&cpu_stats_all.vm, "pgswapout");
376 stats_s3.v_intr = CPU_STAT(&cpu_stats_all.sys, "intr");
377 stats_s3.v_intr -= hz*(stats_s3.curtime.tv_sec - btm.tv_sec) +
378 hz*(stats_s3.curtime.tv_usec - btm.tv_usec)/1000000;
379 stats_s2.v_intr =
380 stats_s4.v_intr = stats_s3.v_intr;
381 /* swtch not in V1 */
382 stats_s2.v_swtch =
383 stats_s3.v_swtch =
384 stats_s4.v_swtch = CPU_STAT(&cpu_stats_all.sys, "pswitch");
385
386 #ifdef DEBUG
387 fprintf(stderr,
388 "pgin: %d pgout: %d swpin: %d swpout: %d intr: %d swtch: %d\n",
389 stats_s3.v_pgpgin,
390 stats_s3.v_pgpgout,
391 stats_s3.v_pswpin,
392 stats_s3.v_pswpout,
393 stats_s3.v_intr,
394 stats_s3.v_swtch);
395 #endif
|
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 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * rstat service: built with rstat.x
28 */
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <stdarg.h>
33 #include <string.h>
34 #include <signal.h>
35 #include <utmpx.h>
36 #include <nlist.h>
37 #include <fcntl.h>
38 #include <syslog.h>
39 #include <kstat.h>
40
41 #include <rpc/rpc.h>
42
43 #include <sys/socket.h>
44 #include <sys/cpuvar.h>
45 #include <sys/sysinfo.h>
350 CPU_STAT(&cpu_stats_all.sys, "cpu_ticks_idle"));
351 fprintf(stderr, "cp_time: %d %d %d %d\n",
352 stats_s3.cp_time[RSTAT_CPU_USER],
353 stats_s3.cp_time[RSTAT_CPU_NICE],
354 stats_s3.cp_time[RSTAT_CPU_SYS],
355 stats_s3.cp_time[RSTAT_CPU_IDLE]);
356 #endif
357
358 /* current time */
359 gettimeofday((struct timeval *)&stats_s3.curtime, NULL);
360 stats_s4.curtime = stats_s3.curtime;
361
362 stats_s2.v_pgpgin =
363 stats_s3.v_pgpgin =
364 stats_s4.v_pgpgin = CPU_STAT(&cpu_stats_all.vm, "pgpgin");
365 stats_s2.v_pgpgout =
366 stats_s3.v_pgpgout =
367 stats_s4.v_pgpgout = CPU_STAT(&cpu_stats_all.vm, "pgpgout");
368 stats_s2.v_pswpin =
369 stats_s3.v_pswpin =
370 stats_s4.v_pswpin = 0;
371 stats_s2.v_pswpout =
372 stats_s3.v_pswpout =
373 stats_s4.v_pswpout = 0;
374 stats_s3.v_intr = CPU_STAT(&cpu_stats_all.sys, "intr");
375 stats_s3.v_intr -= hz*(stats_s3.curtime.tv_sec - btm.tv_sec) +
376 hz*(stats_s3.curtime.tv_usec - btm.tv_usec)/1000000;
377 stats_s2.v_intr =
378 stats_s4.v_intr = stats_s3.v_intr;
379 /* swtch not in V1 */
380 stats_s2.v_swtch =
381 stats_s3.v_swtch =
382 stats_s4.v_swtch = CPU_STAT(&cpu_stats_all.sys, "pswitch");
383
384 #ifdef DEBUG
385 fprintf(stderr,
386 "pgin: %d pgout: %d swpin: %d swpout: %d intr: %d swtch: %d\n",
387 stats_s3.v_pgpgin,
388 stats_s3.v_pgpgout,
389 stats_s3.v_pswpin,
390 stats_s3.v_pswpout,
391 stats_s3.v_intr,
392 stats_s3.v_swtch);
393 #endif
|