1
1

Merge pull request #7436 from rhc54/topic/pstat

Remove the unused opal/pstat framework
Этот коммит содержится в:
Ralph Castain 2020-02-20 10:52:15 -08:00 коммит произвёл GitHub
родитель dd5991f513 254dd2288a
Коммит 3366f3ec40
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
27 изменённых файлов: 8 добавлений и 2480 удалений

Просмотреть файл

@ -12,7 +12,7 @@
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -290,18 +290,6 @@ int opal_dss_compare_byte_object(opal_byte_object_t *value1, opal_byte_object_t
return OPAL_EQUAL; /* sum of both value's bytes was identical */
}
/* OPAL_PSTAT */
int opal_dss_compare_pstat(opal_pstats_t *value1, opal_pstats_t *value2, opal_data_type_t type)
{
return OPAL_EQUAL; /* eventually compare field to field */
}
/* OPAL_NODE_STAT */
int opal_dss_compare_node_stat(opal_node_stats_t *value1, opal_node_stats_t *value2, opal_data_type_t type)
{
return OPAL_EQUAL; /* eventually compare field to field */
}
/* OPAL_VALUE */
int opal_dss_compare_value(opal_value_t *value1, opal_value_t *value2, opal_data_type_t type)
{

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
@ -197,62 +197,6 @@ int opal_dss_copy_byte_object(opal_byte_object_t **dest, opal_byte_object_t *src
return OPAL_SUCCESS;
}
/* OPAL_PSTAT */
int opal_dss_copy_pstat(opal_pstats_t **dest, opal_pstats_t *src,
opal_data_type_t type)
{
opal_pstats_t *p;
/* create the new object */
*dest = OBJ_NEW(opal_pstats_t);
if (NULL == *dest) {
return OPAL_ERR_OUT_OF_RESOURCE;
}
p = *dest;
/* copy the individual fields */
memcpy(p->node, src->node, sizeof(src->node));
p->rank = src->rank;
p->pid = src->pid;
memcpy(p->cmd, src->cmd, sizeof(src->cmd));
p->state[0] = src->state[0];
p->time = src->time;
p->priority = src->priority;
p->num_threads = src->num_threads;
p->pss = src->pss;
p->vsize = src->vsize;
p->rss = src->rss;
p->peak_vsize = src->peak_vsize;
p->processor = src->processor;
p->sample_time.tv_sec = src->sample_time.tv_sec;
p->sample_time.tv_usec = src->sample_time.tv_usec;
return OPAL_SUCCESS;
}
/* OPAL_NODE_STAT */
int opal_dss_copy_node_stat(opal_node_stats_t **dest, opal_node_stats_t *src,
opal_data_type_t type)
{
opal_node_stats_t *p;
/* create the new object */
*dest = OBJ_NEW(opal_node_stats_t);
if (NULL == *dest) {
return OPAL_ERR_OUT_OF_RESOURCE;
}
p = *dest;
/* copy the individual fields */
p->la = src->la;
p->la5 = src->la5;
p->la15 = src->la15;
p->total_mem = src->total_mem;
p->free_mem = src->free_mem;
p->sample_time.tv_sec = src->sample_time.tv_sec;
p->sample_time.tv_usec = src->sample_time.tv_usec;
return OPAL_SUCCESS;
}
/* OPAL_VALUE */
int opal_dss_copy_value(opal_value_t **dest, opal_value_t *src,
opal_data_type_t type)

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
@ -299,12 +299,6 @@ int opal_dss_pack_data_type(opal_buffer_t *buffer, const void *src,
int opal_dss_pack_byte_object(opal_buffer_t *buffer, const void *src,
int32_t num_vals, opal_data_type_t type);
int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src,
int32_t num_vals, opal_data_type_t type);
int opal_dss_pack_node_stat(opal_buffer_t *buffer, const void *src,
int32_t num_vals, opal_data_type_t type);
int opal_dss_pack_value(opal_buffer_t *buffer, const void *src,
int32_t num_vals, opal_data_type_t type);
@ -373,12 +367,6 @@ int opal_dss_unpack_data_type(opal_buffer_t *buffer, void *dest,
int opal_dss_unpack_byte_object(opal_buffer_t *buffer, void *dest,
int32_t *num_vals, opal_data_type_t type);
int opal_dss_unpack_pstat(opal_buffer_t *buffer, void *dest,
int32_t *num_vals, opal_data_type_t type);
int opal_dss_unpack_node_stat(opal_buffer_t *buffer, void *dest,
int32_t *num_vals, opal_data_type_t type);
int opal_dss_unpack_value(opal_buffer_t *buffer, void *dest,
int32_t *num_vals, opal_data_type_t type);
@ -425,12 +413,6 @@ int opal_dss_copy_string(char **dest, char *src, opal_data_type_t type);
int opal_dss_copy_byte_object(opal_byte_object_t **dest, opal_byte_object_t *src,
opal_data_type_t type);
int opal_dss_copy_pstat(opal_pstats_t **dest, opal_pstats_t *src,
opal_data_type_t type);
int opal_dss_copy_node_stat(opal_node_stats_t **dest, opal_node_stats_t *src,
opal_data_type_t type);
int opal_dss_copy_value(opal_value_t **dest, opal_value_t *src,
opal_data_type_t type);
@ -481,10 +463,6 @@ int opal_dss_compare_dt(opal_data_type_t *value1, opal_data_type_t *value2, opal
int opal_dss_compare_byte_object(opal_byte_object_t *value1, opal_byte_object_t *value2, opal_data_type_t type);
int opal_dss_compare_pstat(opal_pstats_t *value1, opal_pstats_t *value2, opal_data_type_t type);
int opal_dss_compare_node_stat(opal_node_stats_t *value1, opal_node_stats_t *value2, opal_data_type_t type);
int opal_dss_compare_value(opal_value_t *value1, opal_value_t *value2, opal_data_type_t type);
int opal_dss_compare_buffer_contents(opal_buffer_t *value1, opal_buffer_t *value2, opal_data_type_t type);
@ -540,8 +518,6 @@ int opal_dss_print_int64(char **output, char *prefix, void *src, opal_data_type_
int opal_dss_print_null(char **output, char *prefix, void *src, opal_data_type_t type);
int opal_dss_print_data_type(char **output, char *prefix, opal_data_type_t *src, opal_data_type_t type);
int opal_dss_print_byte_object(char **output, char *prefix, opal_byte_object_t *src, opal_data_type_t type);
int opal_dss_print_pstat(char **output, char *prefix, opal_pstats_t *src, opal_data_type_t type);
int opal_dss_print_node_stat(char **output, char *prefix, opal_node_stats_t *src, opal_data_type_t type);
int opal_dss_print_value(char **output, char *prefix, opal_value_t *src, opal_data_type_t type);
int opal_dss_print_buffer_contents(char **output, char *prefix, opal_buffer_t *src, opal_data_type_t type);
int opal_dss_print_float(char **output, char *prefix, float *src, opal_data_type_t type);

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2019 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
@ -149,94 +149,6 @@ OBJ_CLASS_INSTANCE(opal_dss_type_info_t, opal_object_t,
opal_dss_type_info_destruct);
static void opal_pstat_construct(opal_pstats_t *obj)
{
memset(obj->node, 0, sizeof(obj->node));
memset(obj->cmd, 0, sizeof(obj->cmd));
obj->rank = 0;
obj->pid = 0;
obj->state[0] = 'U';
obj->state[1] = '\0';
obj->percent_cpu = 0.0;
obj->time.tv_sec = 0;
obj->time.tv_usec = 0;
obj->priority = -1;
obj->num_threads = -1;
obj->pss = 0.0;
obj->vsize = 0.0;
obj->rss = 0.0;
obj->peak_vsize = 0.0;
obj->processor = -1;
obj->sample_time.tv_sec = 0;
obj->sample_time.tv_usec = 0;
}
OBJ_CLASS_INSTANCE(opal_pstats_t, opal_list_item_t,
opal_pstat_construct,
NULL);
static void diskstat_cons(opal_diskstats_t *ptr)
{
ptr->disk = NULL;
}
static void diskstat_dest(opal_diskstats_t *ptr)
{
if (NULL != ptr->disk) {
free(ptr->disk);
}
}
OBJ_CLASS_INSTANCE(opal_diskstats_t,
opal_list_item_t,
diskstat_cons, diskstat_dest);
static void netstat_cons(opal_netstats_t *ptr)
{
ptr->net_interface = NULL;
}
static void netstat_dest(opal_netstats_t *ptr)
{
if (NULL != ptr->net_interface) {
free(ptr->net_interface);
}
}
OBJ_CLASS_INSTANCE(opal_netstats_t,
opal_list_item_t,
netstat_cons, netstat_dest);
static void opal_node_stats_construct(opal_node_stats_t *obj)
{
obj->la = 0.0;
obj->la5 = 0.0;
obj->la15 = 0.0;
obj->total_mem = 0;
obj->free_mem = 0.0;
obj->buffers = 0.0;
obj->cached = 0.0;
obj->swap_cached = 0.0;
obj->swap_total = 0.0;
obj->swap_free = 0.0;
obj->mapped = 0.0;
obj->sample_time.tv_sec = 0;
obj->sample_time.tv_usec = 0;
OBJ_CONSTRUCT(&obj->diskstats, opal_list_t);
OBJ_CONSTRUCT(&obj->netstats, opal_list_t);
}
static void opal_node_stats_destruct(opal_node_stats_t *obj)
{
opal_list_item_t *item;
while (NULL != (item = opal_list_remove_first(&obj->diskstats))) {
OBJ_RELEASE(item);
}
OBJ_DESTRUCT(&obj->diskstats);
while (NULL != (item = opal_list_remove_first(&obj->netstats))) {
OBJ_RELEASE(item);
}
OBJ_DESTRUCT(&obj->netstats);
}
OBJ_CLASS_INSTANCE(opal_node_stats_t, opal_object_t,
opal_node_stats_construct,
opal_node_stats_destruct);
static void opal_envar_construct(opal_envar_t *obj)
{
obj->envar = NULL;
@ -538,27 +450,6 @@ int opal_dss_open(void)
return rc;
}
tmp = OPAL_PSTAT;
if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_pstat,
opal_dss_unpack_pstat,
(opal_dss_copy_fn_t)opal_dss_copy_pstat,
(opal_dss_compare_fn_t)opal_dss_compare_pstat,
(opal_dss_print_fn_t)opal_dss_print_pstat,
OPAL_DSS_STRUCTURED,
"OPAL_PSTAT", &tmp))) {
return rc;
}
tmp = OPAL_NODE_STAT;
if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_node_stat,
opal_dss_unpack_node_stat,
(opal_dss_copy_fn_t)opal_dss_copy_node_stat,
(opal_dss_compare_fn_t)opal_dss_compare_node_stat,
(opal_dss_print_fn_t)opal_dss_print_node_stat,
OPAL_DSS_STRUCTURED,
"OPAL_NODE_STAT", &tmp))) {
return rc;
}
tmp = OPAL_VALUE;
if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_value,
opal_dss_unpack_value,

