#include "pmix_config.h"
#include "pmix_common.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <string.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#include "src/include/pmix_globals.h"
#include "src/mca/pstat/base/base.h"
#include "src/mca/pstat/pstat.h"
#include "pstat_test.h"
static int init(void);
static int query(pid_t pid, pmix_proc_stats_t *stats, pmix_node_stats_t *nstats);
static int fini(void);
const pmix_pstat_base_module_t pmix_pstat_test_module = {init, query, fini};
static int init(void)
{
return PMIX_SUCCESS;
}
static int fini(void)
{
return PMIX_SUCCESS;
}
static int query(pid_t pid, pmix_proc_stats_t *stats, pmix_node_stats_t *nstats)
{
double dtime;
if (NULL != stats) {
gettimeofday(&stats->sample_time, NULL);
if (NULL != nstats) {
nstats->sample_time.tv_sec = stats->sample_time.tv_sec;
nstats->sample_time.tv_usec = stats->sample_time.tv_usec;
}
} else if (NULL != nstats) {
gettimeofday(&nstats->sample_time, NULL);
}
if (NULL != stats) {
stats->node = strdup(pmix_globals.hostname);
stats->pid = pid;
stats->cmd = strdup("UNKNOWN");
stats->state = 'R';
stats->priority = 2;
stats->num_threads = 1;
stats->vsize = 1.75;
stats->rss = 1.23;
stats->peak_vsize = 7.89;
dtime = 12345.678;
stats->time.tv_sec = (long) dtime;
stats->time.tv_usec = (long) (1000000.0 * (dtime - stats->time.tv_sec));
stats->priority = 2;
}
if (NULL != nstats) {
nstats->total_mem = 123.45;
nstats->free_mem = 0.45;
nstats->buffers = 1.33;
nstats->cached = 0.56;
nstats->swap_cached = 0.95;
nstats->swap_total = 11.45;
nstats->swap_free = 1.26;
nstats->mapped = 12.98;
nstats->la = 0.52;
nstats->la5 = 1.03;
nstats->la15 = 0.12;
}
return PMIX_SUCCESS;
}