5 #include <sys/socket.h>
7 #include <sys/sysctl.h>
10 #include <machine/apmvar.h>
11 #include <sys/ioctl.h>
12 #include <uvm/uvm_param.h>
13 #include <uvm/uvm_extern.h>
26 void (*statfn[])(int) =
44 if(getloadavg(l, 3) < 0)
46 Bprint(&bout, "load =%d 1000\n", (int)(l[0]*1000.0));
53 struct apm_power_info ai;
56 fd = open("/dev/apm", OREAD);
60 if(ioctl(fd, APM_IOC_GETPOWER, &ai) < 0)
63 if(ai.battery_life <= 100)
64 Bprint(&bout, "battery =%d 100\n", ai.battery_life);
70 ulong out, in, outb, inb, err;
71 struct ifaddrs *ifa, *ifap;
72 struct if_data *ifd = NULL;
77 out = in = outb = inb = err = 0;
79 if (getifaddrs(&ifap) == -1)
82 for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
83 if (ifa->ifa_addr == NULL ||
84 ifa->ifa_addr->sa_family != AF_LINK)
90 out += ifd->ifi_opackets;
91 in += ifd->ifi_ipackets;
92 outb += ifd->ifi_obytes;
93 inb += ifd->ifi_ibytes;
94 err += ifd->ifi_ierrors;
98 Bprint(&bout, "etherin %lud 1000\n", in);
99 Bprint(&bout, "etherout %lud 1000\n", out);
100 Bprint(&bout, "etherinb %lud 1000000\n", inb);
101 Bprint(&bout, "etheroutb %lud 1000000\n", outb);
102 Bprint(&bout, "ethererr %lud 1000\n", err);
103 Bprint(&bout, "ether %lud 1000\n", in+out);
104 Bprint(&bout, "etherb %lud 1000000\n", inb+outb);
114 struct clockinfo *ci;
120 mib[1] = KERN_CLOCKRATE;
122 sysctl(mib, 2, (char *)&x, &l, nil, 0);
127 ci = (struct clockinfo*)x;
134 mib[1] = KERN_CPTIME;
136 sysctl(mib, 2, (char *)&x, &l, nil, 0);
137 if (l < 5*sizeof(ulong))
141 Bprint(&bout, "user %lud %d\n", x[CP_USER]+x[CP_NICE], stathz);
142 Bprint(&bout, "sys %lud %d\n", x[CP_SYS], stathz);
143 Bprint(&bout, "cpu %lud %d\n", x[CP_USER]+x[CP_NICE]+x[CP_SYS], stathz);
144 Bprint(&bout, "idle %lud %d\n", x[CP_IDLE], stathz);
158 sysctl(mib, 2, &vm, &l, nil, 0);
163 pgsize = vm.pagesize;
165 Bprint(&bout, "mem =%lud %lud\n", vm.active*pgsize, vm.npages*pgsize);
166 Bprint(&bout, "context %lud 1000\n", vm.swtch);
167 Bprint(&bout, "syscall %lud 1000\n", vm.syscalls);
168 Bprint(&bout, "intr %lud 1000\n", vm.intrs+vm.traps);
169 Bprint(&bout, "fault %lud 1000\n", vm.faults);
171 Bprint(&bout, "fork %ud 1000\n", vm.forks);
172 Bprint(&bout, "swap =%lud %lud\n", vm.swpginuse*pgsize, vm.swpages*pgsize);