1 --- procps-3.2.7/vmstat.c 2008-12-11 22:11:30.042532106 -0500
2 +++ procps-3.2.7/vmstat.c.timestamp 2008-12-11 22:08:11.553529883 -0500
9 #include "proc/sysinfo.h"
10 #include "proc/version.h"
13 static unsigned int height; // window height
14 static unsigned int moreheaders=TRUE;
15 +static unsigned int showtimestamp=FALSE;
18 /////////////////////////////////////////////////////////////////////////
20 fprintf(stderr," -p prints disk partition statistics\n");
21 fprintf(stderr," -s prints vm table\n");
22 fprintf(stderr," -m prints slabinfo\n");
23 + fprintf(stderr," -t add timestamp to output\n");
24 fprintf(stderr," -S unit size\n");
25 fprintf(stderr," delay is the delay between updates in seconds. \n");
26 fprintf(stderr," unit size k:1000 K:1024 m:1000000 M:1048576 (default is K)\n");
28 ////////////////////////////////////////////////////////////////////////////
30 static void new_header(void){
31 - printf("procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----\n");
33 + printf("procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----\n");
35 + printf("procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ ---timestamp---\n");
38 "%2s %2s %6s %6s %6s %6s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s\n",
41 ////////////////////////////////////////////////////////////////////////////
43 static void new_format(void) {
44 - const char format[]="%2u %2u %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u\n";
45 + const char format[]="%2u %2u %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u\t%s\n";
46 unsigned int tog=0; /* toggle switch for cleaner code */
48 unsigned int hz = Hertz;
50 unsigned int sleep_half;
51 unsigned long kb_per_page = sysconf(_SC_PAGESIZE) / 1024ul;
52 int debt = 0; // handle idle ticks running backwards
58 sleep_half=(sleep_time/2);
66 + (void) time( &the_time );
67 + tm_ptr = localtime( &the_time );
68 + strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S %Z", tm_ptr);
71 duse= *cpu_use + *cpu_nic;
72 dsys= *cpu_sys + *cpu_xxx + *cpu_yyy;
75 (unsigned)( (100*dsys + divo2) / Div ),
76 (unsigned)( (100*didl + divo2) / Div ),
77 (unsigned)( (100*diow + divo2) / Div ),
78 - (unsigned)( (100*dstl + divo2) / Div )
79 + (unsigned)( (100*dstl + divo2) / Div ),
83 for(i=1;i<num_updates;i++) { /* \\\\\\\\\\\\\\\\\\\\ main loop ////////////////// */
90 + (void) time( &the_time );
91 + tm_ptr = localtime( &the_time );
92 + strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S %Z", tm_ptr);
95 duse= cpu_use[tog]-cpu_use[!tog] + cpu_nic[tog]-cpu_nic[!tog];
96 dsys= cpu_sys[tog]-cpu_sys[!tog] + cpu_xxx[tog]-cpu_xxx[!tog] + cpu_yyy[tog]-cpu_yyy[!tog];
97 didl= cpu_idl[tog]-cpu_idl[!tog];
99 (unsigned)( (100*dsys+divo2)/Div ), /*sy*/
100 (unsigned)( (100*didl+divo2)/Div ), /*id*/
101 (unsigned)( (100*diow+divo2)/Div ), //wa
102 - (unsigned)( (100*dstl+divo2)/Div ) //st
103 + (unsigned)( (100*dstl+divo2)/Div ), //st
104 + timebuf /* timestamp */
110 statMode |= VMSUMSTAT;
113 + showtimestamp=TRUE;
116 /* no other aguments defined yet. */