Просмотреть файл

@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
@ -461,241 +461,6 @@ int opal_dss_pack_byte_object(opal_buffer_t *buffer, const void *src, int32_t nu
return OPAL_SUCCESS;
}
/*
* OPAL_PSTAT
*/
int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src,
int32_t num_vals, opal_data_type_t type)
{
opal_pstats_t **ptr;
int32_t i;
int ret;
char *cptr;
ptr = (opal_pstats_t **) src;
for (i = 0; i < num_vals; ++i) {
cptr = ptr[i]->node;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &cptr, 1, OPAL_STRING))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->rank, 1, OPAL_INT32))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->pid, 1, OPAL_PID))) {
return ret;
}
cptr = ptr[i]->cmd;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &cptr, 1, OPAL_STRING))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->state[0], 1, OPAL_BYTE))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->time, 1, OPAL_TIMEVAL))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->priority, 1, OPAL_INT32))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->num_threads, 1, OPAL_INT16))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->pss, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->vsize, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->rss, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->peak_vsize, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->processor, 1, OPAL_INT16))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->sample_time, 1, OPAL_TIMEVAL))) {
return ret;
}
}
return OPAL_SUCCESS;
}
static int pack_disk_stats(opal_buffer_t *buffer, opal_diskstats_t *dk)
{
uint64_t i64;
int ret;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &dk->disk, 1, OPAL_STRING))) {
return ret;
}
i64 = (uint64_t)dk->num_reads_completed;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_reads_merged;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_sectors_read;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->milliseconds_reading;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_writes_completed;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_writes_merged;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_sectors_written;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->milliseconds_writing;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_ios_in_progress;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->milliseconds_io;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->weighted_milliseconds_io;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
return OPAL_SUCCESS;
}
static int pack_net_stats(opal_buffer_t *buffer, opal_netstats_t *ns)
{
uint64_t i64;
int ret;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ns->net_interface, 1, OPAL_STRING))) {
return ret;
}
i64 = (uint64_t)ns->num_bytes_recvd;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_packets_recvd;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_recv_errs;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_bytes_sent;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_packets_sent;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_send_errs;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
return OPAL_SUCCESS;
}
/*
* OPAL_NODE_STAT
*/
int opal_dss_pack_node_stat(opal_buffer_t *buffer, const void *src,
int32_t num_vals, opal_data_type_t type)
{
opal_node_stats_t **ptr;
int32_t i, j;
int ret;
opal_diskstats_t *ds;
opal_netstats_t *ns;
ptr = (opal_node_stats_t **) src;
for (i = 0; i < num_vals; ++i) {
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->la, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->la5, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->la15, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->total_mem, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->free_mem, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->buffers, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->cached, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->swap_cached, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->swap_total, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->swap_free, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->mapped, 1, OPAL_FLOAT))) {
return ret;
}
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->sample_time, 1, OPAL_TIMEVAL))) {
return ret;
}
/* pack the number of disk stat objects on the list */
j = opal_list_get_size(&ptr[i]->diskstats);
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &j, 1, OPAL_INT32))) {
return ret;
}
if (0 < j) {
/* pack them */
OPAL_LIST_FOREACH(ds, &ptr[i]->diskstats, opal_diskstats_t) {
if (OPAL_SUCCESS != (ret = pack_disk_stats(buffer, ds))) {
return ret;
}
}
}
/* pack the number of net stat objects on the list */
j = opal_list_get_size(&ptr[i]->netstats);
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &j, 1, OPAL_INT32))) {
return ret;
}
if (0 < j) {
/* pack them */
OPAL_LIST_FOREACH(ns, &ptr[i]->netstats, opal_netstats_t) {
if (OPAL_SUCCESS != (ret = pack_net_stats(buffer, ns))) {
return ret;
}
}
}
}
return OPAL_SUCCESS;
}
/*
* OPAL_VALUE
*/

