vm.c revision 38589
138589Sabial/*-
238589Sabial * Copyright (c) 1998 Andrzej Bialecki
338589Sabial * All rights reserved.
438589Sabial *
538589Sabial * Redistribution and use in source and binary forms, with or without
638589Sabial * modification, are permitted provided that the following conditions
738589Sabial * are met:
838589Sabial * 1. Redistributions of source code must retain the above copyright
938589Sabial *    notice, this list of conditions and the following disclaimer.
1038589Sabial * 2. Redistributions in binary form must reproduce the above copyright
1138589Sabial *    notice, this list of conditions and the following disclaimer in the
1238589Sabial *    documentation and/or other materials provided with the distribution.
1338589Sabial *
1438589Sabial * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1538589Sabial * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1638589Sabial * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1738589Sabial * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1838589Sabial * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1938589Sabial * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2038589Sabial * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2138589Sabial * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2238589Sabial * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2338589Sabial * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2438589Sabial * SUCH DAMAGE.
2538589Sabial *
2638589Sabial *	$Id: vm.c,v 1.1.1.1 1998/07/14 07:30:54 abial Exp $
2738589Sabial */
2838589Sabial
2938589Sabial#include <stdio.h>
3038589Sabial#include <sys/types.h>
3138589Sabial#include <sys/sysctl.h>
3238589Sabial#include <sys/vmmeter.h>
3338589Sabial#include <vm/vm_param.h>
3438589Sabial
3538589Sabialint
3638589Sabialmain(int argc, char *argv[])
3738589Sabial{
3838589Sabial	int mib[2],i=0,len;
3938589Sabial	struct vmtotal v;
4038589Sabial
4138589Sabial	len=sizeof(struct vmtotal);
4238589Sabial	mib[0]=CTL_VM;
4338589Sabial	mib[1]=VM_METER;
4438589Sabial	for(;;) {
4538589Sabial		sysctl(mib,2,&v,&len,NULL,0);
4638589Sabial		if(i==0) {
4738589Sabial			printf("  procs    kB virt mem      real mem     shared vm   shared real    free\n");
4838589Sabial			printf(" r d p s    tot    act    tot    act    tot    act    tot    act\n");
4938589Sabial		}
5038589Sabial		printf("%2hu%2hu%2hu%2hu",v.t_rq,v.t_dw,v.t_pw,v.t_sl);
5138589Sabial		printf("%7u%7u%7u%7u",
5238589Sabial		v.t_vm<<2,v.t_avm<<2,v.t_rm<<2,v.t_arm<<2);
5338589Sabial		printf("%7u%7u%7u%7u%7u\n",
5438589Sabial		v.t_vmshr<<2,v.t_avmshr<<2,v.t_rmshr<<2,v.t_armshr<<2,v.t_free<<2);
5538589Sabial		sleep(5);
5638589Sabial		i++;
5738589Sabial		if(i>22) i=0;
5838589Sabial	}
5938589Sabial	exit(0);
6038589Sabial
6138589Sabial}
62