vm.c revision 38589
11543Srgrimes/*-
21543Srgrimes * Copyright (c) 1998 Andrzej Bialecki
31543Srgrimes * All rights reserved.
41543Srgrimes *
51543Srgrimes * Redistribution and use in source and binary forms, with or without
61543Srgrimes * modification, are permitted provided that the following conditions
71543Srgrimes * are met:
81543Srgrimes * 1. Redistributions of source code must retain the above copyright
91543Srgrimes *    notice, this list of conditions and the following disclaimer.
101543Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111543Srgrimes *    notice, this list of conditions and the following disclaimer in the
121543Srgrimes *    documentation and/or other materials provided with the distribution.
131543Srgrimes *
141543Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
151543Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161543Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171543Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
181543Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
191543Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
201543Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
211543Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
221543Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
231543Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
241543Srgrimes * SUCH DAMAGE.
251543Srgrimes *
261543Srgrimes *	$Id: vm.c,v 1.1.1.1 1998/07/14 07:30:54 abial Exp $
271543Srgrimes */
281543Srgrimes
291543Srgrimes#include <stdio.h>
301543Srgrimes#include <sys/types.h>
311543Srgrimes#include <sys/sysctl.h>
321543Srgrimes#include <sys/vmmeter.h>
331543Srgrimes#include <vm/vm_param.h>
3450477Speter
351543Srgrimesint
361543Srgrimesmain(int argc, char *argv[])
379343Sbde{
389343Sbde	int mib[2],i=0,len;
392166Spaul	struct vmtotal v;
401543Srgrimes
411543Srgrimes	len=sizeof(struct vmtotal);
421543Srgrimes	mib[0]=CTL_VM;
431543Srgrimes	mib[1]=VM_METER;
441543Srgrimes	for(;;) {
451543Srgrimes		sysctl(mib,2,&v,&len,NULL,0);
469343Sbde		if(i==0) {
479343Sbde			printf("  procs    kB virt mem      real mem     shared vm   shared real    free\n");
481543Srgrimes			printf(" r d p s    tot    act    tot    act    tot    act    tot    act\n");
491543Srgrimes		}
501543Srgrimes		printf("%2hu%2hu%2hu%2hu",v.t_rq,v.t_dw,v.t_pw,v.t_sl);
511543Srgrimes		printf("%7u%7u%7u%7u",
521543Srgrimes		v.t_vm<<2,v.t_avm<<2,v.t_rm<<2,v.t_arm<<2);
531543Srgrimes		printf("%7u%7u%7u%7u%7u\n",
541543Srgrimes		v.t_vmshr<<2,v.t_avmshr<<2,v.t_rmshr<<2,v.t_armshr<<2,v.t_free<<2);
551543Srgrimes		sleep(5);
561543Srgrimes		i++;
5751792Smarcel		if(i>22) i=0;
5851792Smarcel	}
5951792Smarcel	exit(0);
6051792Smarcel
6151792Smarcel}
6251792Smarcel