Date: Tue, 16 Oct 2007 11:52:58 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 127599 for review Message-ID: <200710161152.l9GBqwRl016243@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=127599 Change 127599 by zec@zec_tca51 on 2007/10/16 11:52:06 Rearrange output of "vimage -l" so that less lines are consumed, and reintroduce the output of CPU average use. Affected files ... .. //depot/projects/vimage/src/usr.sbin/vimage/vimage.c#5 edit Differences ... ==== //depot/projects/vimage/src/usr.sbin/vimage/vimage.c#5 (text+ko) ==== @@ -64,43 +64,39 @@ { double lf = 1.0/vi_req->averunnable.fscale; - printf ("\"%s\":\n", vi_req->vi_name); - printf (" Processes (current/max): %d/%d\n", + printf("\"%s\":\n", vi_req->vi_name); + printf(" Processes (cur/max): %d/%d;", vi_req->vi_proc_count, vi_req->vi_proc_limit); - printf (" load averages: %3.2f, %3.2f, %3.2f\n", + printf(" load averages: %3.2f, %3.2f, %3.2f\n", lf * vi_req->averunnable.ldavg[0], lf * vi_req->averunnable.ldavg[1], lf * vi_req->averunnable.ldavg[2]); + printf(" CPU usage: %3.2f%%\n", 0.01 * vi_req->cp_time_avg); + + printf(" Sockets (cur/max): %d/%d;", vi_req->vi_sock_count, + vi_req->vi_maxsockets); + printf(" %d network interfaces\n", vi_req->vi_if_count); + #if 0 - printf (" CPU usage: %3.2f%% (", - 0.0001 * vi_req->cp_time_avg[CP_ALL]); - printf ("%3.2f%% user, ", 0.0001 * vi_req->cp_time_avg[CP_USER]); - printf ("%3.2f%% nice, ", 0.0001 * vi_req->cp_time_avg[CP_NICE]); - printf ("%3.2f%% sys, ",0.0001 * vi_req->cp_time_avg[CP_SYS]); - printf ("%3.2f%% intr)\n",0.0001 * vi_req->cp_time_avg[CP_INTR]); - - printf (" CPU limits: min %3.2f%%, ", 0.0001 * vi_req->vi_cpu_min); + printf(" CPU limits: min %3.2f%%, ", 0.0001 * vi_req->vi_cpu_min); if (vi_req->vi_cpu_max == 0) vi_req->vi_cpu_max = 1000000; - printf ("max %3.2f%%, ", 0.0001 * vi_req->vi_cpu_max); - printf ("weight %d, ", vi_req->vi_cpu_weight); + printf("max %3.2f%%, ", 0.0001 * vi_req->vi_cpu_max); + printf("weight %d, ", vi_req->vi_cpu_weight); if (vi_req->vi_intr_limit) - printf ("intr limit: %3.2f%%\n", + printf("intr limit: %3.2f%%\n", 0.0001 * vi_req->vi_intr_limit); else - printf ("no intr limit\n"); -#endif + printf("no intr limit\n"); if (vi_req->vi_child_limit) - printf (" child limit: %d\n", vi_req->vi_child_limit); - printf(" Sockets (current/max): %d/%d\n", vi_req->vi_sock_count, - vi_req->vi_maxsockets); - printf (" %d network interfaces\n", vi_req->vi_if_count); + printf(" child limit: %d\n", vi_req->vi_child_limit); if (vi_req->vi_child_count) - printf (" %d child vimages\n", vi_req->vi_child_count); + printf(" %d child vimages\n", vi_req->vi_child_count); if (vi_req->vi_chroot[0]) - printf (" Chroot dir: %s\n", vi_req->vi_chroot); + printf(" Chroot dir: %s\n", vi_req->vi_chroot); +#endif } @@ -124,7 +120,7 @@ if (s == -1) goto abort; - bzero (&vi_req, sizeof (vi_req)); + bzero(&vi_req, sizeof(vi_req)); if (argc == 1) { vi_req.vi_name[0] = 0; cmd = VI_GET; @@ -162,28 +158,28 @@ if (ioctl(s, SIOCGPVIMAGE, (caddr_t)&vi_req) < 0) goto abort; if (argc==1) - printf ("%s\n", vi_req.vi_name); + printf("%s\n", vi_req.vi_name); else vi_print(&vi_req); - exit (0); + exit(0); case VI_GETNEXT: while (ioctl(s, SIOCGPVIMAGE, (caddr_t)&vi_req) == 0) vi_print(&vi_req); - exit (0); + exit(0); case VI_IFACE: /* here vi_chroot stores the current ifc name */ - strncpy(vi_req.vi_chroot, argv[3], sizeof (vi_req.vi_chroot)); + strncpy(vi_req.vi_chroot, argv[3], sizeof(vi_req.vi_chroot)); if (argc >= 5) strncpy(vi_req.vi_if_xname, argv[4], - sizeof (vi_req.vi_if_xname)); + sizeof(vi_req.vi_if_xname)); else vi_req.vi_if_xname[0] = 0; if (ioctl(s, SIOCSIFVIMAGE, (caddr_t)&vi_req) < 0) goto abort; printf("%s@%s\n", vi_req.vi_chroot, vi_req.vi_name); - exit (0); + exit(0); case VI_CREATE: case VI_MODIFY: @@ -198,7 +194,7 @@ * 10000; if (vi_req.vi_cpu_min > 900000) { fprintf(stderr, "error: cpumin must be between 0 and 90\n"); - exit (1); + exit(1); } } if (strcmp(argv[i], "cpumax")==0) { @@ -208,7 +204,7 @@ if (vi_req.vi_cpu_max<10000 || vi_req.vi_cpu_max>1000000) { fprintf(stderr, "error: cpumax must be between 1 and 100\n"); - exit (1); + exit(1); } } if (strcmp(argv[i], "cpuweight")==0) { @@ -217,7 +213,7 @@ if (vi_req.vi_cpu_weight<1 || vi_req.vi_cpu_weight>10) { fprintf(stderr, "error: cpuweight must be between 1 and 10\n"); - exit (1); + exit(1); } } if (strcmp(argv[i], "intr")==0) { @@ -227,7 +223,7 @@ if (vi_req.vi_intr_limit<10000 || vi_req.vi_intr_limit>1000000) { fprintf(stderr, "error: intr limit must be between 1 and 100\n"); - exit (1); + exit(1); } } if (strcmp(argv[i], "child")==0) { @@ -240,13 +236,13 @@ } if (strcmp(argv[i], "chroot")==0) { vi_req.req_action |= VI_SET_CHROOT; - strncpy (vi_req.vi_chroot, argv[i+1], - sizeof (vi_req.vi_chroot)); + strncpy(vi_req.vi_chroot, argv[i+1], + sizeof(vi_req.vi_chroot)); } } if (ioctl(s, SIOCSPVIMAGE, (caddr_t)&vi_req) < 0) goto abort; - exit (0); + exit(0); case VI_SWITCHTO: strcpy(vi_req.vi_name, argv[1]); @@ -260,26 +256,26 @@ goto abort; close(s); if (argc==2) { - printf ("Switched to vimage %s\n", argv[1]); + printf("Switched to vimage %s\n", argv[1]); if ((shell=getenv("SHELL"))==NULL) - execlp ("/bin/sh",argv[0],NULL); + execlp("/bin/sh",argv[0],NULL); else - execlp (shell,argv[0],NULL); + execlp(shell,argv[0],NULL); } else - execvp (argv[2],&argv[2]); + execvp(argv[2],&argv[2]); break; case VI_DESTROY: if (ioctl(s, SIOCSPVIMAGE, (caddr_t)&vi_req) < 0) goto abort; - exit (0); + exit(0); default: fprintf(stderr, "usage: %s bla bla\n", argv[0]); - exit (1); + exit(1); } abort: - perror ("Error"); + perror("Error"); exit(1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710161152.l9GBqwRl016243>