This source file includes following definitions.
- init
- fini
- query
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 #include "opal_config.h"
  23 #include "opal/constants.h"
  24 
  25 #ifdef HAVE_UNISTD_H
  26 #include <unistd.h>
  27 #endif
  28 #include <string.h>
  29 #ifdef HAVE_SYS_TIME_H
  30 #include <sys/time.h>
  31 #endif
  32 
  33 #include "opal/mca/pstat/pstat.h"
  34 #include "opal/mca/pstat/base/base.h"
  35 #include "opal/util/string_copy.h"
  36 
  37 #include "pstat_test.h"
  38 
  39 static int init(void);
  40 static int query(pid_t pid,
  41                  opal_pstats_t *stats,
  42                  opal_node_stats_t *nstats);
  43 static int fini(void);
  44 
  45 
  46 
  47 
  48 const opal_pstat_base_module_t opal_pstat_test_module = {
  49     init,
  50     query,
  51     fini
  52 };
  53 
  54 static int init(void)
  55 {
  56     return OPAL_SUCCESS;
  57 }
  58 
  59 static int fini(void)
  60 {
  61     return OPAL_SUCCESS;
  62 }
  63 
  64 static int query(pid_t pid,
  65                  opal_pstats_t *stats,
  66                  opal_node_stats_t *nstats)
  67 {
  68     double dtime;
  69     char hostname[OPAL_MAXHOSTNAMELEN];
  70 
  71     if (NULL != stats) {
  72         
  73         gettimeofday(&stats->sample_time, NULL);
  74         
  75 
  76 
  77         if (NULL != nstats) {
  78             nstats->sample_time.tv_sec = stats->sample_time.tv_sec;
  79             nstats->sample_time.tv_usec = stats->sample_time.tv_usec;
  80         }
  81     } else if (NULL != nstats) {
  82         
  83         gettimeofday(&nstats->sample_time, NULL);
  84     }
  85 
  86     if (NULL != stats) {
  87         gethostname(hostname, sizeof(hostname));
  88         opal_string_copy(stats->node, hostname, OPAL_PSTAT_MAX_STRING_LEN);
  89 
  90         stats->pid = pid;
  91         opal_string_copy(stats->cmd, "UNKNOWN", OPAL_PSTAT_MAX_STRING_LEN);
  92         stats->state[0] = 'R';
  93         stats->priority = 2;
  94         stats->num_threads = 1;
  95 
  96         
  97         stats->vsize = 1.75;
  98         stats->rss = 1.23;
  99         stats->peak_vsize = 7.89;
 100 
 101         
 102         dtime = 12345.678;
 103         stats->time.tv_sec = (long)dtime;
 104         stats->time.tv_usec = (long)(1000000.0 * (dtime - stats->time.tv_sec));
 105         stats->priority = 2;
 106     }
 107 
 108     if (NULL != nstats) {
 109         
 110         nstats->total_mem = 123.45;
 111         nstats->free_mem = 0.45;
 112         nstats->buffers = 1.33;
 113         nstats->cached = 0.56;
 114         nstats->swap_cached = 0.95;
 115         nstats->swap_total = 11.45;
 116         nstats->swap_free = 1.26;
 117         nstats->mapped = 12.98;
 118         
 119         nstats->la = 0.52;
 120         nstats->la5 = 1.03;
 121         nstats->la15 = 0.12;
 122     }
 123 
 124     return OPAL_SUCCESS;
 125 }