Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/procps/nmeter.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 17  Line 17 
17  //  totalram=2107416576, freeram=211525632, sharedram=0, bufferram=157204480}  //  totalram=2107416576, freeram=211525632, sharedram=0, bufferram=157204480}
18  //  totalswap=134209536, freeswap=134209536, procs=157})  //  totalswap=134209536, freeswap=134209536, procs=157})
19    
 #include <time.h>  
20  #include "libbb.h"  #include "libbb.h"
21    
22  typedef unsigned long long ullong;  typedef unsigned long long ullong;
# Line 282  static void scale(ullong ul) Line 281  static void scale(ullong ul)
281  #define S_STAT(a) \  #define S_STAT(a) \
282  typedef struct a { \  typedef struct a { \
283   struct s_stat *next; \   struct s_stat *next; \
284   void (*collect)(struct a *s); \   void (*collect)(struct a *s) FAST_FUNC; \
285   const char *label;   const char *label;
286  #define S_STAT_END(a) } a;  #define S_STAT_END(a) } a;
287    
288  S_STAT(s_stat)  S_STAT(s_stat)
289  S_STAT_END(s_stat)  S_STAT_END(s_stat)
290    
291  static void collect_literal(s_stat *s UNUSED_PARAM)  static void FAST_FUNC collect_literal(s_stat *s UNUSED_PARAM)
292  {  {
293  }  }
294    
# Line 326  S_STAT(cpu_stat) Line 325  S_STAT(cpu_stat)
325  S_STAT_END(cpu_stat)  S_STAT_END(cpu_stat)
326    
327    
328  static void collect_cpu(cpu_stat *s)  static void FAST_FUNC collect_cpu(cpu_stat *s)
329  {  {
330   ullong data[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 };   ullong data[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 };
331   unsigned frac[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 };   unsigned frac[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 };
# Line 400  S_STAT(int_stat) Line 399  S_STAT(int_stat)
399   int no;   int no;
400  S_STAT_END(int_stat)  S_STAT_END(int_stat)
401    
402  static void collect_int(int_stat *s)  static void FAST_FUNC collect_int(int_stat *s)
403  {  {
404   ullong data[1];   ullong data[1];
405   ullong old;   ullong old;
# Line 434  S_STAT(ctx_stat) Line 433  S_STAT(ctx_stat)
433   ullong old;   ullong old;
434  S_STAT_END(ctx_stat)  S_STAT_END(ctx_stat)
435    
436  static void collect_ctx(ctx_stat *s)  static void FAST_FUNC collect_ctx(ctx_stat *s)
437  {  {
438   ullong data[1];   ullong data[1];
439   ullong old;   ullong old;
# Line 463  S_STAT(blk_stat) Line 462  S_STAT(blk_stat)
462   ullong old[2];   ullong old[2];
463  S_STAT_END(blk_stat)  S_STAT_END(blk_stat)
464    
465  static void collect_blk(blk_stat *s)  static void FAST_FUNC collect_blk(blk_stat *s)
466  {  {
467   ullong data[2];   ullong data[2];
468   int i;   int i;
# Line 505  S_STAT(fork_stat) Line 504  S_STAT(fork_stat)
504   ullong old;   ullong old;
505  S_STAT_END(fork_stat)  S_STAT_END(fork_stat)
506    
507  static void collect_thread_nr(fork_stat *s UNUSED_PARAM)  static void FAST_FUNC collect_thread_nr(fork_stat *s UNUSED_PARAM)
508  {  {
509   ullong data[1];   ullong data[1];
510    
# Line 516  static void collect_thread_nr(fork_stat Line 515  static void collect_thread_nr(fork_stat
515   scale(data[0]);   scale(data[0]);
516  }  }
517    
518  static void collect_fork(fork_stat *s)  static void FAST_FUNC collect_fork(fork_stat *s)
519  {  {
520   ullong data[1];   ullong data[1];
521   ullong old;   ullong old;
# Line 550  S_STAT(if_stat) Line 549  S_STAT(if_stat)
549   char *device_colon;   char *device_colon;
550  S_STAT_END(if_stat)  S_STAT_END(if_stat)
551    
552  static void collect_if(if_stat *s)  static void FAST_FUNC collect_if(if_stat *s)
553  {  {
554   ullong data[4];   ullong data[4];
555   int i;   int i;
# Line 625  S_STAT_END(mem_stat) Line 624  S_STAT_END(mem_stat)
624  //HugePages_Total:     0  //HugePages_Total:     0
625  //HugePages_Free:      0  //HugePages_Free:      0
626  //Hugepagesize:     4096 kB  //Hugepagesize:     4096 kB
627  static void collect_mem(mem_stat *s)  static void FAST_FUNC collect_mem(mem_stat *s)
628  {  {
629   ullong m_total = 0;   ullong m_total = 0;
630   ullong m_free = 0;   ullong m_free = 0;
# Line 672  static s_stat* init_mem(const char *para Line 671  static s_stat* init_mem(const char *para
671  S_STAT(swp_stat)  S_STAT(swp_stat)
672  S_STAT_END(swp_stat)  S_STAT_END(swp_stat)
673    
674  static void collect_swp(swp_stat *s UNUSED_PARAM)  static void FAST_FUNC collect_swp(swp_stat *s UNUSED_PARAM)
675  {  {
676   ullong s_total[1];   ullong s_total[1];
677   ullong s_free[1];   ullong s_free[1];
# Line 696  static s_stat* init_swp(const char *para Line 695  static s_stat* init_swp(const char *para
695  S_STAT(fd_stat)  S_STAT(fd_stat)
696  S_STAT_END(fd_stat)  S_STAT_END(fd_stat)
697    
698  static void collect_fd(fd_stat *s UNUSED_PARAM)  static void FAST_FUNC collect_fd(fd_stat *s UNUSED_PARAM)
699  {  {
700   ullong data[2];   ullong data[2];
701    
# Line 721  S_STAT(time_stat) Line 720  S_STAT(time_stat)
720   int scale;   int scale;
721  S_STAT_END(time_stat)  S_STAT_END(time_stat)
722    
723  static void collect_time(time_stat *s)  static void FAST_FUNC collect_time(time_stat *s)
724  {  {
725   char buf[sizeof("12:34:56.123456")];   char buf[sizeof("12:34:56.123456")];
726   struct tm* tm;   struct tm* tm;
# Line 756  static s_stat* init_time(const char *par Line 755  static s_stat* init_time(const char *par
755   return (s_stat*)s;   return (s_stat*)s;
756  }  }
757    
758  static void collect_info(s_stat *s)  static void FAST_FUNC collect_info(s_stat *s)
759  {  {
760   gen ^= 1;   gen ^= 1;
761   while (s) {   while (s) {
# Line 786  static init_func *const init_functions[] Line 785  static init_func *const init_functions[]
785  };  };
786    
787  int nmeter_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;  int nmeter_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
788  int nmeter_main(int argc, char **argv)  int nmeter_main(int argc UNUSED_PARAM, char **argv)
789  {  {
790   char buf[32];   char buf[32];
791   s_stat *first = NULL;   s_stat *first = NULL;
# Line 798  int nmeter_main(int argc, char **argv) Line 797  int nmeter_main(int argc, char **argv)
797    
798   xchdir("/proc");   xchdir("/proc");
799    
800   if (argc != 2)   if (!argv[1])
801   bb_show_usage();   bb_show_usage();
802    
803   if (open_read_close("version", buf, sizeof(buf)-1) > 0) {   if (open_read_close("version", buf, sizeof(buf)-1) > 0) {

Legend:
Removed from v.983  
changed lines
  Added in v.984