Просмотреть файл

@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
@ -636,70 +636,6 @@ int opal_dss_print_byte_object(char **output, char *prefix, opal_byte_object_t *
return OPAL_SUCCESS;
}
/*
* OPAL_PSTAT
*/
int opal_dss_print_pstat(char **output, char *prefix, opal_pstats_t *src, opal_data_type_t type)
{
char *prefx;
/* deal with NULL prefix */
if (NULL == prefix) opal_asprintf(&prefx, " ");
else prefx = prefix;
/* if src is NULL, just print data type and return */
if (NULL == src) {
opal_asprintf(output, "%sData type: OPAL_PSTATS\tValue: NULL pointer", prefx);
if (prefx != prefix) {
free(prefx);
}
return OPAL_SUCCESS;
}
opal_asprintf(output, "%sOPAL_PSTATS SAMPLED AT: %ld.%06ld\n%snode: %s rank: %d pid: %d cmd: %s state: %c pri: %d #threads: %d Processor: %d\n"
"%s\ttime: %ld.%06ld cpu: %5.2f PSS: %8.2f VMsize: %8.2f PeakVMSize: %8.2f RSS: %8.2f\n",
prefx, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec,
prefx, src->node, src->rank, src->pid, src->cmd, src->state[0], src->priority, src->num_threads, src->processor,
prefx, (long)src->time.tv_sec, (long)src->time.tv_usec, src->percent_cpu, src->pss, src->vsize, src->peak_vsize, src->rss);
if (prefx != prefix) {
free(prefx);
}
return OPAL_SUCCESS;
}
/*
* OPAL_NODE_STAT
*/
int opal_dss_print_node_stat(char **output, char *prefix, opal_node_stats_t *src, opal_data_type_t type)
{
char *prefx;
/* deal with NULL prefix */
if (NULL == prefix) opal_asprintf(&prefx, " ");
else prefx = prefix;
/* if src is NULL, just print data type and return */
if (NULL == src) {
opal_asprintf(output, "%sData type: OPAL_NODE_STATS\tValue: NULL pointer", prefx);
if (prefx != prefix) {
free(prefx);
}
return OPAL_SUCCESS;
}
opal_asprintf(output, "%sOPAL_NODE_STATS SAMPLED AT: %ld.%06ld\n%sTotal Mem: %5.2f Free Mem: %5.2f Buffers: %5.2f Cached: %5.2f\n"
"%sSwapCached: %5.2f SwapTotal: %5.2f SwapFree: %5.2f Mapped: %5.2f\n"
"%s\tla: %5.2f\tla5: %5.2f\tla15: %5.2f\n",
prefx, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec,
prefx, src->total_mem, src->free_mem, src->buffers, src->cached,
prefx, src->swap_cached, src->swap_total, src->swap_free, src->mapped,
prefx, src->la, src->la5, src->la15);
if (prefx != prefix) {
free(prefx);
}
return OPAL_SUCCESS;
}
/*
* OPAL_VALUE
*/

Просмотреть файл

