Add code to print interrupt statistics when they will be
exported via sysctl.
This commit is contained in:
parent
ec2dc65015
commit
2fbfa5f862
@ -34,6 +34,43 @@
|
||||
|
||||
#define pgtok(a) ((a) * (u_int) pagesize >> 10)
|
||||
|
||||
int
|
||||
vm_i()
|
||||
{
|
||||
#define CNT 49
|
||||
int cnt[CNT];
|
||||
char names[CNT*16];
|
||||
char *a, *namep[CNT*16];
|
||||
int i,len;
|
||||
long long inttotal=0;
|
||||
long uptime=1;
|
||||
|
||||
len=sizeof(cnt);
|
||||
i = sysctlbyname("kern.intrcnt", &cnt, &len, NULL, 0);
|
||||
if (i != 0)
|
||||
return i ;
|
||||
len=sizeof(names);
|
||||
i = sysctlbyname("kern.intrnames", &names, &len, NULL, 0);
|
||||
if (i != 0)
|
||||
return i ;
|
||||
|
||||
for( i=0, a = names ; i < CNT && a < names+sizeof(names) ; ) {
|
||||
namep[i++] = a++;
|
||||
while (a < names+sizeof(names) && *a)
|
||||
a++ ;
|
||||
a++ ; /* skip \0 */
|
||||
}
|
||||
printf("interrupt total rate\n");
|
||||
inttotal = 0;
|
||||
for (i=0; i< CNT ; i++)
|
||||
if (cnt[i] >0) {
|
||||
printf("%-12s %20lu %10lu\n", namep[i], cnt[i], cnt[i]/uptime);
|
||||
inttotal += cnt[i];
|
||||
}
|
||||
printf("Total %20llu %10llu\n", inttotal,
|
||||
inttotal / (u_int64_t) uptime);
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -41,6 +78,11 @@ main(int argc, char *argv[])
|
||||
int pagesize, pagesize_len;
|
||||
struct vmtotal v;
|
||||
|
||||
if (argc > 1 && !strcmp(argv[1], "-i")) {
|
||||
if (vm_i())
|
||||
fprintf(stderr, "vm -i stats not available via sysctl\n");
|
||||
return 0 ;
|
||||
}
|
||||
pagesize_len = sizeof(int);
|
||||
sysctlbyname("vm.stats.vm.v_page_size",&pagesize,&pagesize_len,NULL,0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user