From 8618adeaaff567743b79b7bbeb6f931499c724e3 Mon Sep 17 00:00:00 2001 From: albert <> Date: Sun, 10 Aug 2003 23:40:41 +0000 Subject: [PATCH] got most of procps-3.1.11ff2.diff --- proc/ksym.c | 2 + proc/library.map | 2 +- proc/sysinfo.c | 17 +++++ proc/sysinfo.h | 2 + procps.spec | 2 +- vmstat.8 | 16 ++++- vmstat.c | 180 +++++++++++++++++++++++++++++++++++++++++------ 7 files changed, 197 insertions(+), 24 deletions(-) diff --git a/proc/ksym.c b/proc/ksym.c index dd4d52e1..bf1d6358 100644 --- a/proc/ksym.c +++ b/proc/ksym.c @@ -607,6 +607,8 @@ const char * wchan(unsigned KLONG address, unsigned pid) { /* good_symb->name has the data, but needs to be trimmed */ ret = good_symb->name; + // lame ppc64 has a '.' in front of every name + if(*ret=='.') ret++; switch(*ret){ case 's': if(!strncmp(ret, "sys_", 4)) ret += 4; break; case 'd': if(!strncmp(ret, "do_", 3)) ret += 3; break; diff --git a/proc/library.map b/proc/library.map index 557d5ac8..52ebcc28 100644 --- a/proc/library.map +++ b/proc/library.map @@ -10,7 +10,7 @@ global: Hertz; smp_num_cpus; sprint_uptime; uptime; user_from_uid; print_uptime; loadavg; pretty_print_signals; print_given_signals; unix_print_signals; signal_name_to_number; signal_number_to_name; - meminfo; vminfo; getstat; getdiskstat; getslabinfo; get_pid_digits; + meminfo; vminfo; getstat; getdiskstat; getpartitions_num; getslabinfo; get_pid_digits; kb_active; kb_inactive; kb_main_buffers; kb_main_cached; kb_main_free; kb_main_total; kb_main_used; kb_swap_free; kb_swap_total; kb_swap_used; kb_main_shared; diff --git a/proc/sysinfo.c b/proc/sysinfo.c index e2a5b7ac..02b58a51 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -671,6 +671,21 @@ static unsigned int getFileLines(const char* szFile){ return lines; } +///////////////////////////////////////////////////////////////////////////// + +unsigned int getpartitions_num(struct disk_stat *disks, int ndisks){ + int i=0; + int partitions=0; + + for (i=0;i. -Diskstat,slab mode and some improvements by Fabian Frederick +Fabian Fr\('ed\('erick (diskstat, slab, partitions...) diff --git a/vmstat.c b/vmstat.c index d7a13c16..4a6ecc78 100644 --- a/vmstat.c +++ b/vmstat.c @@ -1,12 +1,16 @@ // old: "Copyright 1994 by Henry Ware . Copyleft same year." // most code copyright 2002 Albert Cahalan -// 27/05/2003 (Fabian) : Add unit conversion + interface +// +// 27/05/2003 (Fabian Frederick) : Add unit conversion + interface // Export proc/stat access to libproc // Adapt vmstat helpfile // 31/05/2003 (Fabian) : Add diskstat support (/libproc) // June 2003 (Fabian) : -S -s & -s -S patch // June 2003 (Fabian) : -Adding diskstat against 3.1.9, slabinfo // -patching 'header' in disk & slab +// July 2003 (Fabian) : -Adding disk partition output +// -Adding disk table +// -Syncing help / usage #include #include @@ -26,16 +30,18 @@ static unsigned long dataUnit=1024; static char szDataUnit [16]; -#define UNIT_B 1 -#define UNIT_k 1000 -#define UNIT_K 1024 -#define UNIT_m 1000000 -#define UNIT_M 1048576 +#define UNIT_B 1 +#define UNIT_k 1000 +#define UNIT_K 1024 +#define UNIT_m 1000000 +#define UNIT_M 1048576 -#define VMSTAT 0 -#define DISKSTAT 0x00000001 -#define VMSUMSTAT 0x00000002 -#define SLABSTAT 0x00000004 +#define VMSTAT 0 +#define DISKSTAT 0x00000001 +#define VMSUMSTAT 0x00000002 +#define SLABSTAT 0x00000004 +#define PARTITIONSTAT 0x00000008 +#define DISKSUMSTAT 0x00000010 static int statMode=VMSTAT; @@ -60,6 +66,9 @@ static void usage(void) { fprintf(stderr," -n causes the headers not to be reprinted regularly.\n"); fprintf(stderr," -a print inactive/active page stats.\n"); fprintf(stderr," -d prints disk statistics\n"); + fprintf(stderr," -D prints disk table\n"); + fprintf(stderr," -p prints disk partition statistics\n"); + fprintf(stderr," -s prints vm table\n"); fprintf(stderr," -m prints slabinfo\n"); fprintf(stderr," -S unit size\n"); fprintf(stderr," delay is the delay between updates in seconds. \n"); @@ -137,6 +146,8 @@ static int format_1000(unsigned long long val64, char *restrict dst){ } #endif +//////////////////////////////////////////////////////////////////////////// + static void new_header(void){ printf("procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----\n"); printf( @@ -161,11 +172,16 @@ static void new_diskheader(void){ //////////////////////////////////////////////////////////////////////////// +static void new_diskpartition_header(const char *partition_name){ + printf("%-10s %10s %10s %10s %10s\n",partition_name, "reads ", "read sectors", "writes ", "requested writes"); +} + +//////////////////////////////////////////////////////////////////////////// + static void new_slabheader(void){ printf("%-24s %6s %6s %6s %6s\n","Cache","Num", "Total", "Size", "Pages"); } - //////////////////////////////////////////////////////////////////////////// static unsigned long unitConvert(unsigned int size){ @@ -274,6 +290,59 @@ static void new_format(void) { //////////////////////////////////////////////////////////////////////////// +static int new_diskpartition_format(const char* partition_name){ + FILE *fDiskstat; + struct disk_stat *disks; + struct partition_stat *partitions, *current_partition=NULL; + unsigned long ndisks,i,j,k,npartitions; + const char format[]="%20u %10llu %10u %10u\n"; + + if ((fDiskstat=fopen("/proc/diskstats", "rb"))){ + fclose(fDiskstat); + ndisks=getdiskstat(&disks,&partitions); + npartitions=getpartitions_num(disks, ndisks); + for(k=0; kreads,current_partition->reads_sectors,current_partition->writes,current_partition->requested_writes); + fflush(stdout); + free(disks); + free(partitions); + for(j=1; jreads,current_partition->reads_sectors,current_partition->writes,current_partition->requested_writes); + fflush(stdout); + free(disks); + free(partitions); + } + }else{ + fprintf(stderr, "Your kernel doesn't support diskstat (2.5.70 or above required)"); + exit(0); + } +} + +//////////////////////////////////////////////////////////////////////////// + static void new_diskformat(void){ FILE *fDiskstat; struct disk_stat *disks; @@ -366,6 +435,57 @@ static void new_slabformat (void){ //////////////////////////////////////////////////////////////////////////// +static void disksum_format(void) { + + FILE *fDiskstat; + struct disk_stat *disks; + struct partition_stat *partitions; + int ndisks, i; + unsigned long reads, merged_reads, read_sectors, milli_reading, writes, + merged_writes, written_sectors, milli_writing, inprogress_IO, + milli_spent_IO, weighted_milli_spent_IO; + + reads=merged_reads=read_sectors=milli_reading=writes=merged_writes= \ + written_sectors=milli_writing=inprogress_IO=milli_spent_IO= \ + weighted_milli_spent_IO=0; + + if ((fDiskstat=fopen("/proc/diskstats", "rb"))){ + fclose(fDiskstat); + ndisks=getdiskstat(&disks, &partitions); + printf("%13d disks \n", ndisks); + printf("%13d partitions \n", getpartitions_num(disks, ndisks)); + + for(i=0; i