@ -15,7 +15,7 @@
* reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2014-2019 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -91,8 +91,6 @@ typedef struct {
#define OPAL_BYTE_OBJECT (opal_data_type_t) 20 /**< byte object structure */
#define OPAL_DATA_TYPE (opal_data_type_t) 21 /**< data type */
#define OPAL_NULL (opal_data_type_t) 22 /**< don't interpret data type */
#define OPAL_PSTAT (opal_data_type_t) 23 /**< process statistics */
#define OPAL_NODE_STAT (opal_data_type_t) 24 /**< node statistics */
#define OPAL_HWLOC_TOPO (opal_data_type_t) 25 /**< hwloc topology */
#define OPAL_VALUE (opal_data_type_t) 26 /**< opal value structure */
#define OPAL_BUFFER (opal_data_type_t) 27 /**< pack the remaining contents of a buffer as an object */
@ -179,82 +177,6 @@ typedef struct {
} opal_value_t;
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_value_t);
/* Process statistics object */
#define OPAL_PSTAT_MAX_STRING_LEN 32
typedef struct {
opal_list_item_t super; /* required for this to be on a list */
/* process ident info */
char node[OPAL_PSTAT_MAX_STRING_LEN];
int32_t rank;
pid_t pid;
char cmd[OPAL_PSTAT_MAX_STRING_LEN];
/* process stats */
char state[2];
struct timeval time;
float percent_cpu;
int32_t priority;
int16_t num_threads;
float pss; /* in MBytes */
float vsize; /* in MBytes */
float rss; /* in MBytes */
float peak_vsize; /* in MBytes */
int16_t processor;
/* time at which sample was taken */
struct timeval sample_time;
} opal_pstats_t;
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_pstats_t);
typedef struct {
opal_list_item_t super;
char *disk;
unsigned long num_reads_completed;
unsigned long num_reads_merged;
unsigned long num_sectors_read;
unsigned long milliseconds_reading;
unsigned long num_writes_completed;
unsigned long num_writes_merged;
unsigned long num_sectors_written;
unsigned long milliseconds_writing;
unsigned long num_ios_in_progress;
unsigned long milliseconds_io;
unsigned long weighted_milliseconds_io;
} opal_diskstats_t;
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_diskstats_t);
typedef struct {
opal_list_item_t super;
char *net_interface;
unsigned long num_bytes_recvd;
unsigned long num_packets_recvd;
unsigned long num_recv_errs;
unsigned long num_bytes_sent;
unsigned long num_packets_sent;
unsigned long num_send_errs;
} opal_netstats_t;
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_netstats_t);
typedef struct {
opal_object_t super;
/* node-level load averages */
float la;
float la5;
float la15;
/* memory usage */
float total_mem; /* in MBytes */
float free_mem; /* in MBytes */
float buffers; /* in MBytes */
float cached; /* in MBytes */
float swap_cached; /* in MBytes */
float swap_total; /* in MBytes */
float swap_free; /* in MBytes */
float mapped; /* in MBytes */
/* time at which sample was taken */
struct timeval sample_time;
/* list of disk stats, one per disk */
opal_list_t diskstats;
/* list of net stats, one per interface */
opal_list_t netstats;
} opal_node_stats_t;
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_node_stats_t);
/* structured-unstructured data flags */
#define OPAL_DSS_STRUCTURED true
#define OPAL_DSS_UNSTRUCTURED false

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012-2015 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
@ -578,375 +578,6 @@ int opal_dss_unpack_byte_object(opal_buffer_t *buffer, void *dest, int32_t *num,
return OPAL_SUCCESS;
}
/*
* OPAL_PSTAT
*/
int opal_dss_unpack_pstat(opal_buffer_t *buffer, void *dest,
int32_t *num_vals, opal_data_type_t type)
{
opal_pstats_t **ptr;
int32_t i, n, m;
int ret;
char *cptr;
ptr = (opal_pstats_t **) dest;
n = *num_vals;
for (i = 0; i < n; ++i) {
/* allocate the new object */
ptr[i] = OBJ_NEW(opal_pstats_t);
if (NULL == ptr[i]) {
return OPAL_ERR_OUT_OF_RESOURCE;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &cptr, &m, OPAL_STRING))) {
OPAL_ERROR_LOG(ret);
return ret;
}
memmove(ptr[i]->node, cptr, strlen(cptr));
free(cptr);
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->rank, &m, OPAL_INT32))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->pid, &m, OPAL_PID))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &cptr, &m, OPAL_STRING))) {
OPAL_ERROR_LOG(ret);
return ret;
}
memmove(ptr[i]->cmd, cptr, strlen(cptr));
free(cptr);
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->state[0], &m, OPAL_BYTE))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->time, &m, OPAL_TIMEVAL))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->priority, &m, OPAL_INT32))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->num_threads, &m, OPAL_INT16))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->pss, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->vsize, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->rss, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->peak_vsize, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->processor, &m, OPAL_INT16))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->sample_time, &m, OPAL_TIMEVAL))) {
OPAL_ERROR_LOG(ret);
return ret;
}
}
return OPAL_SUCCESS;
}
static int unpack_disk_stats(opal_buffer_t *buffer, opal_node_stats_t *ns)
{
int32_t i, m, n;
int ret;
opal_diskstats_t *dk;
uint64_t i64;
/* unpack the number of disk stat objects */
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &n, &m, OPAL_INT32))) {
OPAL_ERROR_LOG(ret);
return ret;
}
/* unpack them */
for (i=0; i < n; i++) {
dk = OBJ_NEW(opal_diskstats_t);
assert(dk);
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &dk->disk, &m, OPAL_STRING))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_reads_completed = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_reads_merged = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_sectors_read = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->milliseconds_reading = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_writes_completed = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_writes_merged = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_sectors_written = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->milliseconds_writing = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_ios_in_progress = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->milliseconds_io = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->weighted_milliseconds_io = i64;
opal_list_append(&ns->diskstats, &dk->super);
}
return OPAL_SUCCESS;
}
static int unpack_net_stats(opal_buffer_t *buffer, opal_node_stats_t *ns)
{
int32_t i, m, n;
int ret;
opal_netstats_t *net;
uint64_t i64;
/* unpack the number of net stat objects */
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &n, &m, OPAL_INT32))) {
OPAL_ERROR_LOG(ret);
return ret;
}
/* unpack them */
for (i=0; i < n; i++) {
net = OBJ_NEW(opal_netstats_t);
assert(net);
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &net->net_interface, &m, OPAL_STRING))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_bytes_recvd = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_packets_recvd = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_recv_errs = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_bytes_sent = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_packets_sent = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_send_errs = i64;
opal_list_append(&ns->netstats, &net->super);
}
return OPAL_SUCCESS;
}
/*
* OPAL_NODE_STAT
*/
int opal_dss_unpack_node_stat(opal_buffer_t *buffer, void *dest,
int32_t *num_vals, opal_data_type_t type)
{
opal_node_stats_t **ptr;
int32_t i, n, m;
int ret;
ptr = (opal_node_stats_t **) dest;
n = *num_vals;
for (i = 0; i < n; ++i) {
/* allocate the new object */
ptr[i] = OBJ_NEW(opal_node_stats_t);
if (NULL == ptr[i]) {
return OPAL_ERR_OUT_OF_RESOURCE;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->la, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->la5, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->la15, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->total_mem, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->free_mem, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->buffers, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->cached, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_cached, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_total, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_free, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->mapped, &m, OPAL_FLOAT))) {
OPAL_ERROR_LOG(ret);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->sample_time, &m, OPAL_TIMEVAL))) {
OPAL_ERROR_LOG(ret);
return ret;
}
/* unpack the disk stat objects */
if (OPAL_SUCCESS != (ret = unpack_disk_stats(buffer, ptr[i]))) {
OPAL_ERROR_LOG(ret);
return ret;
}
/* unpack the net stat objects */
if (OPAL_SUCCESS != (ret = unpack_net_stats(buffer, ptr[i]))) {
OPAL_ERROR_LOG(ret);
return ret;
}
OBJ_RELEASE(ptr[i]);
}
return OPAL_SUCCESS;
}
/*
* OPAL_VALUE
*/

Просмотреть файл

@ -1,37 +0,0 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# main library setup
noinst_LTLIBRARIES = libmca_pstat.la
libmca_pstat_la_SOURCES =
# local files
headers = pstat.h
libmca_pstat_la_SOURCES += $(headers)
# Conditionally install the header files
if WANT_INSTALL_HEADERS
opaldir = $(opalincludedir)/$(subdir)
nobase_opal_HEADERS = $(headers)
endif
include base/Makefile.am
distclean-local:
rm -f base/static-components.h

Просмотреть файл

@ -1,24 +0,0 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
headers += \
base/base.h
libmca_pstat_la_SOURCES += \
base/pstat_base_select.c \
base/pstat_base_open.c

Просмотреть файл

@ -1,58 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef OPAL_PSTAT_BASE_H
#define OPAL_PSTAT_BASE_H
#include "opal_config.h"
#include "opal/mca/base/mca_base_framework.h"
#include "opal/mca/pstat/pstat.h"
/*
* Global functions for MCA overall pstat open and close
*/
BEGIN_C_DECLS
/**
* Framework structure declaration for this framework
*/
OPAL_DECLSPEC extern mca_base_framework_t opal_pstat_base_framework;
/**
* Select an available component.
*
* @return OPAL_SUCCESS Upon success.
* @return OPAL_NOT_FOUND If no component can be selected.
* @return OPAL_ERROR Upon other failure.
*
* At the end of this process, we'll either have a single
* component that is selected and initialized, or no component was
* selected. If no component was selected, subsequent invocation
* of the pstat functions will return an error indicating no data
* could be obtained
*/
OPAL_DECLSPEC int opal_pstat_base_select(void);
OPAL_DECLSPEC extern opal_pstat_base_component_t *opal_pstat_base_component;
END_C_DECLS
#endif /* OPAL_BASE_PSTAT_H */

Просмотреть файл

@ -1,88 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/mca/pstat/pstat.h"
#include "opal/mca/pstat/base/base.h"
/*
* The following file was created by configure. It contains extern
* statements and the definition of an array of pointers to each
* component's public mca_base_component_t struct.
*/
#include "opal/mca/pstat/base/static-components.h"
/* unsupported functions */
static int opal_pstat_base_unsupported_init(void);
static int opal_pstat_base_unsupported_query(pid_t pid, opal_pstats_t *stats, opal_node_stats_t *nstats);
static int opal_pstat_base_unsupported_finalize(void);
/*
* Globals
*/
opal_pstat_base_component_t *opal_pstat_base_component = NULL;
opal_pstat_base_module_t opal_pstat = {
opal_pstat_base_unsupported_init,
opal_pstat_base_unsupported_query,
opal_pstat_base_unsupported_finalize
};
/* Use default register/open/close functions */
static int opal_pstat_base_close(void)
{
/* let the selected module finalize */
if (NULL != opal_pstat.finalize) {
opal_pstat.finalize();
}
return mca_base_framework_components_close(&opal_pstat_base_framework, NULL);
}
static int opal_pstat_base_open(mca_base_open_flag_t flags)
{
/* Open up all available components */
return mca_base_framework_components_open(&opal_pstat_base_framework, flags);
}
MCA_BASE_FRAMEWORK_DECLARE(opal, pstat, "process statistics", NULL,
opal_pstat_base_open, opal_pstat_base_close,
mca_pstat_base_static_components, 0);
static int opal_pstat_base_unsupported_init(void)
{
return OPAL_ERR_NOT_SUPPORTED;
}
static int opal_pstat_base_unsupported_query(pid_t pid, opal_pstats_t *stats, opal_node_stats_t *nstats)
{
return OPAL_ERR_NOT_SUPPORTED;
}
static int opal_pstat_base_unsupported_finalize(void)
{
return OPAL_ERR_NOT_SUPPORTED;
}

