xref: /csrg-svn/local/local.cmd/la.c (revision 38185)
138183Smckusick /*
238183Smckusick  * Copyright (c) 1989 The Regents of the University of California.
338183Smckusick  * All rights reserved.
438183Smckusick  *
538183Smckusick  * Redistribution and use in source and binary forms are permitted
638183Smckusick  * provided that the above copyright notice and this paragraph are
738183Smckusick  * duplicated in all such forms and that any documentation,
838183Smckusick  * advertising materials, and other materials related to such
938183Smckusick  * distribution and use acknowledge that the software was developed
1038183Smckusick  * by the University of California, Berkeley.  The name of the
1138183Smckusick  * University may not be used to endorse or promote products derived
1238183Smckusick  * from this software without specific prior written permission.
1338183Smckusick  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1438183Smckusick  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1538183Smckusick  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1638183Smckusick  */
1738183Smckusick 
1838183Smckusick #ifndef lint
1938183Smckusick char copyright[] =
2038183Smckusick "@(#) Copyright (c) 1989 The Regents of the University of California.\n\
2138183Smckusick  All rights reserved.\n";
2238183Smckusick #endif /* not lint */
2338183Smckusick 
2438183Smckusick #ifndef lint
25*38185Smckusick static char sccsid[] = "@(#)la.c	6.2 (Berkeley) 05/29/89";
2638183Smckusick #endif /* not lint */
2738183Smckusick 
2838183Smckusick /*
2938183Smckusick  * la - print load averages
3038183Smckusick  */
3138183Smckusick #include <stdio.h>
3238183Smckusick 
3338183Smckusick double	avenrun[3];
3438183Smckusick 
main(argc,argv)3538183Smckusick main(argc,argv)
36*38185Smckusick 	int argc;
37*38185Smckusick 	char *argv[];
3838183Smckusick {
3938183Smckusick 	register int kmem, mem;
4038183Smckusick 
41*38185Smckusick 	if (getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0])) < 0) {
42*38185Smckusick 		fprintf(stderr, "%s: getloadavg: failed\n", argv[0]);
4338183Smckusick 		exit(1);
4438183Smckusick 	}
45*38185Smckusick 
46*38185Smckusick 	if ((argc > 1) && (! strcmp (argv[1],"-g"))) {
47*38185Smckusick 		printf("1    5    15\n");
48*38185Smckusick 		printf("Min  Min  Min\n");
49*38185Smckusick 		printf("-------------\n");
5038183Smckusick 	}
5138183Smckusick 	printf("%.2f %.2f %.2f\n", avenrun[0], avenrun[1], avenrun[2]);
5238183Smckusick }
53