Просмотреть файл

@ -1,67 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/mca/pstat/pstat.h"
#include "opal/mca/pstat/base/base.h"
/*
* Globals
*/
int opal_pstat_base_select(void)
{
int ret, exit_status = OPAL_SUCCESS;
opal_pstat_base_component_t *best_component = NULL;
opal_pstat_base_module_t *best_module = NULL;
/*
* Select the best component
*/
if( OPAL_SUCCESS != mca_base_select("pstat", opal_pstat_base_framework.framework_output,
&opal_pstat_base_framework.framework_components,
(mca_base_module_t **) &best_module,
(mca_base_component_t **) &best_component, NULL) ) {
/* It is okay if we don't find a runnable component - default
* to the unsupported default.
*/
goto cleanup;
}
/* Save the winner */
opal_pstat_base_component = best_component;
opal_pstat = *best_module;
/* Initialize the winner */
if (OPAL_SUCCESS != (ret = opal_pstat.init()) ) {
exit_status = ret;
goto cleanup;
}
cleanup:
return exit_status;
}

Просмотреть файл

@ -1,13 +0,0 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2007 Los Alamos National Security, LLC.
dnl All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
dnl we only want those at same priority
m4_define(MCA_opal_pstat_CONFIGURE_MODE, STOP_AT_FIRST_PRIORITY)

Просмотреть файл

@ -1,46 +0,0 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2017 IBM Corporation. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
sources = \
pstat_linux.h \
pstat_linux_component.c \
pstat_linux_module.c
# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).
if MCA_BUILD_opal_pstat_linux_DSO
component_noinst =
component_install = mca_pstat_linux.la
else
component_noinst = libmca_pstat_linux.la
component_install =
endif
mcacomponentdir = $(opallibdir)
mcacomponent_LTLIBRARIES = $(component_install)
mca_pstat_linux_la_SOURCES = $(sources)
mca_pstat_linux_la_LDFLAGS = -module -avoid-version
mca_pstat_linux_la_LIBADD = $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la
noinst_LTLIBRARIES = $(component_noinst)
libmca_pstat_linux_la_SOURCES =$(sources)
libmca_pstat_linux_la_LDFLAGS = -module -avoid-version

Просмотреть файл

@ -1,48 +0,0 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AC_DEFUN([MCA_opal_pstat_linux_PRIORITY], [60])
# MCA_pstat_linux_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_opal_pstat_linux_CONFIG],[
AC_CONFIG_FILES([opal/mca/pstat/linux/Makefile])
case "${host}" in
i?86-*linux*|x86_64*linux*|ia64-*linux*|powerpc-*linux*|powerpc64-*linux*|powerpc64le-*linux*|powerpcle-*linux*|sparc*-*linux*)
AS_IF([test -r "/proc/cpuinfo"],
[pstat_linux_happy="yes"],
[pstat_linux_happy="no"])
;;
*)
pstat_linux_happy="no"
;;
esac
AS_IF([test "$pstat_linux_happy" = "yes"],
[AC_CHECK_DECLS([HZ],
[], [pstat_linux_happy="no"], [AC_INCLUDES_DEFAULT
#include <sys/param.h>
])])
AS_IF([test "$pstat_linux_happy" = "yes"],
[$1],
[$2])
])

Просмотреть файл

@ -1,7 +0,0 @@
#
# owner/status file
# owner: institution that is responsible for this package
# status: e.g. active, maintenance, unmaintained
#
owner: INTEL
status: maintenance

Просмотреть файл

@ -1,48 +0,0 @@
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Processor stats for Posix systems.
*
*/
#ifndef MCA_PSTAT_LINUX_EXPORT_H
#define MCA_PSTAT_LINUX_EXPORT_H
#include "opal_config.h"
#include "opal/mca/mca.h"
#include "opal/mca/pstat/pstat.h"
BEGIN_C_DECLS
/**
* Globally exported variable
*/
OPAL_DECLSPEC extern const opal_pstat_base_component_t mca_pstat_linux_component;
OPAL_DECLSPEC extern const opal_pstat_base_module_t opal_pstat_linux_module;
END_C_DECLS
#endif /* MCA_PSTAT_LINUX_EXPORT_H */

Просмотреть файл

@ -1,80 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
* These symbols are in a file by themselves to provide nice linker
* semantics. Since linkers generally pull in symbols by object
* files, keeping these symbols as the only symbols in this file
* prevents utility programs such as "ompi_info" from having to import
* entire components just to query their version and parameters.
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/mca/pstat/pstat.h"
#include "pstat_linux.h"
/*
* Public string showing the pstat ompi_linux component version number
*/
const char *opal_pstat_linux_component_version_string =
"OPAL linux pstat MCA component version " OPAL_VERSION;
/*
* Local function
*/
static int pstat_linux_component_query(mca_base_module_t **module, int *priority);
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
const opal_pstat_base_component_t mca_pstat_linux_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
.base_version = {
OPAL_PSTAT_BASE_VERSION_2_0_0,
/* Component name and version */
.mca_component_name = "linux",
MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION),
.mca_query_component = pstat_linux_component_query,
},
.base_data = {
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
},
};
static int pstat_linux_component_query(mca_base_module_t **module, int *priority)
{
*priority = 20;
*module = (mca_base_module_t *)&opal_pstat_linux_module;
return OPAL_SUCCESS;
}

Просмотреть файл

@ -1,578 +0,0 @@
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved.
* Copyright (c) 2013 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/constants.h"
/* This component will only be compiled on Linux, where we are
guaranteed to have <unistd.h> and friends */
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/param.h> /* for HZ to convert jiffies to actual time */
#include "opal/dss/dss_types.h"
#include "opal/util/argv.h"
#include "opal/util/printf.h"
#include "pstat_linux.h"
/*
* API functions
*/
static int linux_module_init(void);
static int query(pid_t pid,
opal_pstats_t *stats,
opal_node_stats_t *nstats);
static int linux_module_fini(void);
/*
* Linux pstat module
*/
const opal_pstat_base_module_t opal_pstat_linux_module = {
/* Initialization function */
linux_module_init,
query,
linux_module_fini
};
#define OPAL_STAT_MAX_LENGTH 1024
/* Local functions */
static char *local_getline(FILE *fp);
static char *local_stripper(char *data);
static void local_getfields(char *data, char ***fields);
/* Local data */
static char input[OPAL_STAT_MAX_LENGTH];
static int linux_module_init(void)
{
return OPAL_SUCCESS;
}
static int linux_module_fini(void)
{
return OPAL_SUCCESS;
}
static char *next_field(char *ptr, int barrier)
{
int i=0;
/* we are probably pointing to the last char
* of the current field, so look for whitespace
*/
while (!isspace(*ptr) && i < barrier) {
ptr++; /* step over the current char */
i++;
}
/* now look for the next field */
while (isspace(*ptr) && i < barrier) {
ptr++;
i++;
}
return ptr;
}
static float convert_value(char *value)
{
char *ptr;
float fval;
/* compute base value */
fval = (float)strtoul(value, &ptr, 10);
/* get the unit multiplier */
if (NULL != ptr && NULL != strstr(ptr, "kB")) {
fval /= 1024.0;
}
return fval;
}
static int query(pid_t pid,
opal_pstats_t *stats,
opal_node_stats_t *nstats)
{
char data[4096];
int fd;
size_t numchars;
char *ptr, *eptr;
int i;
int len, itime;
double dtime;
FILE *fp;
char *dptr, *value;
char **fields;
opal_diskstats_t *ds;
opal_netstats_t *ns;
if (NULL != stats) {
/* record the time of this sample */
gettimeofday(&stats->sample_time, NULL);
/* check the nstats - don't do gettimeofday twice
* as it is expensive
*/
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) {
/* record the time of this sample */
gettimeofday(&nstats->sample_time, NULL);
}
if (NULL != stats) {
/* create the stat filename for this proc */
numchars = snprintf(data, sizeof(data), "/proc/%d/stat", pid);
if (numchars >= sizeof(data)) {
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
}
if (0 > (fd = open(data, O_RDONLY))) {
/* can't access this file - most likely, this means we
* aren't really on a supported system, or the proc no
* longer exists. Just return an error
*/
return OPAL_ERR_FILE_OPEN_FAILURE;
}
/* absorb all of the file's contents in one gulp - we'll process
* it once it is in memory for speed
*/
memset(data, 0, sizeof(data));
len = read(fd, data, sizeof(data)-1);
if (len < 0) {
/* This shouldn't happen! */
close(fd);
return OPAL_ERR_FILE_OPEN_FAILURE;
}
close(fd);
/* remove newline at end */
data[len] = '\0';
/* the stat file consists of a single line in a carefully formatted
* form. Parse it field by field as per proc(3) to get the ones we want
*/
/* we don't need to read the pid from the file - we already know it! */
stats->pid = pid;
/* the cmd is surrounded by parentheses - find the start */
if (NULL == (ptr = strchr(data, '('))) {
/* no cmd => something wrong with data, return error */
return OPAL_ERR_BAD_PARAM;
}
/* step over the paren */
ptr++;
/* find the ending paren */
if (NULL == (eptr = strchr(ptr, ')'))) {
/* no end to cmd => something wrong with data, return error */
return OPAL_ERR_BAD_PARAM;
}
/* save the cmd name, up to the limit of the array */
i = 0;
while (ptr < eptr && i < OPAL_PSTAT_MAX_STRING_LEN) {
stats->cmd[i++] = *ptr++;
}
/* move to the next field in the data */
ptr = next_field(eptr, len);
/* next is the process state - a single character */
stats->state[0] = *ptr;
/* move to next field */
ptr = next_field(ptr, len);
/* skip fields until we get to the times */
ptr = next_field(ptr, len); /* ppid */
ptr = next_field(ptr, len); /* pgrp */
ptr = next_field(ptr, len); /* session */
ptr = next_field(ptr, len); /* tty_nr */
ptr = next_field(ptr, len); /* tpgid */
ptr = next_field(ptr, len); /* flags */
ptr = next_field(ptr, len); /* minflt */
ptr = next_field(ptr, len); /* cminflt */
ptr = next_field(ptr, len); /* majflt */
ptr = next_field(ptr, len); /* cmajflt */
/* grab the process time usage fields */
itime = strtoul(ptr, &ptr, 10); /* utime */
itime += strtoul(ptr, &ptr, 10); /* add the stime */
/* convert to time in seconds */
dtime = (double)itime / (double)HZ;
stats->time.tv_sec = (int)dtime;
stats->time.tv_usec = (int)(1000000.0 * (dtime - stats->time.tv_sec));
/* move to next field */
ptr = next_field(ptr, len);
/* skip fields until we get to priority */
ptr = next_field(ptr, len); /* cutime */
ptr = next_field(ptr, len); /* cstime */
/* save the priority */
stats->priority = strtol(ptr, &ptr, 10);
/* move to next field */
ptr = next_field(ptr, len);
/* skip nice */
ptr = next_field(ptr, len);
/* get number of threads */
stats->num_threads = strtoul(ptr, &ptr, 10);
/* move to next field */
ptr = next_field(ptr, len);
/* skip fields until we get to processor id */
ptr = next_field(ptr, len); /* itrealvalue */
ptr = next_field(ptr, len); /* starttime */
ptr = next_field(ptr, len); /* vsize */
ptr = next_field(ptr, len); /* rss */
ptr = next_field(ptr, len); /* rss limit */
ptr = next_field(ptr, len); /* startcode */
ptr = next_field(ptr, len); /* endcode */
ptr = next_field(ptr, len); /* startstack */
ptr = next_field(ptr, len); /* kstkesp */
ptr = next_field(ptr, len); /* kstkeip */
ptr = next_field(ptr, len); /* signal */
ptr = next_field(ptr, len); /* blocked */
ptr = next_field(ptr, len); /* sigignore */
ptr = next_field(ptr, len); /* sigcatch */
ptr = next_field(ptr, len); /* wchan */
ptr = next_field(ptr, len); /* nswap */
ptr = next_field(ptr, len); /* cnswap */
ptr = next_field(ptr, len); /* exit_signal */
/* finally - get the processor */
stats->processor = strtol(ptr, NULL, 10);
/* that's all we care about from this data - ignore the rest */
/* now create the status filename for this proc */
memset(data, 0, sizeof(data));
numchars = snprintf(data, sizeof(data), "/proc/%d/status", pid);
if (numchars >= sizeof(data)) {
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
}
if (NULL == (fp = fopen(data, "r"))) {
/* ignore this */
return OPAL_SUCCESS;
}
/* parse it according to proc(3) */
while (NULL != (dptr = local_getline(fp))) {
if (NULL == (value = local_stripper(dptr))) {
/* cannot process */
continue;
}
/* look for VmPeak */
if (0 == strncmp(dptr, "VmPeak", strlen("VmPeak"))) {
stats->peak_vsize = convert_value(value);
} else if (0 == strncmp(dptr, "VmSize", strlen("VmSize"))) {
stats->vsize = convert_value(value);
} else if (0 == strncmp(dptr, "VmRSS", strlen("VmRSS"))) {
stats->rss = convert_value(value);
}
}
fclose(fp);
/* now create the smaps filename for this proc */
memset(data, 0, sizeof(data));
numchars = snprintf(data, sizeof(data), "/proc/%d/smaps", pid);
if (numchars >= sizeof(data)) {
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
}
if (NULL == (fp = fopen(data, "r"))) {
/* ignore this */
return OPAL_SUCCESS;
}
/* parse it to find lines that start with "Pss" */
while (NULL != (dptr = local_getline(fp))) {
if (NULL == (value = local_stripper(dptr))) {
/* cannot process */
continue;
}
/* look for Pss */
if (0 == strncmp(dptr, "Pss", strlen("Pss"))) {
stats->pss += convert_value(value);
}
}
fclose(fp);
}
if (NULL != nstats) {
/* get the loadavg data */
if (0 > (fd = open("/proc/loadavg", O_RDONLY))) {
/* not an error if we don't find this one as it
* isn't critical
*/
goto diskstats;
}
/* absorb all of the file's contents in one gulp - we'll process
* it once it is in memory for speed
*/
memset(data, 0, sizeof(data));
len = read(fd, data, sizeof(data)-1);
close(fd);
if (len < 0) {
goto diskstats;
}
/* remove newline at end */
data[len] = '\0';
/* we only care about the first three numbers */
nstats->la = strtof(data, &ptr);
nstats->la5 = strtof(ptr, &eptr);
nstats->la15 = strtof(eptr, NULL);
/* see if we can open the meminfo file */
if (NULL == (fp = fopen("/proc/meminfo", "r"))) {
/* ignore this */
goto diskstats;
}
/* read the file one line at a time */
while (NULL != (dptr = local_getline(fp))) {
if (NULL == (value = local_stripper(dptr))) {
/* cannot process */
continue;
}
if (0 == strcmp(dptr, "MemTotal")) {
nstats->total_mem = convert_value(value);
} else if (0 == strcmp(dptr, "MemFree")) {
nstats->free_mem = convert_value(value);
} else if (0 == strcmp(dptr, "Buffers")) {
nstats->buffers = convert_value(value);
} else if (0 == strcmp(dptr, "Cached")) {
nstats->cached = convert_value(value);
} else if (0 == strcmp(dptr, "SwapCached")) {
nstats->swap_cached = convert_value(value);
} else if (0 == strcmp(dptr, "SwapTotal")) {
nstats->swap_total = convert_value(value);
} else if (0 == strcmp(dptr, "SwapFree")) {
nstats->swap_free = convert_value(value);
} else if (0 == strcmp(dptr, "Mapped")) {
nstats->mapped = convert_value(value);
}
}
fclose(fp);
diskstats:
/* look for the diskstats file */
if (NULL == (fp = fopen("/proc/diskstats", "r"))) {
/* not an error if we don't find this one as it
* isn't critical
*/
goto netstats;
}
/* read the file one line at a time */
while (NULL != (dptr = local_getline(fp))) {
/* look for the local disks */
if (NULL == strstr(dptr, "sd")) {
continue;
}
/* parse to extract the fields */
fields = NULL;
local_getfields(dptr, &fields);
if (NULL == fields) {
continue;
}
if (14 < opal_argv_count(fields)) {
opal_argv_free(fields);
continue;
}
/* pack the ones of interest into the struct */
ds = OBJ_NEW(opal_diskstats_t);
ds->disk = strdup(fields[2]);
ds->num_reads_completed = strtoul(fields[3], NULL, 10);
ds->num_reads_merged = strtoul(fields[4], NULL, 10);
ds->num_sectors_read = strtoul(fields[5], NULL, 10);
ds->milliseconds_reading = strtoul(fields[6], NULL, 10);
ds->num_writes_completed = strtoul(fields[7], NULL, 10);
ds->num_writes_merged = strtoul(fields[8], NULL, 10);
ds->num_sectors_written = strtoul(fields[9], NULL, 10);
ds->milliseconds_writing = strtoul(fields[10], NULL, 10);
ds->num_ios_in_progress = strtoul(fields[11], NULL, 10);
ds->milliseconds_io = strtoul(fields[12], NULL, 10);
ds->weighted_milliseconds_io = strtoul(fields[13], NULL, 10);
opal_list_append(&nstats->diskstats, &ds->super);
opal_argv_free(fields);
}
fclose(fp);
netstats:
/* look for the netstats file */
if (NULL == (fp = fopen("/proc/net/dev", "r"))) {
/* not an error if we don't find this one as it
* isn't critical
*/
goto complete;
}
/* skip the first two lines as they are headers */
local_getline(fp);
local_getline(fp);
/* read the file one line at a time */
while (NULL != (dptr = local_getline(fp))) {
/* the interface is at the start of the line */
if (NULL == (ptr = strchr(dptr, ':'))) {
continue;
}
*ptr = '\0';
ptr++;
/* parse to extract the fields */
fields = NULL;
local_getfields(ptr, &fields);
if (NULL == fields) {
continue;
}
/* pack the ones of interest into the struct */
ns = OBJ_NEW(opal_netstats_t);
ns->net_interface = strdup(dptr);
ns->num_bytes_recvd = strtoul(fields[0], NULL, 10);
ns->num_packets_recvd = strtoul(fields[1], NULL, 10);
ns->num_recv_errs = strtoul(fields[2], NULL, 10);
ns->num_bytes_sent = strtoul(fields[8], NULL, 10);
ns->num_packets_sent = strtoul(fields[9], NULL, 10);
ns->num_send_errs = strtoul(fields[10], NULL, 10);
opal_list_append(&nstats->netstats, &ns->super);
opal_argv_free(fields);
}
fclose(fp);
}
complete:
return OPAL_SUCCESS;
}
static char *local_getline(FILE *fp)
{
char *ret, *ptr;
ret = fgets(input, OPAL_STAT_MAX_LENGTH, fp);
if (NULL != ret) {
input[strlen(input)-1] = '\0'; /* remove newline */
/* strip leading white space */
ptr = input;
while (!isalnum(*ptr)) {
ptr++;
}
return ptr;
}
return NULL;
}
static char *local_stripper(char *data)
{
char *ptr, *end, *enddata;
int len = strlen(data);
/* find the colon */
if (NULL == (end = strchr(data, ':'))) {
return NULL;
}
ptr = end;
--end;
/* working backwards, look for first non-whitespace */
while (end != data && !isalnum(*end)) {
--end;
}
++end;
*end = '\0';
/* now look for value */
ptr++;
enddata = &(data[len-1]);
while (ptr != enddata && !isalnum(*ptr)) {
++ptr;
}
return ptr;
}
static void local_getfields(char *dptr, char ***fields)
{
char *ptr, *end;
/* set default */
*fields = NULL;
/* find the beginning */
ptr = dptr;
while ('\0' != *ptr && !isalnum(*ptr)) {
ptr++;
}
if ('\0' == *ptr) {
return;
}
/* working from this point, find the end of each
* alpha-numeric field and store it on the stack.
* Then shift across the white space to the start
* of the next one
*/
end = ptr; /* ptr points to an alnum */
end++; /* look at next character */
while ('\0' != *end) {
/* find the end of this alpha string */
while ('\0' != *end && isalnum(*end)) {
end++;
}
/* terminate it */
*end = '\0';
/* store it on the stack */
opal_argv_append_nosize(fields, ptr);
/* step across any white space */
end++;
while ('\0' != *end && !isalnum(*end)) {
end++;
}
if ('\0' == *end) {
ptr = NULL;
break;
}
ptr = end;
end++;
}
if (NULL != ptr) {
/* have a hanging field */
opal_argv_append_nosize(fields, ptr);
}
}

Просмотреть файл

@ -1,93 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2008 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* pstat (process statistics) framework component interface.
*
* Intent
*
* To support the ompi-top utility.
*
*/
#ifndef OPAL_MCA_PSTAT_H
#define OPAL_MCA_PSTAT_H
#include "opal_config.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/dss/dss_types.h"
BEGIN_C_DECLS
/**
* Module initialization function. Should return OPAL_SUCCESS.
*/
typedef int (*opal_pstat_base_module_init_fn_t)(void);
typedef int (*opal_pstat_base_module_query_fn_t)(pid_t pid,
opal_pstats_t *stats,
opal_node_stats_t *nstats);
typedef int (*opal_pstat_base_module_fini_fn_t)(void);
/**
* Structure for pstat components.
*/
struct opal_pstat_base_component_2_0_0_t {
/** MCA base component */
mca_base_component_t base_version;
/** MCA base data */
mca_base_component_data_t base_data;
};
/**
* Convenience typedef
*/
typedef struct opal_pstat_base_component_2_0_0_t opal_pstat_base_component_2_0_0_t;
typedef struct opal_pstat_base_component_2_0_0_t opal_pstat_base_component_t;
/**
* Structure for pstat modules
*/
struct opal_pstat_base_module_1_0_0_t {
opal_pstat_base_module_init_fn_t init;
opal_pstat_base_module_query_fn_t query;
opal_pstat_base_module_fini_fn_t finalize;
};
/**
* Convenience typedef
*/
typedef struct opal_pstat_base_module_1_0_0_t opal_pstat_base_module_1_0_0_t;
typedef struct opal_pstat_base_module_1_0_0_t opal_pstat_base_module_t;
/**
* Macro for use in components that are of type pstat
*/
#define OPAL_PSTAT_BASE_VERSION_2_0_0 \
OPAL_MCA_BASE_VERSION_2_1_0("pstat", 2, 0, 0)
/* Global structure for accessing pstat functions */
OPAL_DECLSPEC extern opal_pstat_base_module_t opal_pstat;
END_C_DECLS
#endif /* OPAL_MCA_PSTAT_H */

Просмотреть файл

@ -1,46 +0,0 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2010-2011 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2017 IBM Corporation. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
sources = \
pstat_test.h \
pstat_test_component.c \
pstat_test.c
# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).
if MCA_BUILD_opal_pstat_test_DSO
component_noinst =
component_install = mca_pstat_test.la
else
component_noinst = libmca_pstat_test.la
component_install =
endif
mcacomponentdir = $(opallibdir)
mcacomponent_LTLIBRARIES = $(component_install)
mca_pstat_test_la_SOURCES = $(sources)
mca_pstat_test_la_LDFLAGS = -module -avoid-version
mca_pstat_test_la_LIBADD = $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la
noinst_LTLIBRARIES = $(component_noinst)
libmca_pstat_test_la_SOURCES =$(sources)
libmca_pstat_test_la_LDFLAGS = -module -avoid-version

Просмотреть файл

@ -1,32 +0,0 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2010-2011 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AC_DEFUN([MCA_opal_pstat_test_PRIORITY], [10])
# MCA_pstat_test_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_opal_pstat_test_CONFIG],[
AC_CONFIG_FILES([opal/mca/pstat/test/Makefile])
pstat_test_happy="yes"
AS_IF([test "$pstat_test_happy" = "yes"],
[$1],
[$2])
])

Просмотреть файл

@ -1,7 +0,0 @@
#
# owner/status file
# owner: institution that is responsible for this package
# status: e.g. active, maintenance, unmaintained
#
owner: INTEL
status: maintenance

Просмотреть файл

@ -1,128 +0,0 @@
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2019 Triad National Security, LLC. All rights
* reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/constants.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include "opal/runtime/opal.h"
#include "opal/mca/pstat/pstat.h"
#include "opal/mca/pstat/base/base.h"
#include "opal/util/string_copy.h"
#include "pstat_test.h"
static int init(void);
static int query(pid_t pid,
opal_pstats_t *stats,
opal_node_stats_t *nstats);
static int fini(void);
/*
* Test pstat module
*/
const opal_pstat_base_module_t opal_pstat_test_module = {
init,
query,
fini
};
static int init(void)
{
return OPAL_SUCCESS;
}
static int fini(void)
{
return OPAL_SUCCESS;
}
static int query(pid_t pid,
opal_pstats_t *stats,
opal_node_stats_t *nstats)
{
double dtime;
const char *hostname;
if (NULL != stats) {
/* record the time of this sample */
gettimeofday(&stats->sample_time, NULL);
/* check the nstats - don't do gettimeofday twice
* as it is expensive
*/
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) {
/* record the time of this sample */
gettimeofday(&nstats->sample_time, NULL);
}
if (NULL != stats) {
hostname = opal_gethostname();
opal_string_copy(stats->node, hostname, OPAL_PSTAT_MAX_STRING_LEN);
stats->pid = pid;
opal_string_copy(stats->cmd, "UNKNOWN", OPAL_PSTAT_MAX_STRING_LEN);
stats->state[0] = 'R';
stats->priority = 2;
stats->num_threads = 1;
/* set the values to something identifiable for testing */
stats->vsize = 1.75;
stats->rss = 1.23;
stats->peak_vsize = 7.89;
/* convert to time in seconds */
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) {
/* set the memory values to something identifiable for testing */
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;
/* set the load averages */
nstats->la = 0.52;
nstats->la5 = 1.03;
nstats->la15 = 0.12;
}
return OPAL_SUCCESS;
}

Просмотреть файл

@ -1,40 +0,0 @@
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef MCA_PSTAT_TEST_EXPORT_H
#define MCA_PSTAT_TEST_EXPORT_H
#include "opal_config.h"
#include "opal/mca/mca.h"
#include "opal/mca/pstat/pstat.h"
BEGIN_C_DECLS
/*
* Globally exported variable
*/
OPAL_DECLSPEC extern const opal_pstat_base_component_t mca_pstat_test_component;
OPAL_DECLSPEC extern const opal_pstat_base_module_t opal_pstat_test_module;
END_C_DECLS
#endif /* MCA_PSTAT_TEST_EXPORT_H */

Просмотреть файл

@ -1,85 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
* These symbols are in a file by themselves to provide nice linker
* semantics. Since linkers generally pull in symbols by object
* files, keeping these symbols as the only symbols in this file
* prevents utility programs such as "ompi_info" from having to import
* entire components just to query their version and parameters.
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/mca/pstat/pstat.h"
#include "pstat_test.h"
/*
* Public string showing the pstat ompi_test component version number
*/
const char *opal_pstat_test_component_version_string =
"OPAL test pstat MCA component version " OPAL_VERSION;
/*
* Local function
*/
static int pstat_test_component_query(mca_base_module_t **module, int *priority);
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
const opal_pstat_base_component_t mca_pstat_test_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
.base_version = {
/* Indicate that we are a pstat v1.1.0 component (which also
implies a specific MCA version) */
OPAL_PSTAT_BASE_VERSION_2_0_0,
/* Component name and version */
.mca_component_name = "test",
MCA_BASE_MAKE_VERSION (component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION),
.mca_query_component = pstat_test_component_query,
},
/* Next the MCA v1.0.0 component meta data */
.base_data = {
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
}
};
static int pstat_test_component_query(mca_base_module_t **module, int *priority)
{
*priority = 20;
*module = (mca_base_module_t *)&opal_pstat_test_module;
return OPAL_SUCCESS;
}